Jumat, 05 Oktober 2012

The Essence of Object Oriented Programming with Java and UML by Bruce E. Wampler, Ph.D.




The Essence of Objects

class A class is a description of a set of objects. The set of objects share common attributes and common behavior. Class is similar in concept to abstract data types found in non-OO programming languages, but is more comprehensive in that it includes both structure and behavior. A class definition describes all the attributes of member objects of that class, as well as the class methods that implement the behavior of member objects.

object The basic unit of object orientation. An object is an entity that has attributes, behavior, and identity. Objects are members of a class, and the attributes and behavior of an object are defined by the class definition.

class is a description or definition of the characteristics of objects that belong to that class. An object is a single instance or member of a class that is created and exists while the program is running. A class may have just a single object or any number of member objects existing at any given time. All members of a class have similar behavior.

For example, consider a software system used to monitor various sensors in a factory. One obvious kind of object present is such a system is a sensor. A class called Sensor would be defined and used to model physical sensors. The class would define the basic characteristics of any Sensor, such as its location, value, and identification number, as well as a set of services used to carry out its responsibilities. Each individual physical sensor in the system would be represented as an object belonging to the class Sensor, and have specific values for the attributes described by the class definition.
The class description includes the means of accessing and changing the state of individual object members of that class. A common representation of color is called RGB, where the color is specified by the values of its red, green, and blue components. One possible design of a class called Color could provide the means of manipulating the color by both retrieving and setting the RGB values of a Color object. In an object-oriented system, it is typical to describe one class based on a pre-existing class, either by extending the description of a higher level class, or by including the description of another class within the current class. For example, you could create one class that describes the general characteristics of all sensors, and then more specialized classes that describe specific sensors such as temperature or pressure sensors, each based on the original general Sensor class.
Placing attributes and responsibilities in a top level general class can provide many benefits. For example, if the responsibilities of the general Sensor class included keeping track of a history of readings from a sensor, programming that capability could get somewhat complex. By placing the history code in the top level class, that code need be defined only once, and won't be repeated in new classes. Each of the specialized sensors can then use the history capabilities of the top level Sensor class. Objects and classes are really the heart of object orientation. OO software systems consist of objects of different classes that interact with each other using well-defined methods or services specified by the class definitions. When used properly and consistently, object- oriented software development leads to programs that are robust, and easy to debug, modify, and maintain. To produce successful OO programs, it is important to always "think objects." Just because a program is written in Java or C++ does not mean it is an object-oriented program! If you have a programming background that is not OO based, or even if you've just learned Java, one of the great challenges is to switch the way you think about programming to use the object-oriented programming paradigm.





 

1 komentar:

Jasa Evan Sipayung mengatakan...

The Essence of Object Oriented
Programming with Java and UML
by
Bruce E. Wampler, Ph.D.

Posting Komentar