|
Introduction |
The main principles in OO are :
(1) Abstraction
(2) Encapsulation:the process of hiding data representation and implementation details in each abstraction from others.
Benefits:
(a) Ensures that each abstraction is independent.
(b) Eases the impact of future changes to the system.
(c) Prevent information misuse.
(3) Modularity
(4) Hierarchy
Programming languages support a set of predefined data types that permit certain operations to be performed on their instances .
A variable of type int in C++ can only hold an integer value not a character , and operations such as addition , subtraction , multiplication and division are permitted on integers.
A variables of type char in Pascal can only character , and operations such as add ,multiply , divide and subtract are not allowed on variables of this type .
When solving computerized problems we are often faced with the restrictions and difficulties of the predefined datatype that affect our our solution .
Example : problem that involves date calculation
Defining the dates as long integer could impose difficulties , such as adding two dates or finding the difference between them would be not correct . The difference between 20020202 and 20030202 is 10000 and not 365 ( one year) .
Such difficulties and many others can be overcome with the definition of suitable datatypes along with the operations to manipulate them .
When analyzing a problem to be computerized , the type of data and operations are necessary to determined , and by combining the data and operations one or more abstract data types (ADT) are defined for the problem .
ADT can be viewed as black box that can be accessed through its available operations .
The logical decomposition of a problem can be successfully made by deciding the right set of ADTs that are implemented independently.