lecture8 - OOP and recursion

lecture8 - OOP and recursion - Wednesday, January 28 th How...

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

View Full Document Right Arrow Icon
Wednesday, January 28 th   How to  design  an Object  Oriented program Recursion One day A mad poet with little to say Gave a poem away That started: One day A mad poet with little to say Gave a poem away That started:                One day                A mad poet with little to say                Gave a poem away                That started:               One day          … etc -Martin Gardner (famous mathematician)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Object-Oriented Design So, how does a computer scientist go about  designing a program? Mad EE scientist How do you figure out all of the  classes methods algorithms , etc. that you need for a  program? (Well, it’s not easy!  Many senior engineers ar horrible  at it!) At a high level, its best to tackle a design in two phases: First , determine the classes you need,  what data they hold, and how they  interact with one another. Second , determine each class’s  data structures and algorithms.
Background image of page 2
Class Design Steps 2. Determine the  outward-facing  functionality  of each class.  How do you  interact with a class? 1. Determine the  classes  and  objects  required to  solve your problem. 3. Determine the  data  each of your classes holds  and… 4. How they  interact  with each other.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
An Example Often, we start with a  textual  specification  of the problem. For instance, let’s consider a spec for an  electronic calendar . Each user’s calendar should contain appointments for that user.                     There are two different types of appointments, one-time appts  and recurring appts.                                        The user of the calendar  must supply a password before accessing the calendar.  Users of the calendar can get a list of appointments for the day, add new  appointments, remove existing appointments, and check other users’  calendars to see if a time-slot is empty.    Each appointment has a start-time and an end-time, a list of  participants, and a location.
Background image of page 4
Step #1: Identify Objects Start by identifying  potential  classes The easiest way to do this is identify all  of the  nouns  in the specification!  Each user’s calendar should contain appointments for that user.                     There are two different types of appointments, one-time appts  and recurring appts.                                        The user of the calendar  must supply a password before accessing the calendar.  Users of the calendar can get a list of appointments for the day, add new 
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 57

lecture8 - OOP and recursion - Wednesday, January 28 th How...

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

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