2006/03/11

Let there be a class!

Suddenly, eveything started becoming a class. Or, atleast, most of the things. To struct or to class?
Didn't make much difference in performance. But class allows one to make members/member-functions private and protected.
Now, you must have heard this saying (of sorts) - 'If you have a hammer, every problem looks like a nail!' Similarly, you are tempted to fit all your functions into some class. So much so, that you might end up declaring/defining classes entirely for the purpose of fitting some function somewhere!
OO is a good technique (if you got me wrong ...) - but how it should be applied comes only with experience. And experience is something that doesn't come only with time, sadly. You need to be exposed to good people, good projects, and sometimes, good search engines!
Another thing that you get with experience is this - you know what exactly to look for in a given situation. Or, approximately exactly.
I can say all this with the benefit of a lot of hindsight. Don't expect me to be absolutely right though. Because my hindsight next year would be definitely better than my hindsight today.
And for those who have reached this paragraph - I suggest you read this nice article by Scott Meyers. (Warning: The article's website needs you to register.)

0 Comments:

Post a Comment

<< Home