Skip to content

Managing Complexity

Estimated time to read: 2 minutes

From Introduction to Object-Oriented Programming With Java

Why use Object-Oriented programming

Object Orientation starts way back in SmallTalk 80, by IBM. It did not become mainstream at the time.

Apple releases the Macintosh in 1978 and Object-Orientation becomes an issue as Graphical User Interfaces become common place and users are presented with multiple choices at a time. This proved problematic for developers as there was no longer a linear approach to user interaction.

Apple introduced Object-Orientation into PASCAL and the first graphical framework, MACAPP. This graphical framework made it possible for developers to write code to respond to a users selection in the GUI, without having to manage the underlying system, as this was taken care of by the framework, MACAPP.

Early 90's saw the emergence of object-oriented frameworks to help program on Windows. This coincides with the formation of C++ as a formidable language.

The complexity of needing to interact with graphical environments drove the uptake of object-oriented programming.

Java attempts to address the same challenges to this day. It supports UI frameworks out of the box and as it has evolved into the server realm, these frameworks became the basis upon which application frameworks have been built.

Java is not a pure object-oriented language, but its roots can be found in the object-oriented programming emergence. It is a hybrid environment, due to its use of primitives, classes and objects.

Encapsulation as a concept

A primary concept of Java is encapsulation. Object Oriented programming uses encapsulation to isolate complex sections of code. Programmers can used code without having to understand the details of how it works.

The idea of encapsulation is that if you were not the implementer of a class, but you are the user of a class, all you get to know about the employee class, it is what is published as its interface, a contract to you, what methods are available for you to use. But how it goes about doing that, is none of the users business, it is encapsulated and hidden away.

Java does allow public data, but as a general rule this should not happen! Access to data should be given through methods.

As methods could be updated and changed at any time, all that a programmer needs to know is what needs to be provide to the method to make it work, what is the contract provided by the method.