1 / 46

Object-Oriented Programming

Object-Oriented Programming. Lesson 16. Overview. OOP Classes Objects Inheritance Functions GUI. Event-driven Object-Oriented Programming Events Interactivity. Basic Concepts. Procedural Looks at the actions or the data but not both at the same time.

Download Presentation

Object-Oriented Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Object-Oriented Programming Lesson 16 COP1006

  2. Overview • OOP • Classes • Objects • Inheritance • Functions • GUI • Event-driven Object-Oriented Programming • Events • Interactivity COP1006

  3. Basic Concepts • Procedural • Looks at the actions or the data but not both at the same time. • Associated with menu-driven systems • Object-Oriented • Looks at the data parts and the actions associated with those data parts as one unit. • Associated with GUI systems COP1006

  4. Object-Oriented – A Definition • A programming methodology in which the programmer can define not only data types, but also procedures that are automatically associated with them. COP1006

  5. Classes • User-defined types created by programmers • Contains data as well as the set of methods which manipulate that data. • Data components of a class are called instance variables. • Nouns are used to create initial set of classes. • Verbs determine what methods to associate with each class. • Can only contain code--no GUI elements. • Ex. Books COP1006

  6. Objects • An individual (member) instantiation of a class • Ex. • Harry Potter and the Sorcerer’s Stoneby J. K. Rowling • Itby Stephen King • More about Classes & Objects later COP1006

  7. OO Uses • Graphical objects (drawing tools) • Mathematical objects • Vectors, matrices • Input-output devices • The procedure to draw a line is different to different outputs • Simulations • Reusable software components COP1006

  8. Software Engineering Advantage • Enables implementation decisions to be made in stages: • top level - focus on how to use a data object and on what operators (procedures and functions) are needed. • lower level - concentrate on implementation details. COP1006

  9. Software Reusability • Programmers • create new classes • reuse existing classes • Software is created by new classes with existing, well-defined, carefully tested, well-documented, widely available components. • Promotes Rapid Applications Development (RAD) COP1006

  10. Data Abstraction & Classes • Being able to describe an object’s behaviors without being concerned with the implementation details of those behaviors. • Classes can be replaced without affecting the remainder of the code. COP1006

  11. Procedural Example • Library Checkout System • We would look at: • Menu-driven program • Data input • Checking out a book • Checking in a book • Printouts of all outstanding books • Printouts of all books • Add, delete, and update book info COP1006

  12. Object-Oriented Example • Library Checkout System • We would look at: • Books • Recognize Book ID • Recognize the Book’s author • Check out • Check in • Location of book • List all books • Add, delete, and change data on a book COP1006

  13. I’m sure glad I don’t have to eat this stuff! Looks Yummy!

  14. The Restaurant Messages invoke methods & methods send messages. Customer Turnstile (object) Data: tickets: 1 Methods: isTicketReady add Ticket remove Ticket Cook (object) Data: name: Arnold specialties: HamandEggs Pancakes FrenchToast Private Methods: makeHamandEggs makePancakes makeFrenchToast Public Methods: takeTicketFromTurnstile putOrderOnCounter Waiter (object) Data: name: Joe tables: 1,2 tickets: 2 Methods: takeOrder putOrderonTurnstile pickup Order serverOrder Counter (object) Data: ordersAvailable Methods: isOrderReady addOrder removeOrder

  15. Example of Classes of Objects What characteristics should be defined at what level and what would be inherited by each object and to what level? Menu Breakfast Menu Lunch Menu Dinner Menu Adult Menu Child’s Menu St. Patrick’s Day Menu Senior Menu

  16. Some OO Terms COP1006

  17. Data Abstraction • Program design technique • focuses on • the data objects needed by a program and • the operations on those objects. • It specifies what data objects are needed for a problem without being concerned how the data objects will be represented. COP1006

  18. Inheritance • New data types can be defined based on previously defined objects • sharing code and behavior; and • involves classification of objects according to shared properties COP1006

  19. Animalia Animals Protozoa One-Celled Animals Parazoa Metazoa Mollusca Molluscs Arthropoda Joint-Footed Animals Annelida Segmented Worms Porifera Sponges Chordata Chordates Arachnida Spiders Crustacea Lobsters Insecta Insects Chilopoda Centipedes Urochordata Tunicates Vertebrata Vertebrates Cephalocordata Lancelets Isoptera Termites Hemiptera Bugs Psocoptera Booklice Ascidiacea Sea Squirts Thaliacea Salps Corixidae Water-Boatmen Tingidae Lace-Bugs Pentatomidae Stink-Bugs Reptilia Reptiles Amphibia Amphibians Agnatha Lampreys & Hagfishes Mammalia Mammals Aves Birds Testudinata Tortoises Lacertilia Lizards Serpentes Snakes Cetacea Whales Tubulidendata Aardvarks Primates Primates Chiroptera Bats Iguanidae New World Lizards Chamaeleonidae Chameleons Lemuridae Lemurs Tupaiidae Shrews Hominidae Animal Kingdom Scientific Classification (very incomplete) COP1006

  20. Object Instantiation • a variable with the same type as the data object • Class - Singly-linked List • Object – A specific Singly-linked List COP1006

  21. Information Hiding • Concealing the details of a low-level module’s implementation from a higher-level module. • Looks forward to future maintenance by building details into the design phase. COP1006

  22. Polymorphism • The use of different procedures, each with the same name, which are associated with different object types. • Allows each object to recognize the properties pertinent to itself and to ignore those that are not. COP1006

  23. Polymorphism • Example: • Procedures named draw associated with types • Point • Circle • Square • Calling draw for any particular object gets the right drawing procedure for that type. COP1006

  24. Polymorphism Example Base Class Uses the same name as the abstract data type recordset Generic recordset Derived Classes Dynaset-type recordset Snapshot-type recordset Table-type recordset COP1006

  25. Classes • A collection of like items or objects. • Examples • Books • Clients • Waiter • Cook COP1006

  26. Objects • An instance (member) of a class. • Instances of Books • Stephen King’s It • Mark Twain’s Tom Sawyer • J.K. Rowling’s Harry Potter and the Sorcerer’s Stone • Tom Clancy’s Hunt for Red October COP1006

  27. Classes of Objects • Visual Basic’s Toolbox contains controls, each a class of objects. • Once selected, each instantiation is an object of a particular class of objects. • Used in GUI’s. COP1006

  28. Graphical User Interface (GUI’s) • Computer screen designed for easy interaction between the user and the computer. • Response to the demand by users for more user-friendliness in their interactivity with computers. • Takes up a HUGE amount of space. • Languages that create GUI’s • C++ and Visual Basic COP1006

  29. Events • Each language has own set of events • Examples of events • Mousedown • Mouseup • Keydown • Keyup • Double click • Single click COP1006

  30. Event Driven Programming • Use actions or events to trigger the execution of a set of instructions • Sometimes called scripts or modules • The user dictates the order of program execution--not the programmer. • The program is instructed as to what actions to perform when events happen to those objects. COP1006

  31. Event Procedures • Events are triggered by messages • When an event occurs, a message is generated that describes what action occurred. • When the control receives the message, it generates an appropriate message response. • Event Monitoring • The state that the system is in after an event has completed execution but before a new event is detected. COP1006

  32. Interactivity • Exists when using event-driven languages • Exists between screens and/or between the user and the computer. • Produces a non-linear application. • Uses navigational tools COP1006

  33. Navigational Tools • Include • Command buttons that can • Move forward or backward • Quit the program • Menu buttons • Hot spots • Planning MUST be used to make the navigation user-friendly. COP1006

  34. OO Program Design Lesson17 COP1006

  35. Interface Design • Success is measured by the amount of planning and inclusion of the user in the development process. • Include the user to give them warm fuzzies • This leads to buy-in by the client and user. COP1006

  36. Interface Design Rules • Never lose sight of the purpose or the message. • Keep it simple! • Be consistent. • Design the navigation with the user in mind. • Understand when you can break the rules. COP1006

  37. OO Design Issues • Determine the • Requirements of the program • Input and output • Classes of data • Including properties and their attributes and the functions (operations) of each class • Interactivity • Between classes and between the functions within classes • Instructions to accomplish each function. COP1006

  38. The Well-designed Interface • Is • Pleasant to look at • Functional • Provides easy access to its functions • Provides easy to understand instructions on the functionality of the application • Allows the user to move through the program non-linearly • Provides the ability to quit the program COP1006

  39. Designing an Event-Driven Object-Oriented Application COP1006

  40. The Steps… • Define the audience & the environment. • Know your audience • Know the environment in which the program will be set COP1006

  41. The Steps… • Create the storyboards • Useful in designing the way your screen will appear to the user. • It’s easier to take an eraser to paper than redoing the screen • Even loosely defined, this is basically the same as creating a structure chart for the project • Example of storyboard http://saulcarliner.home.att.net/id/storyboard.htm#screen COP1006

  42. Storyboard Example COP1006

  43. The Steps… • Define all objects • Screens are made up of objects • Developed • Within the software application • In through an outside source • Create an object dictionary • Similar to a data dictionary COP1006

  44. The Steps… • Define the interactivity between screens. • Chart the interaction between the different screens. • Some may loop back on themselves • Some may only go forward through a process COP1006

  45. The Steps… • Define the “scripts” (or modules) • Short sets of instructions attached to objects (or to the entire application) • Includes the private functions that give the object its functionality COP1006

  46. We're done! Only the last test to take now... COP1006

More Related