Structure and Object Orientation

As a beginner and student of programming languages, there are many new concepts to learn and understand. Many of these concepts are designed to make things clearer, not only to learn, but to put into action. It seems like one of the most important aspects of good code is clear and understandable architecture.


Everything is better off with a solid structure. Buildings, cars, people, politics; all of these are stronger as a result of an organized structure. So, as we go into coding, it should also be important to recognize this common idea and be able to understand it to a functional level.

Object-oriented programming (OOP) is a programming paradigm based on the concept of “objects”, which are data structures that contain data, in the form of fields, often known as attributes; and code, in the form of procedures, often known as methods. A distinguishing feature of objects is that an object’s procedures can access and often modify the data fields of the object with which they are associated.

So, we create objects that can be reused and altered as needed to perform repeated tasks. I play the drums. When i pick up a stick to attack the drum head, my mind thinks to hit the drum in a certain way that correlates to the music i am trying to emulate. I do not think about how my heart is pumping blood to my fingers. I do not think about where my elbow is positioned, and i do not think about the actions of my muscles and nerves in my hand. The hand, elbow, and heart are all objects. The do not need to be brought up front in my mind every time i hit a drum, it has become a fluid motion. This way, i can play faster and with less energy use. This also applies to programming.


With often limited memory resources and speed, you do not want a computer to perform multiple repeated functions for every action. This would slow your computer down, and the code itself would be a nightmare to read. I have seen some code that looks very complex, but i have found that often code looks complex because its not structured. Things are not in a tidy package, programmers are telling a computer to perform long functions repeatedly for each action. It is a mess of code.

I have also seen code that performs a similar task that looks very understandable and organized. Each process is separated out into reusable “classes”. The classes are saved on a separate file and read in with one line to the main code. This also goes for styles, which are read in from style sheets by one line of code. This way you can work on compartmentalized code and not lose track of where you were or get distracted by another possible flaw that should be saved for another time.

And your coding is more efficient. You already have the necessary methods and classes written. you just need to reference them as you write new code. Copy and paste old classes into new code, and you already know it works. The stick strikes the drum at blazing speeds, the muscles and nerves are not slowing you down, they already work. The mind does not need to slow down to think and neither does your computer.

There will certainly be situations where OOP is not the best way. I have heard about some really complex programming where it does not work as good as it may seem in some languages.

It is no longer possible to detect execution flow bugs with a simple code review. Going over an Assembly code it is very easy to detect simple bugs such as down-casting, potential overflows etc. Reading an object oriented code you can’t see the big picture and it is often impossible to review all the small functions that call the one function that you modified.
Asaf Shelly, Flaws of Object Oriented Modeling

Although Asaf may be correct in use for assembly language, for my basic understanding and use in high level languages, object oriented programming is the best way to keep your code organized and structured.

This sums up my very basic analogy of object oriented programming and code architecture. I find it helpful to write about these difficult concepts in ways i can understand. In the next year of schooling i will be learning more detail about this and putting it into better action. I look forward to writing great code and better analogies!

Leave a Reply

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