Tuesday, July 17, 2001

Thoughts on Objects

Amsterdam, The Netherlands

There seem to be two types of behaviour when it comes to using object oriented frameworks. Programmers and Designers generally tends to fall into two types of categories. There are the acquisitive programmers and then there are those existive programmers.The former tends to use an inordinate amounts of associations in their models (generally compositions) while the latter focuses on using inheritence to solve their programming problems. The question is not on of which is better as it is quite possible to solve a problem using either. Generally acquisitive systems are equivalent to existive models. But the question is why one would tend to sway more in one direction than the other.

For instance if a class say a Portfolio needs to hold and track a list of financial instruments, one could either model a class Portfolio and use an acquisitive relationship to say a Vector class to contain the instruments. Such a model would result in a class that exposes facilities to add , remove or ammend the objects contained in the vector. The resulting class could therfore contain at least three more methods that are more to do with manipulating the contents of the vector than actually related to the various business methods related to portfolio. On the other hand, one could model a portfolio as a subclass of say a Vector. The resulting classes would not require the methods related to the manipulation of the vectors contents as they are already contained in the Portfolio through its existive relationship. The additional methods that one could add to the class are purely related to the business methods required of the class. The existive solution seems more esthetic but generally such a solution is not used (atleast I have never come across such a solution) ,however such a solution would seem to violate the morphological relationships inherent in using existive relationship. After all, a portfolio is not a vector and the semantics that one associates with a vector seem out of place when they are regarded as intrinsic to the behaviour of a portfolio. Nevertheless, either of these solutions would work, the difference would be that in the case of the acquisitive relationship, the programmer would have to write more code than in useing the existive relationship.

No comments: