#2 Object Oriented Programming

#2 Object Oriented - Object Oriented Programming What is Object-Oriented Programming(OOP What is an Object An object is anything that has

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
Object Oriented Programming
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
What is Object-Oriented Programming (OOP)? What is an “Object”? An “object” is anything that has attributes (length, width, etc) and operations associated (Speak, Sit, Stand) with it What then is a “class”? A class is the “blueprint” for an object, the conceptual representation of the object, while the object is the “manifestation” of the class at runtime OOP is a programming paradigm that focuses on utilizing “objects”
Background image of page 2
Classes mirrors real world objects A class is a blueprint for all things of that type Classes have three main types of members Methods (functions in other languages) Fields (the data, sometimes called member variables) Properties (accessed like fields, but actually methods)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Why use OOP? OOP is utilized to combat mainly: Spaghetti code Related code bits not grouped (or functioning) as a unit Nightmarish code maintenance OOP promotes: Logical code grouping Slick programming design Straightforward maintenance and extensibility
Background image of page 4
OOP’s chief ingredients/ A guide to proper class design Encapsulation Inheritance Abstraction Polymorphism
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
What is Encapsulation? Encapsulation is a technique of linking together variables & procedures to form an object The only way to access variables & procedures of an object is to create an instance of it.
Background image of page 6
Why use Encapsulation Encapsulation is the “hiding” of an object’s attributes from outside forces This way, unintended modification of said attributes are curtailed. Encapsulation enables programmer to institute checks and balances by placing variables & procedures in a class and defining rules in the class to control its access.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Protection using Access Specifiers Public One can access directly the variables & procedures defined using the keyword public within the program by using the name of the instance, the dot operator, and the name of the attribute or procedure / method being accessed.
Background image of page 8
Protection using Access Specifiers Private The private access specifier restricts access to variables and procedures that are members of the same class.
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Protection using Access Specifiers Protected The protected access specifier identifies the
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/14/2011 for the course COMPUTER 091 taught by Professor Rajivsir during the Summer '11 term at MIT.

Page1 / 34

#2 Object Oriented - Object Oriented Programming What is Object-Oriented Programming(OOP What is an Object An object is anything that has

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online