DOC PREVIEW
UMD CMSC 132 - Object-Oriented Design & Programming

This preview shows page 1-2-24-25 out of 25 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 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 25 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 25 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 25 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Object-Oriented Design & ProgrammingOverviewGoalsTechniques – AbstractionTypes of AbstractionAbstraction ExampleTechniques – EncapsulationEncapsulationBenefits of EncapsulationObject-Oriented DesignObject-Oriented ViewHistory of Object-Oriented DesignOO Programming LanguagesFactors in Success of OO DesignElements of Object-Oriented DesignObjectsObject ExampleSlide 18Object StateMethodsMethod TypesIdentityReference VariablesSlide 24EquivalenceObject-Oriented Design & ProgrammingNelson Padua-PerezChau-Wen TsengDepartment of Computer ScienceUniversity of Maryland, College ParkOverviewObject-oriented design GoalsTechniquesObject-oriented viewExamplesGoalsImprove software designReduce implementation effortScalable to large software projectsTry to take advantage of two techniquesAbstractionEncapsulationTechniques – AbstractionAbstractionProvide simple high-level model ofPhysical entityActivityHelpful for managing complexityEnables information hidingCan change implementation & representationWill not affect other software componentsTypes of AbstractionProcedural abstractionSpecify what actions should be performedHide algorithmsData abstractionSpecify data objects for problemHide representationAbstraction ExampleAbstraction of a Student RosterDataList of student namesActionsCreate rosterAdd studentRemove studentPrint rosterSTUDENT ROSTERList of namesCreate()AddStudent()RemoveStudent()Print()Techniques – EncapsulationEncapsulationConfine information so it is only visible / accessible through an associated external interfaceApproachFor some entity X in programAbstract data in XAbstract actions on data in XCollect data & actions on X in same locationProtects and hides XEncapsulationExtension of abstractionAlways abstract data & function togetherEncapsulated entity  Abstract Data Type (ADT)ExamplesList ADTMay be implemented as array, linked list, etc…Java collections libraryBenefits of EncapsulationEasier to make code modificationsDue to information hidingPromotes code reuseInterface to data structure clearly definedEasier to reuse codeCode reuse increases productivityObject-Oriented DesignView software asA collection of entities (objects)Functions associated with each objectCommunication between objectsExploits abstraction & encapsulationCan rely on programming language supportObject-Oriented ViewExample problem descriptionThermostat uses dial setting to control a heater to maintain constant temperature in room RoomThermostat(dial)HeatergetTemperature()heaterOn()History of Object-Oriented DesignPreceded by procedure-oriented viewEarliest approach to programming Uses procedure abstractionSimilar to actual machine instructionsFocus on control flow, program scopeExamples: Fortran, Cobol, Pascal, BasicExampleThermostat()1. Get room temperature2. If (temperature < setting) turn heater on3. Else turn heater off4. Goto step 1OO Programming LanguagesDevelopment historySimula (Dahl & Nygaard, 1962)Modeling discrete event simulationSmalltalk (Kay, 1972)General programmingC++ (Stroustrup, 1979)Manage complexity in huge software projectsJava (Gosling, 1991)Designed for embedded processorsFactors in Success of OO DesignGrowing demandMore experience with large software projectsImprovements in language designMade OO programming easierImprovements compiler technologySupport more language features efficientlyImprovements in hardwareHandled inefficiencies in OO programmingMade performance less criticalElements of Object-Oriented DesignObjectsEntities in programMethodsFunctions associated with objectsClassesGroups of objects with similar propertiesInheritanceRelationship between classesObjectsDefinitionEntity that has state, behavior, and identityState (data)Properties possessed by objectCurrent values of those propertiesBehavior (methods)How objects react to changes in stateHow objects interact with each otherIdentity (references)Mechanism to distinguish between objectsObject ExampleThermostatStateDesiredTempCurrentTempHeaterStateBehaviorSetDesiredTemp()TurnHeaterOn()TurnHeaterOff()IdentitythisObject ExampleThermostatState Property ValueDesiredTemp integer 78oCurrentTemp integer 72oHeaterState boolean ONObject StatePropertiesStatic, unchangingMay view as typesValuesDynamic, changesWithin bounds set by propertiesMethodsDefinitionProcedures associated with objectSpecify behavior of objectsInvocation  sending message to objectExamplemyThermostat.setDesiredTemp(78)myThermostat.turnHeaterOn()myThermostat.turnHeaterOff()Method TypesAccessorReturn state informationMutatorModify state informationConstructorCreate & initialize new objectDestructorRemove object & free up resourcesIdentity How to distinguish between objectsReference variablesUsed in object-oriented programming languagesPoints to objectsMultiple variables may point to same objectReference Variables ExampleIdentity EquivalenceWhether two objects are equalName equivalenceReference variables point to same objectContent equivalenceObjects from same classState in each object are identicalEquivalence ExampleName Equivalent Content


View Full Document

UMD CMSC 132 - Object-Oriented Design & Programming

Documents in this Course
Notes

Notes

8 pages

Recursion

Recursion

12 pages

Sorting

Sorting

31 pages

HTML

HTML

7 pages

Trees

Trees

19 pages

HTML

HTML

18 pages

Trees

Trees

19 pages

Honors

Honors

19 pages

Lecture 1

Lecture 1

11 pages

Quiz #3

Quiz #3

2 pages

Hashing

Hashing

21 pages

Load more
Download Object-Oriented Design & Programming
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 Object-Oriented Design & Programming 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 Object-Oriented Design & Programming 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?