Tuesday, April 07, 2009

Object Parallels

What is an Object is part of Sun's The Java Tutorials. This particular tutorial begins by noting parallels between programming objects and objects from the physical world. Two characteristics of objects from the "real world" are noted- their state and their behavior. As is the case in object-oriented programming, objects can contain other objects.

Consider an object called the New York Yankees. The state of this object would include 25 active roster players, an Eastern Division grouping, a Yankee Stadium home field and more. Behavior could include statistical performances of players, standings within the division and dates of home field games. The behaviors would vary during a season and from season to season. Standings in April could differ from June and batting averages vary from day to day. Rainouts could alter scheduling during the season and schedules would vary from year to year.

Associated with states and behavior of programming objects are variables or fields for the former and methods or functions for the latter. States of an object are stored in variables or fields and methods or functions reveal behavior.

It is noted in the tutorial that object oriented programming features data encapsulation as a fundamental principle. Data encapsulation enables a hidden internal state requiring interaction performed through an object's methods or functions.

Labels:

0 Comments:

Post a Comment

<< Home