Category: C Sharp

Welcome to the first post for a hypocrites guide to comments!

My first piece of advice in my guide to comments is that you shouldn’t use comments.

That is, if you choose your variable names and method names well, lay out your code well and your code is doing something trivial ( I mean really trivial, not something that seems trivial now but won’t be in three months time when you’re no longer immersed in the project) then your code might not need comments.

To illustrate this consider have a look at this code:

float a(List <int> b)
 int c = 0; float d = 0;
 for (int i = 0; i < b.Count; i++){
 if (b[i] != 0)
 d += b[i];
 return d / c;}

Can you work out what that code does? How long did it take you to work it out?

Now look at this code:

float getAverageNonZeroMark(List <int> pListOfMarks)
   int numberOfNonZeroMarks = 0;
   float totalSumOfNonZeroMarks = 0;
   for (int i = 0; i < pListOfMarks.Count; i++)
      if (pListOfMarks[i] != 0)
         totalSumOfNonZeroMarks += pListOfMarks[i];
   return totalSumOfNonZeroMarks / numberOfNonZeroMarks;

Can you work out what that code does?

From the machine’s perspective these two pieces of code are pretty much the same. I expect that the compiler will perform the same optimizations on both pieces of code and two end results may well be identical. From a programmers perspective though, the two pieces of code are far from equal.


A while ago I was fortunate enough to be allowed access to the PlayStation Suite Closed Beta testing. PlayStation Suite is an IDE for developing for PlayStation Certified Devices such as the PSVita.

PSSuite - pretty similar to using XNA in Visual Studio

Today I got an email letting me know that PS Suite had moved on to open beta. I had a very brief look at the closed beta version, but unfortunately I wasn’t able to allocate a great deal of time to it. Just enough to convince myself that should I want to I would be able to use it without too much bother.

With the Open Beta came a promise that after the Open Beta “you can offer developed games and applications to a wide variety of users through the PlayStation®Store” for a fee of $99 dollars a year. This was also covered at a talk at GDC. I didn’t go to that talk, but now I have access to the vault so I can watch it at my leisure.

Watch this space for any significant news!

C# Pop Quiz

Look at this code:
int count = 0;

for(uint i = 10; i >=0; --i)

Console.WriteLine("Count is " + count);

What does it do?
...and don't compile it. That's cheating!