|
|
(114 intermediate revisions by 12 users not shown) |
Line 1: |
Line 1: |
| == '''Object Oriented Design''' ==
| | <big>'''Wiki Text book !'''</big> |
| | | * [[CSC 216]] learning exercise |
| | | * [[Expertiza documentation]] |
| ''Object-oriented design is a programming paradigm that uses "objects" and their interactions to design computer programs. It is based on several techniques, including encapsulation, modularity, polymorphism, and inheritance.''
| | * [[CSC 379]] |
| | | * [[CSC/ECE 506 Fall 2007]] |
| | | * [[CSC/ECE 517 Fall 2007]] |
| | | * [[CSC/ECE 517 Summer 2008]] |
| == The Software Life Cycle ==
| | * [[CSC/ECE 517 Fall 2010]] |
| <br>
| | * [[ECE 633]] |
| ''The development of software is usually broken down into five parts: Analysis, Design, Implementation, Testing, and Deployment.''
| | * [[KCU]] |
| | | * [[Progress reports]] |
| <br>
| |
| | |
| ::'''Analysis'''- decision-making process in which a decision is made on what the project is suppose to accomplish.
| |
| | |
| <br>
| |
| | |
| ::'''Design'''- the plan is developed for how the system will be implemented.
| |
| | |
| <br>
| |
| | |
| ::'''Implementation'''- the program is written and compiled to implement the classes and methods that were decided on in the design.
| |
| | |
| <br>
| |
| | |
| ::'''Testing'''- tests are run to verify that the program works correctly.
| |
| | |
| <br> | |
| | |
| ::'''Deployment'''- users install program and use it for its intended purpose
| |
| | |
| <br>
| |
| | |
| | |
| == Classes ==
| |
| | |
| | |
| While programming in an object-oriented way, you must:
| |
| <br>
| |
| <br>
| |
| :*''Discover classes''
| |
| | |
| :*''Determine the responsibilities of each class''
| |
| | |
| :*''Describe the relationships between the classes''
| |
| | |
| <br>
| |
| | |
| <blockquote>
| |
| A class represents a set of objects with the same behaviors. Some entities should be represented as objects, <br/>
| |
| and others as primitive types. An example would be of the decision for an address to be a object of an address <br/>
| |
| class, or simply a string. This decision depends on what your program needs to complete its tasks. Not all <br/>
| |
| classes can be discovered in the analysis phase, and some of the classes that you need may already exist, <br/>
| |
| either in the standard library or in a program that you devloped previously.</blockquote>
| |
| <br>
| |
| <br>
| |
| | |
| == Relationships Between Classes ==
| |
| | |
| === Inheritance ===
| |
| <br>
| |
| | |
| | |
| ::*Inheritance is a relationship between a more general class (the superclass) and a more specialized class (the subclass)
| |
| | |
| ::*This relationship is often described as the "is-a" relationship
| |
| | |
| ::*Examples include:
| |
| | |
| ::::Every truck is a vehicle
| |
| ::::Every savings account is a bank account
| |
| ::::Every circle is an ellipse
| |
| | |
| <br>
| |
| | |
| :::[[Image:ferrari.jpg]]
| |
| | |
| <br>
| |
| | |
| === Aggregation vs. Association ===
| |
| <br>
| |
| | |
| :*An '''aggregation''' is a set of objects that make up a unit, also known as a "has-a" relationship. Some examples of aggregation include:
| |
| | |
| <br>
| |
| :::[[Image:Aggregation1.jpg]]
| |
| <br>
| |
| :*An '''association''' is two or more objects that work together, but one is not part of another. Some examples of association include:
| |
| | |
| <br>
| |
| | |
| :::[[Image:bank.jpg]]
| |
| | |
| | |
| <br>
| |
| | |
| == Learning Exercise ==
| |
| | |
| <br>
| |
| | |
| | |
| | |
| The idea behind this Restaurant O-O Design Game is to
| |
| | |
| :* Decide which elements are classes - Nouns
| |
| :* Determine the responsibilities (methods) of each class - Verbs
| |
| :* Describe the relationships between the classes
| |
| :* Create a "CRC Card" for each class on the provided flash cards.
| |
| ::: CRC Stands for "Classes, Responsibilities, and Collaborators"
| |
| | |
| | |
| Try organinzing classes so that a common superclass can take care of some responsibilities.
| |
| | |
| :* Team members should find the four main classes they think should exist in a small restaurant.
| |
| ::: This means making a list of nouns and choosing the four most practical candidates.
| |
| ::: Write out one class per index card.
| |
| | |
| :* Teams should write at least one responsibility for each class and come up with two total collaborators.
| |
| ::: Find one important task a restaurant would need to complete for each class, and write it on the CRC Card.
| |
| ::: Ask your team if this task needs help from other classes, and write this collaborator on the index card.
| |
| <br>
| |
| <br>
| |
| <br>
| |
| | |
| | |
| :::An example of a completed CRC Card:
| |
| <br>
| |
| <br>
| |
| :::::[[Image:indexcard.jpg]]
| |