Unformatted text preview:

Object-Oriented Programming and DesignGoals: to learnHistory of ObjectsDesign PrinciplesSmalltalkFrom SmalltalkBefore objectsObject ParadigmWhat is an object, anyway?Slide 10Slide 11Heart of Object-Oriented ProgrammingModelingAssumption about ModelingSlide 15Slide 16Objects and RelationshipsObjects and AttributesObjects and BehaviorWhat Really is an Object?Slide 21ClassificationSlide 23SummarySlide 25The classSmalltalk in a NutshellSmalltalk: Everything is an ObjectCommunicating with an ObjectThree Kinds of Message SyntaxSending a MessageSmalltalk in a nutshellMessage Lookup and InheritancePowerPoint PresentationSmalltalk Expression SyntaxSlide 36Smalltalk Method SyntaxVariables in SmalltalkUsing VariablesMore variables(continued)Initializing an ObjectClass MethodsInstance initializing methodCreating a DateComplete SmalltalkSmalltalk (the language) is trivialImplicationsApplicationsObject-oriented programming and design1Object-Oriented Programming and DesignRalph Johnson [email protected] programming and design2 Goals: to learnPrinciplesPatternsPractices“Object think” Design for reuseObject-oriented programming and design3History of ObjectsSimula’67Smalltalk 72,74,76,78,801985 C++ (Objective C, Object Pascal)1986 OOPSLA1990 COM, CORBA1994 Design Patterns1995 Java2001 .NETObject-oriented programming and design4Design PrinciplesEncapsulate what variesCode to an interace rather than to an implementationOpen-closed Principle: Classes should be open to extension and closed to modificationDon’t Repeat Yourself (DRY)Single Responsibility PrincipleLiskov Substitution Principle: Subtypes must be substitutable for their base typesObject-oriented programming and design5SmalltalkExtreme object-oriented languageLive objectsReadable libraryInfluencial, unknownFun!Object-oriented programming and design6From SmalltalkWIMP - Windows, Mice, PointingModel/View/ControllerBrowsersCRC cardseXtreme ProgrammingAutomated refactoring toolsObject-oriented programming and design7Before objectsComputer system consists of data and programs.Programs manipulate data.Programs organized byfunctional decompositiondataflow modulesObject-oriented programming and design8Object ParadigmComputer system consists of a set of objects.Objects are responsible for knowing and doing certain things.Objects collaborate to carry out their responsibilities.Programs organized by classes, inheritance hierarchies and subsystemsObject-oriented programming and design9What is an object, anyway?Mystical viewComputing systems are made up of objects that communicate only by sending messages between each other. All computation is message sending.Object-oriented programming and design10What is an object, anyway?Scandinavian viewA program is a simulation. Each entity in the system being simulated is represented by an entity in the program.Object-oriented programming and design11What is an object, anyway?Programming language viewAn object-oriented system is characterized by• data abstraction• inheritance• polymorphism by late-binding of procedure callsObject-oriented programming and design12Heart of Object-Oriented ProgrammingDon't make a new language, extend your old one.Objects should be abstractions of problem domain.Object-oriented programming and design13ModelingAll phases of software life-cycle are modeling• analysis - modeling of problem• design - modeling of solution• implementation - making model run on a computer• maintenance - fixing/extending your modelObject-oriented programming and design14Assumption about ModelingBasing system design on structure of problem makes system• more reusable• more extensibleObject-oriented programming and design15ModelingClaim: people model the world with "objects"• objects• classes• relationships between objects• relationships between classesObject-oriented programming and design16ModelingAdvantages of object-oriented software development• more natural - matches the way people think• single notation - makes it easy to move between software phasesObject-oriented programming and design17Objects and RelationshipsJohn is Mary's father. Mary is John's daughter.Bob is Mary's dog. Mary is Bob's owner.Ann is John's employer. John is Ann's employee.Object-oriented programming and design18Objects and AttributesJohn's name is "John Patrick O'Brian".John's age is 27.John's address is 987 N. Oak St, Champaign IL 61820What about John's job? John's wife?What is an attribute, and what is a relationship?Object-oriented programming and design19Objects and BehaviorJohn goes on a trip.John makes reservations.John buys tickets.John travels by airplane.John checks into hotel.Object-oriented programming and design20What Really is an Object?Reservation -- a promise to give service to a customerTicket -- proof that customer has paid for service in advanceFlight Payment -- an event (transaction?) in which money is exchangedObject-oriented programming and design21What Really is an Object?Anything we can talk about can be an object, including relationships ("the husband of the first party", "first-born son").What are we trying to model?Models should be as simple as possible, but no simpler.Object-oriented programming and design22ClassificationWe naturally put objects into classes that have similar characteristics.• John is a man.• Mary is a woman.• Bob is a dog.• All women are people.• All people are mammals.MammalsDogsPeopleMenBobJohnWomenMaryObject-oriented programming and design23Classification• John is an employee.• John is a father.• John is a sky-diver.• John is under 30.Is John an instance of Employee, Father, Sky-diver, and Under30?Object-oriented programming and design24SummaryObjects• have identity• have attributes• have behavior• have relationships with other objectsObject-oriented programming and design25SummaryClasses• describes the attributes, behavior, and relationships of a set of objects• subclasses/superclasses form graph of generalizationsObject-oriented programming and design26The classFirst month is SmalltalkHomework, often several per weekSecond half of the semester is group projectSee http://swiki.cs.uiuc.edu/cs598rej/MP0Make a page for yourselfDownload Squeak and play with itObject-oriented programming and design27Smalltalk in a NutshellObjects & classesMessages & methodsInheritance &


View Full Document

UIUC CS 598 - Programming and Design

Download Programming and Design
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 Programming and Design 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 Programming and Design 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?