Archive for February, 2013

Object oriented sanity

Sometimes when a principle is stated, it seems like it must be perfect and unmodifiable. In object-oriented design, we have the SOLID principles (you can google that) which are taken sometimes to be software gospel. I like this caution from Joel Spolsky’s blog (emphasis mine):

One of the SOLID principles, and I’m totally butchering this, but, one of the principles was that you shouldn’t have two things in the same class that would be changed for a different reason [PDF]. Like, you don’t want to have an Employee class, because it’s got his name which might get changed if he gets married, and it has his salary, which might get changed if he gets a raise. Those have to be two separate classes, because they get changed under different circumstances. And you wind up with millions of tiny little classes, like the EmployeeSalary class, and it’s just… (laughs) idiotic! You can’t build software that way! The way real software works is that you create these very imperfect things, and they work great. They really do. And then you have a little problem, and you go and you fix the little problem, because it’s code, and you have an editor, and you edit it. These classes are not going to go wander off flying in the universe all by themselves and need to work perfectly and unchanged until the end of time.


By Mark Ritchie in Uncategorized  .::. (Add your comment)


You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.