2/6/2009 Object-Oriented Design CP-419 Lecture # 1 Introduction The longest journey begins with the first step! And you should have already traveled a few miles from home! (You should know something about object-oriented programming before starting this course.) 2 1 2/6/2009 Things you should already know ‣ How to program in some O-O language like Java, C#, or Ruby ‣ One can write horrible programs in an O-O language as easily as you can in a procedural language ‣ How to work as part of a team to build a non-trivial software system ‣ Tools used by poor programmers only help them write bad programs faster 3 What is OO good for??? ‣ Constructing software ‣ Reusability ‣ Reliability ‣ Robustness ‣ Extensibility ‣ Distributability ‣ Storability ‣ Maintaining software ‣ Using software ‣ GUI’s are often implemented through object orientation ‣ Managing software projects 4 2 2/6/2009 What is analysis and design ‣ Analysis emphasizes an investigation of the problem rather than how a solution is defined. ‣ Design emphasizes a logical solution, how the system fulfills the requirements ‣ Division between A & D is fuzzy ‣ A & D activities exist on a continuum ‣ Some practitioners can classify an activity as analysis, while others put it into design category. More analysis oriented More design oriented •What •Requirements •investigation of domain •understanding of problem •How •logical solution •understanding and description of solution 5 What is O-O analysis and design? ‣ The essence of O-O A&D is to consider a problem domain and logical solution from the perspective of objects (things, concepts, or entities) ‣ O-O Analysis emphasizes finding and describing the objects – or conceptsin the problem domain ‣ O-O Design emphasizes defining logical software objects (things, concepts, or entities) that have attributes and methods 6 3 2/6/2009 Object vs. function oriented analysis 7 Things to do before starting ‣ Select your language ‣ Select your development environment ‣ Plan your schedule so you have time each week for course work ‣ Purchase the book (the authors / publishers thank you) 8 4 2/6/2009 An object has… ‣ State ‣ Changes over time ‣ Behavior ‣ What the object does in response to messages ‣ Identity ‣ What makes the object unique 9 State Dave Age: 32 Height: 6’ 2” Brett Age: 35 Height: 5’ 10” Gary Age: 61 Height: 5’ 8” 10 5 2/6/2009 Behavior Get the mail. Cook dinner. 11 Identity Okay, which one of you wise guys is the real Poppini? I am the great Poppini! I’m the I am the great Poppini. De great Poppini at-a your service. No, I’m the great Poppini. great Poppini! 12 6 2/6/2009 Classes ‣ Define the properties and behavior of objects ‣ Can have behavior and properties that are defined in the class but are independent of the individual objects Inheritance Dad’s smile Dad’s sports obsession Mom’s eyes Mom’s love of ROCK 14 7 2/6/2009 Polymorphism ‣ Different type of objects can respond to the same message ‣ The actual method that executes is not determined until run time ‣ Dynamic (or late) binding 15 Encapsulation …Two… Three. And Abracadabra, the rabbit is gone! Wait. How’d he do that? Where’s the bunny gone? 16 8 2/6/2009 Acknowledgements While preparing this course I have greatly benefited from the material developed by the following people: ‣ Dr. Ying ZHOU, Univeristy of Sydney, Australia ‣ Mr. Umair Javed, LUMS, Pakistan ‣ Gary Pollice, David West and Brett D. Laughlin 17 9