The class was a more general introduction to Object Oriented Programming rather than being specific to Java programming language.
Object Oriented Programming (OOP)
- OOP is one of many techniques used for modeling/programming complex systems by describing a collection of interacting objects via their data and behaviors.
- An object oriented program is based on classes and usually has a collection of interacting objects, as opposed to the conventional/top down model, in which a program consists of functions and routines. In OOP, each object can receive messages, process data, and send messages to other objects.
- An object is a particular component of the program that can perform certain behaviors and can interact with other elements of the program.
- Thus, an object is simply a collection of data with its associated behaviors.
- Behaviors are actions that can occur on an object or that can be performed on an object.
- The behaviors/actions that can be performed on a specific class of objects are called methods.
- At the programming level, methods are like functions in structured programming
- Methods magically have access to all the data associated with that specific object.
- Like functions, methods can also accept parameters, and return values.
- Parameters to a method are a list of objects that need to be passed into the method that is being called/invoked.
- Invoking/calling a method, at the programming level, is the process of telling the method to execute itself by passing into it the required parameters as arguments.
- Classes describe objects. They are like blueprints for creating objects.
- A class defines a data type, which contains variables, attributes and methods.
- Data typically represents/describes the individual characteristics of a certain object.
- Attributes are simply referred to as properties.
- The set of values of the attributes/properties of a particular object is called its state.
- There can be instances and objects of classes.
- An instance is an object of a class created at run-time.
- Thus, objects are instances of classes and they can be associated with each other.
- An object instance is a specific object with its own set of data and behaviors.
- Each orange could have a different weight, the Orange class could then have a weight attribute/property.
- All instances (see what is an instance above) of the orange class have a weight attribute, but each orange might have a different weight value.
- So, attributes don't have to be unique; any two oranges may weigh the same.
- Which means some of these attributes/properties may also belong to multiple classes.
Before you perform object oriented programming there are a number of steps to go through, especially, if the program is complex:
Object-oriented Analysis (OOA)
OOA is the process of looking at a problem, system, or task that somebody wants to turn into an application and identifying the objects and interactions between those objects.
Object-oriented Design (OOD)
OOD is the process of converting such requirements as analysed above into an implementation specification.
-The designer must name the objects, define the behaviors, and formally specify which specific behaviors/actions objects can activate on other objects.
- OOA and OOD is all about figuring out what those objects are and how they should interact.
Object-oriented Programming (OOP)
OOP is the process of converting the perfectly defined design (OOD) into a working program that does exactly as was requested.
Summing up:
- Adding models (mechanisms) and methods to individual objects allows us to create a system of interacting objects.
- Each object in the system is a member of a certain class (eg., oranges belonging to one more classes).
- These classes specify what types of data the object can hold and what methods can be invoked/called on it.
- The data in each object can be in a different state from other objects of the same class, and each object may react to method calls differently because of the differences in state.