Showing posts with label C++. Show all posts
Showing posts with label C++. Show all posts

Jun 27, 2009

To pointer, or not to pointer: That is the question

For a very long time now I've been looking for good explanations of pointers, and how the varying kinds differ.I've finally found a book that does a good job of explaining what they are and how they differ. The book is by Bjarne Stroustrup (the creator of C++) it's called Programming: Principles and Practice Using C++. The book is supposed to teach you how to program (become a good programmer) using C++ not teach the C++ language. The question that Stroustrup poses is How do we choose between using a reference argument and using a pointer argument? his answer to the question is quite in depth, however I'll reiterate his summary here in the hopes that it's useful for someone.
So, the real answer is: "The choice depends on the nature of the the function":
  • For tiny objects prefer pass-by-value.
  • For functions where "no object" (represented by a 0) is a valid argument use a pointer parameter (and remember to test for 0).
  • Otherwise, use a reference parameter.
Ok, that alone seems a little confusing. I'm just going to use function declarations to denote the differences in code.

According to him, pass by value is the least error prone, but it copies memory and is therefore more expensive. To do this you'd declare a function like int func_name(int x);.

"No object" in my quote is another term for "Null pointer" which he defined previous to this but wasn't in my quote. If no argument to the function is valid you'd use that. It's declared like int func_name(int* x);

The last option is to use a reference pointer. these are declared as int func_name(int& x).

I still have some trouble with the what/why/when to use pointers, but I'll probably just go back through this a few times. Stroustrup's explanation is still the best I've seen. I'd suggest his book to any novice programmer. I'm not sure if it's the best for someone who's never seen any code as it goes quite fast. It doesn't spend hardly any time at all on language constructs, which most books do. I don't think so fast that you couldn't use it as a 'first programming book' but it might be good to have a book that covers the constructs (like for loop) in depth.

Mar 12, 2008

Dawn of War: Soulstorm

To start I just got this game so I will be expanding this review throughout the next few days.

First the Bad.

The intro movie (to the game) feels more cartoony than the previous ones, I don't like the style. I don't feel that it is on par with Relic's previous movies. This is a trivial complaint and perhaps merely artistic preference.

There doesn't seem to be a race intro movie like there was in Dark Crusade. I really enjoyed these they made it feel more like freeform campaign than a large free for all. The campaign intro is there and very well put in setting the stage like there was in Dark crusade.

Interplanetary map navigation is clumsy (might not be the word I'm looking for). On my laptop at 800x600 resolution it is hard to tell sometimes what territory you are hovering over, and you can't zoom in on the planets first. you must select the territory and attack or zoom in (can't think of game term) on it, once there you can see the surrounding territories but not select them. The map is semi 3d it would be nice if it could be zoomed and navigated as if the planets were real. The close up planet maps are tacky looking too, they seem less high quality than Dark Crusade.

I have yet to find any maps with special objectives (and rewards, like Dark Crusade's Spaceport) outside of enemy strongholds. I don't believe they exist unfortunately.

The only maps with special objectives (outside annihilate and take and hold) are the enemy strongholds. And these maps are mostly accomplished with annihilate. I admit the take and hold maps are difficult, mostly because they require you to go on the offensive early as you can't allow your enemy to have control.

The enemy strongholds do contain somewhat of a story... however it is less than it was in Dark Crusade, as it seems one way. There was a dialog between attacking and defending races in Dark Crusade. Now there seems to be just the movie, and some occasional banter on the attacking side but I have yet to see it be between the opposing armies commanders.

I believe that the Dark Eldar may be over powered. They are giving my Space Marines a run for their money on easy, and this is after I stomped the Orks and Tau. They have managed to beat Chaos as well, I find this odd on easy.

The Deep Strike power for the Space Marines seems to be bugged. I only figured out how to use it on my assault of the Tau Stronghold and it hasn't worked since. The Ork Special power was very hard to find work and it's description should be more clear. It will add infantry units to your territories (I haven't determined how). But perhaps even more useful is that it will replace 1 infantry unit in your honor guard per turn. If there is only one to replace it, will replace that one, otherwise I think it may replace the cheapest first. The Tau special power is barely useful, it merely downgrades the territory you are attacking by one just before you commit to the attack. I highly doubt Chaos's power will be useful either I've yet to have anything attempt to cut my supply line...

Both the Dark Eldar and Sisters of Battle are interesting races to play, and you will enjoy them if you enjoyed races of the previous games. I found soul harvesting for the Dark Eldar confusing at first, however there is an upgrade the to the 'slave-torture chamber (?)' that will produce souls, have 2 of those upgraded and 2 harvester's a piece and I was set for any battle. The Sister's of Battle's Faith resource I still haven't fully figured out what generates it (I believe units) however I've never had a problem attaining it.

Air support has been added to the races, it seems like a hack they don't move like they should and don't seem overly useful, although they can hit fairly heavy and quickly. Without a full range air force (bombers, fighters, stealth, cruisers, etc), air strategy just isn't there.

To summarize, the new races in Soulstorm are a worthy addition, Air support is a bad hack, there's less plot, and movies, and the map interface is cludgy.

I give this game a C grade, because I believe the developers could have done better and chose not to.