Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code cleanup branch
08-06-2006, 11:25 PM,
#28
 
joevenzon Wrote:
Quote:Unlike globals, you can know and control exactly when the data is created.

How is this useful for a class that is expected by the coder to always be present? I understand what you're saying, and you're right, it's technically an advantage, but in the context of this game how would it be an advantage?

This may not apply specifically in our case. You are correct, but as we redesign the code, things like this may become a concern to achieve a faster startup time or do other optimizations.

Quote:
Quote:you can catch any exceptions that may be thrown during construction

How is this useful unless you're doing a lot of serious loading within the constructor (bad style)? You should always have a separate Load() function if you're going to be doing something that relies on external data -- not in the constructor! If it's not obvious why, I can elaborate. Again, I understand that it's technically an advantage, but in the context of this game I don't think it'd ever be useful.

Here we hold different opinions. I think it is preferble to initilize as much of an object as you can when you create it, which also means creating it closest to it's first use. There will always be cases where it does not make sense to do that.

You seem to prefer a seperate Load()/Init() function.

Quote:
Quote:3) they use static data

My point there was just that IF someone wants to use singletons simply because they don't have the stigma of globals, then they'd be deceiving themselves, because singletons use statics, and statics are in fact globals.

Based on the two advantages above, which I seriously doubt would ever be used in this game, they're not even worth the minimal extra typing that would be required to use them -- not to mention the time spent implementing them.

Although I do think globals should generally not be used, there are very few absolutes when it comes to things like this. There are plenty of cases where globals are just fine. In our case with vdrift, a lot of the globals we use would work better as singletons in my eyes. I can't point out any specific instances with out diving into the code, but this is the impression I got from my past adventures through the source.

Also I am not against globals for begin globals (as you say, statics are globals, they just have a limited namespace/scope and are created at a different time).

Quote:If you (or thelusiv) want to spend that time to get everything working with singletons in the code-cleanup branch, I'm willing to take a second look at their merits for use in this project. Until then, though, I'm sticking to my guns.

We could go on quite a while back and forth with the pros and cons of each approach Smile. I think we have presented a good overview of the issue here, and I say we leave the decision of what to do in his branch with Chris. Once it's done as you said, you can take what you like and leave the rest.
Reply


Messages In This Thread
Code cleanup branch - by thelusiv - 08-01-2006, 01:46 AM
[No subject] - by FFuser - 08-01-2006, 05:34 AM
[No subject] - by joevenzon_phpbb2_import3 - 08-01-2006, 08:28 PM
[No subject] - by thelusiv - 08-01-2006, 08:39 PM
[No subject] - by alex25 - 08-01-2006, 11:38 PM
[No subject] - by thelusiv - 08-03-2006, 12:31 AM
[No subject] - by joevenzon_phpbb2_import3 - 08-03-2006, 10:28 PM
[No subject] - by thelusiv - 08-03-2006, 10:33 PM
[No subject] - by thelusiv - 08-03-2006, 10:33 PM
[No subject] - by matthew_i - 08-04-2006, 01:20 AM
[No subject] - by matthew_i - 08-04-2006, 01:20 AM
[No subject] - by thelusiv - 08-04-2006, 01:38 AM
[No subject] - by thelusiv - 08-04-2006, 01:38 AM
[No subject] - by matthew_i - 08-04-2006, 01:41 AM
[No subject] - by matthew_i - 08-04-2006, 01:41 AM
[No subject] - by thelusiv - 08-04-2006, 01:53 AM
[No subject] - by thelusiv - 08-04-2006, 01:53 AM
[No subject] - by matthew_i - 08-04-2006, 01:58 AM
[No subject] - by matthew_i - 08-04-2006, 01:58 AM
[No subject] - by thelusiv - 08-04-2006, 09:08 AM
[No subject] - by thelusiv - 08-04-2006, 09:08 AM
[No subject] - by joevenzon_phpbb2_import3 - 08-04-2006, 08:38 PM
[No subject] - by joevenzon_phpbb2_import3 - 08-04-2006, 08:38 PM
[No subject] - by matthew_i - 08-06-2006, 02:43 PM
[No subject] - by matthew_i - 08-06-2006, 02:43 PM
[No subject] - by joevenzon_phpbb2_import3 - 08-06-2006, 07:45 PM
[No subject] - by joevenzon_phpbb2_import3 - 08-06-2006, 07:45 PM
[No subject] - by matthew_i - 08-06-2006, 11:25 PM
[No subject] - by matthew_i - 08-06-2006, 11:25 PM
[No subject] - by joevenzon_phpbb2_import3 - 08-07-2006, 09:26 AM
[No subject] - by joevenzon_phpbb2_import3 - 08-07-2006, 09:26 AM
[No subject] - by thelusiv - 08-07-2006, 04:43 PM
[No subject] - by thelusiv - 08-07-2006, 04:43 PM
[No subject] - by clytle374 - 08-07-2006, 04:51 PM
[No subject] - by clytle374 - 08-07-2006, 04:51 PM
[No subject] - by thelusiv - 08-07-2006, 06:25 PM
[No subject] - by thelusiv - 08-07-2006, 06:25 PM
[No subject] - by clytle374 - 08-08-2006, 12:47 AM
[No subject] - by clytle374 - 08-08-2006, 12:47 AM
[No subject] - by thelusiv - 08-08-2006, 09:05 AM
[No subject] - by thelusiv - 08-08-2006, 09:05 AM
[No subject] - by clytle374 - 08-08-2006, 07:19 PM
[No subject] - by clytle374 - 08-08-2006, 07:19 PM

Forum Jump:


Users browsing this thread: 13 Guest(s)