DOC PREVIEW
IUPUI CS 265 - Fundamentals of OO

This preview shows page 1-2-19-20 out of 20 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Fundamentals of OOExample: ClassroomAbstraction and ClassesObjects, Instances of a ClassEncapsulation and ObjectsMessaging Supports EncapsulationPolymorphism Supports EncapsulationHierarchiesInheritance HierarchyAggregation HierarchySummary of Object-Oriented ConceptsComparison of Functional vs. OO ViewsAddition of a New Student TypeAddition of New Report TypeRe-organization of OO AbstractionsExercise: Identifying OO PropertiesAssignment: Identifying OO PropertiesSample Package ViewSample Class ViewAcknowledgementsFundamentals of OOCSCI 265 Dale RobertsExample: Classroom•Attending the lecture we have several individuals–Wade - loves Chinese food–George - an outdoorsman–Wendle - is a sports nut–Lee - doesn't eat anything with a vowel in its name•These are the students of our lectureNote that the individuals are not identical.Wade George Wendle LeeCSCI 265 Dale RobertsAbstraction and Classes•From our perspective, we see them as an instantiation of a "Class", Student–has a name–attends class–has a grade–completes assignmentsNote the each student looks the sameeven though the are different individuals•A Class defines an "Abstraction"•OO Abstractions are based on–data (name, attendance)•"Attributes"•simple access–behavior (completes assignments, attends class)•"Operations/Methods"•complex properties–relationships (student in course)•external implementationsStudent- Name- Grade- Attendance Record- CompleteAssignment()- Attend Class()CSCI 265 Dale RobertsObjects, Instances of a Class•Classes define what properties will exist in each instance•Objects provide distinct instances that exhibit those propertiesStudent- Name- Grade- Attendance Record- CompleteAssignment()- Attend Class()George : Student· Name=“George”· Attendence=100%· CurrentGrade=ALee : Student· Name=“Lee”· Attendence=85%· CurrentGrade=BClassObjectsNotice that the data members are replicated in each object. Each object is an instance of Student. It does not make sense to replicate member functions.CSCI 265 Dale RobertsEncapsulation and Objects•Classes form the interface for interaction, Objects provide the implementation–they are instances of a class (student)–they have unique behavior–they have state WadeGetName(){ look atnotebook }GeorgeGet Name() { look atlicense plate } WendleGet Name() { look atback of hand } LeeGet Name() { look incompany directory }Student· GetName() Class ObjectsCSCI 265 Dale RobertsMessaging Supports Encapsulation•We interact with objects through "messages"•Messages allow object to determine implementation rather than the sender determining the implementation for each instance.Functionally-Oriented InstructorTake Attendence() {Look at back of each student’s hand!!! }Object-Oriented InstructorTake Attendence() {Ask each student for their name. }You're just data to me. Hand it over so I can do my job.You're an object. You implement something I need. I'll ask you for it.Messages are passed and handled, rather than invoked like functions.CSCI 265 Dale RobertsPolymorphism Supports Encapsulation•Allows an object of any implementation type, which satisfies the interface defined by the abstraction, to be used by a generic reference to an abstraction.•Promotes a separation of interface and implementation Student-Name-Grade-Attendance Record-CompleteAssignment()-Attend Class()=Wade-Name=“Wayne”-Current Grade = “B”-Attendence = 90%George-Name = “Gary”-Current Grade = “B+”-Attendence = 95%class GraduateStudent : Student ;float calculateScore(Student s);GraduateStudent George;calculateScore(George)Wade is an undergraduateStudentGeorge is an graduateStudentPolymorphism says that you can treat both Wade and George as Students if the distinction between undergraduate and graduate is not important.CSCI 265 Dale RobertsHierarchies•Organize lower level abstractions into more complex abstractions•Hierarchies allow more complex abstractions to be understood•Two basic forms–Inheritance•Generalization - Specialization•Base Class - Derived Class•Parent - Child•Abstract Class - Concrete Class–Aggregation (many-to-one relationships)•Whole - Part•Containership•Collection•GroupCSCI 265 Dale RobertsInheritance Hierarchy•an "is-A" relationship•Inheritance –for type - a re-use of common interface–for class - a re-use of common interface and implementationPerson· NameStudent· Name· Attendence· CurrentGradeCSCI 265 Dale RobertsAggregation Hierarchy•a "has-A" relationship•assembly-part - where the aggregation of parts makes up the whole–ex: airplane is an aggregation of wings, wheels, motor, prop, etc.•container-contents - where the container exists with or without contents–ex: classroom is an aggregation of students, instructor, tables, chairs, etc.•group-member - where members are logically associated with whole–ex: course has students and teachers as members•"weak has-A" - where there is more of a peer-to-peer relationship between abstractions (association)–ex: Instructor has students, Students have instructorCommunitySchoolsBusinessesResidentsSchoolFacultyStudentsAdministratorsClassroomsClassroomTablesChairsStudentsInstructorCSCI 265 Dale RobertsSummary of Object-Oriented Concepts•Abstraction–Class–Attribute–Behavior–Relations–Encapsulation•Object–Message–Polymorphism•Hierarchies–Inheritance–Aggregation“Is-A” relationships are implemented through inheritance.“Has-A” relationships are implemented through data members.Data structures are used to implement the various “Has-A” relationships. For example, multiple children are maintained through container data structures such as arrays and linked lists.CSCI 265 Dale RobertsComparison of Functional vs. OO ViewsRegisterStudentPrint TranscriptSubmitGradeStudentsStudents GradesStudent/GradesStudentRegister( )Submit Score( )Print Transcript( )0..*ScoreNameValue0..*CSCI 265 Dale RobertsAddition of a New Student Type•Changes in data types cause significant impact to functional approaches•OO approaches allow new object types to re-define functionalityRegisterStudentPrint TranscriptSubmitGradeStudentsStudents/Pass Fail StudentsGrades/PFStudent/Grades/PFImpactAreasStudentRegister( )Submit Score( )Print Transcript( )0..*ScoreNameValue0..*PassFail StudentPrint Transcript( )function overrideCSCI 265 Dale RobertsPassFail StudentPrint Transcript( )Print


View Full Document

IUPUI CS 265 - Fundamentals of OO

Download Fundamentals of OO
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Fundamentals of OO and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Fundamentals of OO 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?