Archive for April, 2008
My Experience With Perfecting OO’s Small Classes and Short Methods
I read this blog post about OO programming. In a nutshell, the article gives you an exercise to flex your OO-programming muscle. It’s not meant to be used in a real-life situation. But it’s a fun exercise for programmers to try to get their brains in shape.
Since my OO skills are not up to par, I decided it could be a fun thing to try. I haven’t finished my little project, but I already ran into some roadblocks.
The main roadblock I ran into was the constraint of not having more than 2 instance variables. That constraint was challenging to get around. The only reason was because of the other constraint: not having getters, setters, and properties.
For example, let’s say I have a class called Person. And that Person has a name, age, and phone number. So that would be 3 instance variables inside the Person class. But the rule says to have only 2. That’s no problem, I’ll just create another class called PersonalInfo and store those name and age values in there. And the Person class can have the one PersonalInfo instance variable and the phone number instance variable.
That’s fine and dandy, but that causes a problem. I have to use PersonalInfo class as a datastore. So I need to have getters and setters for that class. This is a problem in Java. In C# or C++, all you need to do is create a PersonalInfo struct. In JavaScript, you can store them in an object literal (maybe that’s cheating since all objects in JavaScript are pretty much object literals). But Java doesn’t have a struct. So what do we do?
If I was using Java, I would’ve probably created a class called Struct class that can store properties. I haven’t thought of how to implement that though. Luckily I didn’t use Java.
Overall, I think the exercise is fun way to expand your mind. It did get me thinking more creatively. There was another challenge I found that I might try out next. It was to use all the constraints mentioned in the article, but classes can’t have instance variables. No instance variables? That sounds hard.
The Weather Channel Desktop 6
The new version of Weather Channel Desktop is out. If you’re a MLB fan you can download their MLB version as well. Yes, I’m pimping my own software that I was a big part of. In fact, I even did the two download websites that I linked to. So go and download it and see what you think. If you find any bugs, it’s not my fault.