Object-Oriented Programming
A bit of ad : OOP ask a effort in the beginnings ...
Java supports the Object-Oriented Programming (OOP) approach.
OOP focuses on the design of data-types (called objects or classes) rather
than algorithms
Why is this distinction important?
Objects are nouns, Algorithms are verbs
If you want to put a windows in a wall, you don't say
:
"Let's use a hammer to make a hole in that wall,
then let's measure the size of the hole, then lets buy some piece of wood that
we will put together, then ...
You say : Let's decide to have a windows in that wall
You know first what you want and then you think of the
way you will get it
Which is an easier task?
-
identify the actions that apply to a given noun
-
identify those objects to which a given action might be applied
- Example : Verb "to buy" / Object "Car"
isn't it easier to list the actions that you can do with
a car (to buy, to sell, ...to drive°) than to list all the object you can
buy ... and forget lots of them ?
What is easier?
-
identifying similar object classes
is a relationship
-
specifying general-purpose algorithms
with lots of "if then else" statements
Advantages of OOP
-
promotes design abstraction (hiding details)
-
promotes code reuse
-
consolidates specification and interface ... encapsulation