The Java language uses an object-oriented programming where processing consists of exchanging messages between objects, which are the information pulled out of Reality (object abstraction). Objects are formed by attributes that define their characteristics and in the practice of programming are identified by the variables that the object uses to store data. An object to access its memory (attributes) and then accordingly to perform operations and change its state does so through methods. The ownership of objects to incorporate both attributes and methods into them is called encapsulation, in fact it is created as a capsule, a conceptual barrier that isolates the object from the external environment (information masking). Very often the object was built by a programmer other than the one who will use it. The latter is interested to know how to interact with the object, what are the methods that makes available and how to call them. The programmer is like the mechanic who knows the details of the operation of the car while the pilot can ignore these details. This way of understanding objects induces to consider an object as a black box. Details on the structure characteristics of the object are hidden inside by guaranteeing the Information Hiding.
Interaction between Objects
In Object Oriented Programming, the interaction between objects takes place as a mechanism called Message Exchange. An object, by sending a message to another object, can ask for a method to be executed. A message consists of three parts:
- Argument list
The recipient is the object to which the message is addressed.
The selector indicates the method you want to activate: it must be one of the methods made available to the recipient object.
The argument list is the set of parameters that are passed to the object when you ask to activate the method.
In a language of Pseudocodifica we can write: Recipient. Selector (list of topics).
Access to attributes
Summing up what has been said, the objects have encapsulated methods and attributes within them. Messages are the interface to objects that hides and does not allow you to see how the (Encapsulation/masking) methods are implemented. The interface allows however the use of the methods in this sense also the attributes are hidden in the object. To be able to read or change the value of an attribute, you might use a method that performs the requested operation.
The term indicates the possibility of a project to take on multiple forms, as for methods that can undergo different implementations within the class hierarchy.
The automobile and motorcycle subclasses inherit the Accelera method from the means of transport. This is guaranteed by polyformism through dynamic linkage. You define dynamic because the association between the considered object and the correct method to execute is performed during run time. Programs can have dynamic and static linking. Static when it is the compiler that is concerned with creating associations between elements (through for example variables: During compilation is linked their type). Once this link is created, it can no longer be changed (the static link is possible if you know all the information at the time of compilation). In the dynamic link is not possible during the compilation know all that information necessary to the link that can be perfected only during the Run time.
Object-Programming changes the way you understand a program because during execution it corresponds to a set of class instances (objects) that evolve, interact, create new instances, and magazines. By following this definition, objects are entities that exist during the execution of a program. When the program also ends the objects no longer exist. It is said that an object is persistent if it survives the single execution, in order to be used in another session and this is accomplished by recording the object in the mass memory.