Monday, 16 February 2015

Object Oriented Programming, thoughts

This weeks opinion piece/assignment is about Object Oriented Programming concepts and what I think of them. As in all things there are the good, the bad and the ugly. I will start with the good. There seems to be a nice compact organization about the way like actions are grouped together. The class system, computer not social, is a logical grouping of similar activities (methods). I can see how over the long run especially with large complex programs that farming off repeatable activities into methods allows the underlying logic of those methods to be changed without effecting the downstream functions that are using them. As long as the functionality of a method doesn't change than improvements can be made without destroying the whole and with limited duplication of effort.

Now on to the bad. This is where we end up going down the rabbit hole. Not everything can fit in the nice construct of a class but there is the temptation to try anyway. This is akin to finding a nice colour of blue paint, you paint one room with it and you think it looks so awesome that you proceed to paint every room in the house the same colour. The paint is still a nice colour but now your house looks ridiculous. It is pretty simple logic to go from classes being good to having everything in classes as being better. That is one possible outcome, but not the only possible outcome!

And finally the ugly, unreadable code. I think this is where we take the bad to the extreme. Chopping things into smaller and smaller classes and sub-classes so it becomes difficult to know which class is doing what. At some point the programmers using your classes won't know where to look for things and end up writing functions that recreate what exists in multiple classes. I am sure nobody wants to end up there but I can definitely see it happening.

My overall impressions are very favourable and enthusiastic for OOP. I can see why the programming world has gone this direction since it makes such logical sense. As long as I stay aware of the possible pitfalls and not get carried away (like I did with recursion) then all will go well. I think the goal is consistency. Be organized at the start and only the good will happen, not the bad and the ugly.

1 comment:

  1. It's really interesting that you comment on the potential problem of OOP. I feel that I tended to divide too much after reading your post.

    ReplyDelete