Pages Menu
Chitu Okoli chitu.okoli.org
Traditional Programming Versus OOP

Traditional Programming Versus OOP

Traditional Programming Versus Object-Oriented Programming

That’s about it for the general features of OOP. There are many other language-specific features that further the goals of handling complexity and enabling reuse, but with the tools from this primer, you’ve already tackled the hardest part: understanding the shift in programming philosophy that has led to OOP. Now that you understand the basic concepts of OOP, you can go ahead and learn an OOPL like Java or C++ and know how to use these languages to tackle problems from an object perspective.

What is left now is to complete the Shape example that we’ve begun, and thus demonstrate the OOP way of coding vis-à-vis the traditional way. We’ll use C++ so that you can see that the difference is not so much in the language used as it is in the software design. (Another reason I’ll use C++ is that it isn’t even possible to write Smalltalk or Java code the traditional way.)

 

Assignment

  1. Implement a rectangle and an isosceles triangle, each of which (a) creates itself; (b) displays its properties; and (c) prints itself.
  2. Implement a parallelogram with the same functionality.

To somewhat simulate a real development project, assume that at first all you were assigned was #1 (rectangle and isosceles triangle), then later you were told to create a parallelogram.

The best way to read the code will be to first read trad-shapes.cpp, the solution using traditional structured programming. Then next read oop-shapes.cpp, the object-oriented solution. Here’s the {tooltip}class hierarchy{end-link}This class hierarchy diagram is based on the universal modeling language (UML), a standard way to draw object-oriented class hierarchies; but it doesn’t follow UML exactly.{end-tooltip} that is used for the solution:

Post a Reply

Your email address will not be published. Required fields are marked *