Lec6 OO Basics - Todays Announcements EE422C Data...

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

View Full Document Right Arrow Icon
1 EE422C Data Structures Sarfraz Khurshid Lecture 6 Sep 14, 2010 Today’s Announcements Assignment 1 • designs due: today , start of class • code due: sunday 9/19, 11:59pm Today • OO basics EE322C 2 Next time • OO inheritance Exam 1 on Sep 30, 12:30PM, in class OO BASICS EE322C 3 Classes You Have Seen So Far Programs are constructed from many classes, e.g., • java.lang.Object • java.lang.System • java.lang.String • java.util.Scanner EE322C 4 • BankAccount class (today) A Class is a programmer defined type that provides encapsulation of data and operations. This allows access to data and operations on it to be isolated through a defined interface. Objects And Classes - in Two Worlds A class is an abstract grouping (or categorization) of related objects, containing members that have something in common (e.g., at least one attribute); it defines a general kind of or type of object (e g all Real World EE322C 5 kind of or type of object (e.g. all cars, all students in EE322C) An object is a specific, identifiable thing; is a member of 1 or more classes, has attributes, exhibits behavior (e.g. my Toyota, you) Objects And Classes - in Two Worlds A class is an abstract grouping (or categorization) of related objects, containing members that have something in common (e.g., at least one attribute); it defines a general kind of or type of object (e g all cars all Java OO World Real World A class consists of methods, variables, etc.; and is a generalization of and a generator for all objects of that class EE322C 6 of object (e.g. all cars, all students in EE322C) An object is a specific, identifiable thing; is a member of 1 or more classes, has attributes, exhibits behavior (e.g. my Toyota, you) An object is a member (or instance) of a class, it is a data structure that supports desired methods, and is a thing you can create and manipulate in your program. It has a state, and behavior. For some programming problems it is easy to map between these two worlds - that is what OOP tries to do
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 OO Nomenclature class bj classname operations/methods UML style attributes class ER style EE322C 7 object relationship/ association A Class Hierarchy animals vertebrate invertebrate Classification scheme with: Superclasses, subclasses, inheritance EE322C 8 fish amphibian mammal reptile horse dog cat rabbit Missouri cottontail “Fluffy” My pet rabbit What is a Class ? It is how we implement an ADT in Java (or C++, etc.) An Abstract Data Type (ADT) is a model used to describe at a high level the design of a new data type to be implemented. • ADTs specify the type of data objects to be stored and the operations that can be performed on them. • Viewing a data structure as an ADT allows a programmer to focus on an idealized model of the data and its operations. EE322C 9 • Is kind of like a struct with bundled operations, plus more • Encapsulation is the mechanism that binds together the code and data it manipulates into a logical black box that is safe from outside interference and misuse Purposes of Classes Classes serve the following purposes:
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

Lec6 OO Basics - Todays Announcements EE422C Data...

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

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