Thursday, April 20, 2006

Share what you love

I read recently something along the lines of 'Doing what you love does not lead to wealth unless you also share what you love with others.'

It really seems to ring true for me. If you love sport, but spend all day watching it alone then you are not going to get rich. If you spend all day sharing your love of sport with others (coaching, compeating, or commentating) then yes you can make money at it. Infact the more people you share it with the more money you can make.

Wednesday, April 19, 2006

Who needs road rules?

There is a theory that if you take away the road rules everyone would have to driver slower and safer to make sure they don't have accidents. There is evidence to back this up. Think about your local street. Imagine kids were frequently playing ball in the road. How fast would you drive? If there was an accident the kid would get hurt, but not killed. Parents are scared their kids will get hurt, so people move off the streets to the front lawn.This gives the cars a chance to go faster, this makes the roads less safe, so the kids are told to only play in the back garden. This means the cars can go even faster. Now if there is an accident it will be fatal. Take a look at this footage from an intersection in india. The cars all keep moving. The speeds are quite slow though. Everyone expects someone to get in their way. No accidents.

There has to be a simpler way!

Tuesday, April 11, 2006

Comments are for 'why?'

I have blogged on this before, but I keep running across it, so here goes again...

Here is a snippet from some VB code I am having to clean up at the moment.

    Public Property PasswordKeyboard() As Boolean
'Retrieves PasswordKeyboard
Return boolPasswordKeyboard
End Get
'Assigns to PasswordKeyboard
Set(ByVal Value As Boolean)
boolPasswordKeyboard = Value
End Set
End Property

Check out the comments! Your code should clearly explain to the reader your understanding of the problem domain, and your solution to the problems involved. Your code should answer a few questions: What is it doing? How is it doing it? and Why is it being done that way?
'What' should be covered by the method and class names.
'How' is covered by the method body (which should be made easy to read)
'Why' is something you can't easly enbed in the code. This is where comments are invaluable. This is what comments are for.

The only reason I can see for having the comments in the above code is to explain why you put the following lines of code in the file. This only make sence if you are trying to document/teach the VB
language. Maybe this is why this problem is so prolific. When someone learns to program they come across this sort of commenting all the time in tutorials. Students duplicate what they are fed, so they add the same comments to their own code.

Do me a favor... if you see this style of commenting anywhere in code you have your hands on, just delete it. The code will be MORE readable, and smaller. Your brain will thank you.

GitHub Projects