OO Programming  «Prev  Next»
Lesson 3 Object-oriented approach to Design
Objective OO Programming differs from procedural programming.

OO Programming compared to Procedural Programming

Object-oriented programs follow a different path than procedural programs. In procedural programming, you think mostly about the algorithms and data structures that are used to model the problem and divide the problem into a series of procedures.
In OOP (an abbreviation for object-oriented programming), you think about the system you are modeling and how the elements in the system interact with each other. In procedural programs, the procedures are the highest-level elements. They define what the program does and the data is almost an afterthought.

In object-oriented programs, the classes are the highest level elements.
The classes contain the functions (or the methods, as they're referred to in OOP jargon) and the data. In procedural programming, data belongs to functions or occasionally is stored in global variables.
Object-oriented programming languages encapsulate both data and methods in classes.

What Is Object-Oriented Analysis and Design?

During object-oriented analysis, there is an emphasis on finding and describing the objects, or concepts in the problem domain. For example, in the case of the library information system, some of the concepts include Book, Library, and Patron.
During object-oriented design, there is an emphasis on defining software objects and how they collaborate to fulfill the requirements. For example, in the library system, a Book software object may have a title attribute and a getChap-ter method (see Figure 2-3). Finally, during implementation or object-oriented programming, design objects are implemented, such as a Book class in Java.

Object-orientation emphasizes representation of objects.
Figure 2-3: Object-orientation emphasizes representation of objects.

Object Programming

The difference between programmers who use objects in their code and those who truly grasp object-oriented programming[1] comes down to the way their objects relate to each other and to the overall design of the program. This module begins with a very brief description of procedural programming (C-style), followed by a detailed discussion of object-oriented programming (OOP).
Even if you have been using objects for years, you will want to read this module for some new ideas regarding how to think about objects. A discussion of the different kinds of relationships between objects includes pitfalls programmers often succumb to when building an object-oriented program. You will also learn how the principal of abstraction relates to objects. When thinking about procedural programming or object-oriented programming, the most important point to remember is that they just represent different ways of reasoning about what is occurring in your program. Too often, programmers get bogged down in the syntax of OOP before they adequately understand what an object is. This chapter is light on code and heavy on concepts and ideas.

[1]Object-oriented programming: Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code: 1) data in the form of fields (attributes or properties) and 2) code, in the form of methods.