Warning: Parameter 1 to Language::getMagic() expected to be a reference, value given in /home/wikija5/public_html/w/includes/StubObject.php on line 58

Warning: Parameter 3 to renderSEO() expected to be a reference, value given in /home/wikija5/public_html/w/includes/parser/Parser.php on line 3243
Classes, Objects, Entities the classic approach - WikiJava
Tuesday, 2nd September 2014

    Strict Standards: Only variables should be passed by reference in /home/wikija5/public_html/w/skins/GuMax.php on line 126
  • Log in
Follow WikiJava on twitter now. @Wikijava

Classes, Objects, Entities the classic approach

From WikiJava

Jump to: navigation, search


This article explains the concepts of Class, Entity and Object using the classical approach.


Contents

the article

The most basic concept in Java is the Object Oriented paradigm (OOP). The OOP paradigm was the natural evolution of the functional paradigm.

The OOP centers the attention on the concept of object, this concept is so strictly interlinked to the concept of class that it cannot be exlained if we first don't understand what is a class.

A class is the modellization of an entity in the domain of interest of a program

To explain this in english we need to say that the OOP covers the level of abstraction of modelling the entities. This is the main difference between object oriented languages and functional languages. In the functional paradigm the language understands just operations on data, (basically what to do on which piece of information).

The big evolution of object oriented paradigm consists in the possibility to group all the data that relates to a particular entity in a single structure, which includes also the commands and operations that are intended to manipulate the data.

In OOP these structures need to be formalized in actual source code.

OOP splits further these conceptual structures in two parts:

  • The class is the formalization of the properties of the structure. It contains the model of the concept and it can be instanciated to represent any specific occurrence of the same type.
  • the object is the instance of a class. It contains the information of a specific occurrence of the class.

I will make these concept clear, with an example:

Say that we want to implement "myAddressBook", a program to manage an address book.

In our program for sure we will need to model the concept of contact. A contact is a person that we know, in the program we want to manage information about him/her. The information we will manage for each contact is the first name, the last name, the phone number and the address.

Once our program will be ready we will use it to store the real information about our friends, so we will use the model of contact to populate the first and last name, the phone number and the address.

In this example the contact to our friend is the entity that we want to model. The model of the entity is what whe call class which formalizes the information that we want to manage about the entity. When we use the program to remember information about our friends (read: manage the information about our entities) we are in facts instanciating the class and creating objects with the actual information about the entities.

To summarize:

  • the entity is what we want to model,
  • the class is the abstract model of a generic entity,
  • the object is the insance of a class and represents a specific entity.

An entity enters in the program only through objects, they can't be explicitly used in programming (you don't want to put a friend in the address book, his name and phone number should suffice, huh?).

The classes are what we can write in the source code of our program, they represent a model for the entity made in such a way that they can represent many different entities of the same kind.

The objects are instances of a class, and they contain the information about specific entities.

At this point these two statements should One class may be instanciated into many objects. Normally classes do not change between the executions while objects do.

These three concepts are the basic of the object oriented paradigm. They are very powerful.

If this article was not clear read new approach to explaining objects which will be for sure easier.,


Comments from the users

To be notified via mail on the updates of this discussion you can login and click on watch at the top of the page


Comments on wikijava are disabled now, cause excessive spam.