SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
13.
1. Make a class with methods and variables
2. Make an object (a variable) to link to that class
3. Reference the object to use the methods you
made in Step 1.
14.
1. Make a class with methods and variables
2. Make an object (a variable) to link to that class
3. Reference the object to use the methods you
made in Step 1.
15.
Among other reasons...
•It makes sense
•Code reuse
•State and behaviour
•It gives us control
•Constructors
•Encapsulation
16.
Among other reasons...
•It makes sense
•Code reuse
•State and behaviour
•It gives us control
•Constructors
•Encapsulation
26.
Among other reasons...
•It makes sense
•Code reuse
•State and behaviour
•It gives us control
•Constructors
•Encapsulation
27.
Drive Colour
Speed
Number of wheels
Number
plate
Height
Stateandbehaviour
Paint
28.
•All the information we want our program to have
about this object can be categorised as:
•“How the object is” (~Nouns / Adjectives).
•Colour, numberplate, speed and number of
wheels etc.
•“What can be done to the object” / “What the
object can do” (~Verbs).
•Drive and be painted
Stateandbehaviour
29.
•All the information we want our program to have
about this object can be categorised as:
•“How the object is”.
•Colour, numberplate, speed and number of
wheels etc.
•“What can be done to the object” / “What the
object can do”.
•Drive and be painted
STATE
BEHAVIOUR
Stateandbehaviour
30.
STATE
BEHAVIOUR
BEHAVIOUR
BEHAVIOUR
BEHAVIOUR
Stateandbehaviour
45.
• Object orientation, in its simplest form, is code within
code.
• By programming in an OO manner, we are designing code in a
way that both makes sense and gives us control.
• OOP makes sense because it allows for efficient reuse
and an accurate representation of the world using state
and behaviour.
• OOP gives us control through constructors and because it
enforces encapsulation (a black-box approach to
object design in which operations are performed through
well-defined method interfaces).
SUMMARY