5.6.2 Drawbacks



next up previous contents
Next: 5.6.3 Comparison to Object-Oriented Up: 5.6 VOOPS Previous: 5.6.1 Why Object-Oriented Programming?

5.6.2 Drawbacks

Due to the recent enthusiasm about object-orientation in general and object-oriented languages in particular, some non-obvious but intrinsic drawbacks are often overlooked. First of all, it has to be noted that the problem to which object-oriented approaches should be applied, has itself to be object-oriented. Since an object is an encapsulated entity that has precisely known relations to other entities, an object-oriented approach to a problem which cannot be expressed as such an entity-relationship model will likely fail or at least exhibit severe performance drawbacks.

Another drawback is that arithmetic expressions involving method invocations cannot be simplified by a compiler, if the method to be invoked is not known at compile time. For example, an arithmetic expression calculating the volume of a hollow sphere will typically involve a subtraction of the inner sphere volume from the outer sphere volume. A FORTRAN compiler will simplify and optimize the resulting arithmetic expression resulting in a significant speedup compared to a C++ compiler which will have to invoke the method for computing a sphere volume two times and then perform the subtraction without having an opportunity to optimize the resulting arithmetic expression. Keeping this instrinsic drawback in mind, an object-oriented approach to solving numerical problems at least seems to be problematic and is definitely a non-optimal solution for this class of problems.

Memory management is another issue of concern when object-oriented approaches are considered. Objects are usually allocated separately, and when many (especially small) objects are allocated, the main memory becomes cluttered with those small allocated structures. The drawback is, that on traversion of, e.g., a tree of those small objects many different memory locations have to be addressed and accessed by the program, and performance will probably suffer severly if memory pages then have to be swapped in and out of main memory by the operating system. A traversion of, e.g., a FORTRAN array which is hold in one contiguous block in main memory just requires incrementation of an index variable and does not induce any operating system overhead at all.

Determining the function which has to be called at run time occurs frequently during execution of a program written in an object-oriented language, when the appropriate method to be applied to a given object has to be found by the run time inheritance mechanism. The performance of the resulting program will heavily depend on the efficiency of the inheritance algorithm which has to search the class hierarchy for the appropriate method, but will definitely be inferior compared to procedural languages like FORTRAN or C, where the functions called are already known at compile time and therefore are invoked directly.



next up previous contents
Next: 5.6.3 Comparison to Object-Oriented Up: 5.6 VOOPS Previous: 5.6.1 Why Object-Oriented Programming?



Martin Stiftinger
Tue Nov 29 19:41:50 MET 1994