Lecture03 - CS162: Introduction to Computer Science II...

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

View Full Document Right Arrow Icon
1 CS162: Introduction to Computer Science II Classes
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Objects Object: An entity you can manipulate in a program An object is a specific instance of a class Class: defines the methods that you can apply to its objects and has a private implementation
Background image of page 2
3 Key OOP Concepts 1. Encapsulation 2. Abstraction 3. Reusability 4. Inheritance 5. Polymorphism For a future lecture
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Encapsulation Encapsulation: hiding of unimportant details ( information hiding ) controlling access to information in a class through public functions Treat the contents of a class like a black box (ie. inner workings are hidden) Class
Background image of page 4
5 Encapsulation Why black boxes?
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 Abstraction Abstraction: Taking away inessential features until only the essense of the concept remains Figuring out what details you want to ignore (ie. figure out the level of encapsulation)
Background image of page 6
7 Abstraction Example Example using computers: 1. Typical user: Level of abstraction: the computer, monitor, peripherals 2. Tech support: Level of abstraction: computer parts eg. motherboard, RAM, video card 3. Electrical engineer: Level of abstraction: chips, transitors, capacitors
Background image of page 7

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

View Full DocumentRight Arrow Icon
8 Object template: the class Instance data fields describe the essential properties objects of the class type. Methods describe the actions that objects of the class type can perform.
Background image of page 8
9 Naming conventions Use self-documenting names Start class name with uppercase Use noun or descriptive phrase Start data field name with lower-case letter Use noun or descriptive phrase Start method name with lowercase letter Use verb or action phrase
Background image of page 9

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

View Full DocumentRight Arrow Icon
Private data fields Accessed only by methods defined in the class Enforces information hiding Also called: instance data, instance variables, attributes public class BankAccount { . . . private double balance
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/28/2009 for the course CS 161 taught by Professor Wallace during the Spring '08 term at Oregon State.

Page1 / 33

Lecture03 - CS162: Introduction to Computer Science II...

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