Object Programming  «Prev  Next»
Lesson 2 Object fundamentals
Objective Explore the basics of object-oriented programming.

Object Oriented Fundamentals

The goal of all programming languages is to make it easier for humans to communicate with machines. Object-oriented programming languages extend this notion by allowing programmers to think in terms of real-world objects. Java has only added to the excitement surrounding object-oriented programming, or OOP (rhymes with hoop) for short. OOP attempts to narrow the gap between problems in the real world and solutions in the computer world.
In the real world, we naturally think in terms of "things," but pre-OOP programming languages forced programmers to think in terms of blocks of code (procedures) and the data they manipulate. OOP suggests that programmers think in terms of objects, or things, much like we think of things in the real world.

Adaptability

Modern software applications, such as Web browsers and Internet search engines, typically involve large programs that are used for many years. Software, therefore, needs to be able to evolve over time in response to changing conditions in its environment. Thus, another important goal of quality software is that it achieves adaptability (also called evolvability). Related to this concept is portability, which is the ability of software to run with minimal change on different hardware and operating system platforms. An advantage of writing software in Java is the portability provided by the language itself.

Reusability

Going hand in hand with adaptability is the desire that software be reusable, that is, the same code should be usable as a component of different systems in various applications. Developing quality software can be an expensive enterprise, and its cost can be offset somewhat if the software is designed in a way that makes it easily reusable in future applications. Such reuse should be done with care. One of the major sources of software errors in the Therac-25 came from inappropriate reuse of Therac-20 software. The software written for the Therac-20 was not object-oriented and not designed for the hardware platform used with the Therac-25, which resulted in the damage and death of several patients.


Therac-25 relied heavily on software to prevent radiation damage.
Therac-25 relied heavily on software to prevent radiation damage.

Object orientation is an approach to software development in which we focus on objects, attributes, and responsibilities. All business problems involve things and these things can be mapped to a set of objects, such as smart phones. In any given business problem the various components have attributes like screen resolution, keyboard input. These components have responsibilities such as connect to internet and display data. The object oriented approach of system building starts with the earliest phase of analysis of the business problem. In this early phase, object modelers center on identifying the objects involved and their corresponding attributes and responsibilities. One interesting part of object orientation is that it closely parallels the real world, much more so than the traditional structured approach as used with procedural programming. This allows for a more thorough and accurate modeling of the business problem in the system design.
Object orientation can be defined as, a system of cmponents which encapsulate data and function, inherit these things from other components, and communicate via messages with one another.
In the object oriented approach we not only identify the objects required, but we also organize them into classes of objects.