CSCI-383 Lecture 5-6-7: Object-Oriented Design


Published on

Published in: Technology, Education
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Reasons 1. These methods were already evolving toward each other independently. It made sense to continue that evolution together rather than apart, eliminating the potential for any unnecessary and gratuitous differences that would further confuse users. 2. By unifying the semantics and notation, they could bring some stability to the object-oriented marketplace, allowing projects to settle on one mature modeling language and letting tool builders focus on delivering more useful features. 3. They expected that their collaboration would yield improvements in all three earlier methods, helping them to capture lessons learned and to address problems that none of their methods previously handled well.
  • CSCI-383 Lecture 5-6-7: Object-Oriented Design

    1. 1. Lecture 5-6-7: Object-Oriented Design CSCI-383 Object-Oriented Programming & Design Ji Ruan 2009/09/23-25-28 StFX University, Canada
    2. 2. Overview <ul><ul><li>Introduction </li></ul></ul><ul><ul><li>Responsibility-Driven Design </li></ul></ul><ul><ul><li>Case Study with Design Components </li></ul></ul><ul><ul><li>UML Diagrams </li></ul></ul><ul><ul><li>Steps of Software Design </li></ul></ul>
    3. 3. Why Start with Design? <ul><ul><li>It is the easiest way to develop an appreciation of the problems of programming in the large (realistic modern software development).  </li></ul></ul><ul><ul><li>Without understanding programming in the large, one cannot understand the importance of OOP. </li></ul></ul>
    4. 4. Programming in the Small and in the Large <ul><li>Programming in the Small: </li></ul><ul><ul><li>One programmer understands everything from top to bottom.  </li></ul></ul><ul><ul><li>Major problem is the development of algorithms. </li></ul></ul><ul><li>Programming in the Large: </li></ul><ul><ul><li>A system is developed by large team (e.g. graphic artists, design experts, programmers, testers) </li></ul></ul><ul><ul><li>The major problem is the management of details and communication among diverse portion of the project.  </li></ul></ul>
    5. 5. Basis for Design <ul><ul><li>Consider for the moment what aspects of a problem are known first:  </li></ul></ul><ul><ul><ul><li>Data Structures  </li></ul></ul></ul><ul><ul><ul><li>Functions  </li></ul></ul></ul><ul><ul><ul><li>A Formal Specification  </li></ul></ul></ul><ul><ul><ul><li>Behavior  </li></ul></ul></ul><ul><ul><li>A design technique based on behavior can be applied from the very beginning of a problem, whereas techniques based on more structural properties necessarily require more preliminary analysis. </li></ul></ul>
    6. 6. Responsibility-Driven Design (RDD) <ul><li>A design technique that has the following properties: </li></ul><ul><ul><li>Can deal with ambiguous and incomplete specifications.  </li></ul></ul><ul><ul><li>Naturally flows from Analysis to Solution.  </li></ul></ul><ul><ul><li>Easily integrates with various aspects of software development. </li></ul></ul>
    7. 7. Directed Evolution <ul><ul><li>Let us take specifications as they occur in nature  </li></ul></ul><ul><ul><ul><li>Imprecise  </li></ul></ul></ul><ul><ul><ul><li>Ambiguous  </li></ul></ul></ul><ul><ul><ul><li>Unclear  </li></ul></ul></ul><ul><ul><li>and rather than attempt to change human nature, let us direct the evolution of the specification in concert with the design of the software system. </li></ul></ul>
    8. 8. An Example, the IIKH <ul><ul><li>Imagine you are the chief software architect in a major computing firm.  </li></ul></ul><ul><ul><li>The president of the firm rushes into your office with a specification for the next PC-based product. It is drawn on the back of a dinner napkin.  </li></ul></ul><ul><ul><li>Briefly, the Intelligent Interactive Kitchen Helper (IIKH) will replace the box of index cards of recipes in the average kitchen. </li></ul></ul>
    9. 9. Your Job Your job is to develop the software that will implement the IIKH.
    10. 10. Abilities of the IIKH <ul><li>Here are some of the things a user can do with the IIKH: </li></ul><ul><ul><li>Browse a database of recipes  </li></ul></ul><ul><ul><li>Add a new recipe to the database  </li></ul></ul><ul><ul><li>Edit or annotate an existing recipe  </li></ul></ul><ul><ul><li>Plan a meal consisting of several courses  </li></ul></ul><ul><ul><li>Scale a recipe for some number of users  </li></ul></ul><ul><ul><li>Plan a longer period, say a week  </li></ul></ul><ul><ul><li>Generate a grocery list that includes all the items in all the menus for a period </li></ul></ul>
    11. 11. Characterization by Behavior <ul><ul><li>Just as an Abstract Data Type is characterized more by behavior than by representation, the goal in using Responsibility-Driven Design will be to first characterize the application by behavior. </li></ul></ul><ul><ul><ul><li>First capture the behavior of the entire application.  </li></ul></ul></ul><ul><ul><ul><li>Refine this into behavioral descriptions of subsystems.  </li></ul></ul></ul><ul><ul><ul><li>Refine behavior descriptions into code.  </li></ul></ul></ul><ul><ul><li>This emphasis on behavior is a hallmark of Object-Oriented programming. </li></ul></ul>
    12. 12. Working Through Scenarios <ul><ul><li>Because of the ambiguity in the specification, the major tool we will use to uncover the desired behavior is to walk through application scenarios.  </li></ul></ul><ul><ul><ul><li>Pretend we had already a working application. Walk through the various uses of the system.  </li></ul></ul></ul><ul><ul><ul><li>Establish the ``look and feel'' of the system.  </li></ul></ul></ul><ul><ul><ul><li>Make sure we have uncovered all the intended uses.  </li></ul></ul></ul><ul><ul><ul><li>Develop descriptive documentation.  </li></ul></ul></ul><ul><ul><ul><li>Create the high level software design.  </li></ul></ul></ul><ul><ul><li>Other authors use the term ``use-cases'' for this process of developing scenarios. </li></ul></ul>
    13. 13. Software Components <ul><ul><li>A software component is simply an abstract design entity with which we can associate responsibilities for different tasks.  </li></ul></ul><ul><ul><li>May eventually be turned into a class, a function, a module, or something else.  </li></ul></ul><ul><ul><ul><li>A component must have a small well defined set of responsibilities  </li></ul></ul></ul><ul><ul><ul><li>A component should interact with other components to the minimal extent possible  </li></ul></ul></ul>
    14. 14. CRC Cards: Recording Responsibility <ul><ul><li>CRC (Component, Responsibility, Collaborator) </li></ul></ul><ul><ul><li>Components are most easily described using CRC cards.  </li></ul></ul><ul><ul><li>A CRC card records the name, responsibilities, and collaborators of an component.  </li></ul></ul><ul><ul><li>Advantage: Inexpensive, Erasable, Physical </li></ul></ul>
    15. 15. Different Components <ul><li>Let us return to the development of the IIKH. </li></ul><ul><ul><li>The Greeter Components </li></ul></ul><ul><ul><li>The Recipe Database Component </li></ul></ul><ul><ul><li>The Recipe Component </li></ul></ul><ul><ul><li>The Planner Component </li></ul></ul><ul><ul><li>The Date Component </li></ul></ul><ul><ul><li>The Meal Component </li></ul></ul>
    16. 16. Component 1: The Greeter <ul><li>The first component your team defines is the Greeter. When the application is started, the Greeter puts an informative and friendly welcome window (the greeting) on the screen.  </li></ul><ul><li>Offer the user the choice of several different actions </li></ul><ul><ul><li>Casually browse the database of recipes.  </li></ul></ul><ul><ul><li>Add a new recipe.  </li></ul></ul><ul><ul><li>Edit or annotate a recipe.  </li></ul></ul><ul><ul><li>Review a plan for several meals.  </li></ul></ul><ul><ul><li>Create a plan of meals.  </li></ul></ul><ul><li>Many of the details concerning exactly how this is to be done can be ignored for the moment. </li></ul>
    17. 17. Component 1: The Greeter CRC card for the Greeter:
    18. 18. Component 2: The Recipe Database <ul><li>Ignoring the planning of meals for the moment, your team elects to next explore the recipe database component. </li></ul><ul><ul><li>Must maintain the Database of recipes.  </li></ul></ul><ul><ul><li>Must allow the user to browse the database.  </li></ul></ul><ul><ul><li>Must permit the user to edit or annotate an existing recipe.  </li></ul></ul><ul><ul><li>Must permit the user to add a new recipe. </li></ul></ul>
    19. 19. The Who/What Cycle <ul><li>As we walk through scenarios, we go through cycles of identifying a what, followed by a who </li></ul><ul><ul><li>What action needs to be performed at this moment,  </li></ul></ul><ul><ul><li>Who is the component charged with performing the action  </li></ul></ul><ul><li>Every what must have a who , otherwise it simply will not happen. Sometimes the who might not be obvious at first, i.e., who should be in charge of editing a recipe? </li></ul>
    20. 20. Postponing Decisions <ul><ul><li>Many decisions, such as the method of browsing, can be ignored for the moment, as they are entirely encapsulated within the recipe database component, and do not effect other components.  </li></ul></ul><ul><ul><ul><li>Scroll bars and windows?  </li></ul></ul></ul><ul><ul><ul><li>A virtual &quot;book'' with thumb-holes and flipping pages?  </li></ul></ul></ul><ul><ul><ul><li>Keywords and phrases? </li></ul></ul></ul><ul><ul><li>Only need to note that somehow the user can manipulate the database to select a specific recipe. </li></ul></ul>
    21. 21. Component 3: The Recipe <ul><li>We make the recipe itself into an active data structure. It maintains information, but also performs tasks. </li></ul><ul><ul><li>Maintains the list of ingredients and transformation algorithm.  </li></ul></ul><ul><ul><li>Must know how to edit these data values.  </li></ul></ul><ul><ul><li>Must know how to interactively display itself on the output device.  </li></ul></ul><ul><ul><li>Must know how to print itself.  </li></ul></ul><ul><ul><li>We will add other actions later (ability to scale itself, produce integrate ingredients into a grocery list, and so on).  </li></ul></ul>
    22. 22. Component 4: The Planner <ul><li>Returning to the greeter, we start a different scenario. This leads to the description of the Planner. </li></ul><ul><ul><li>Permits the user to select a sequence of dates for planning.  </li></ul></ul><ul><ul><li>Permits the user to edit an existing plan.  </li></ul></ul><ul><ul><li>Associates with Date object.  </li></ul></ul>
    23. 23. Component 5: The Date <ul><li>The Date component holds a sequence of meals for an individual date. </li></ul><ul><ul><li>User can edit specific meals.  </li></ul></ul><ul><ul><li>User can annotate information about dates (''Bob's Birthday'', &quot;Christmas Dinner'', and so on).  </li></ul></ul><ul><ul><li>Can print out grocery list for entire set of meals. </li></ul></ul>
    24. 24. Component 6: The Meal <ul><li>The Meal component holds information about a single meal. </li></ul><ul><ul><li>Allows user to interact with the recipe database to select individual recipes for meals.  </li></ul></ul><ul><ul><li>User sets number of people to be present at meal, recipes are automatically scaled.  </li></ul></ul><ul><ul><li>Can produce grocery list for entire meal, by combining grocery lists from individual scaled recipes.  </li></ul></ul>
    25. 25. The Six Components <ul><ul><li>Having walked through the various scenarios, you team eventually decides everything can be accomplished using only six software components.  </li></ul></ul><ul><ul><li>You can at this point assign the different components to different programmers for development.  </li></ul></ul>
    26. 26. Interaction Diagrams The picture on the previous slide captures static relationships, but not the dynamic flow of messages in a senario. That information can be recorded by an interaction diagram.
    27. 27. Unified Modeling Language (UML) <ul><ul><li>UML is a standard language for: </li></ul></ul><ul><ul><ul><li>Specifying, visualizing, constructing, and documenting the artifacts of software systems  </li></ul></ul></ul><ul><ul><ul><li>Also works for business modeling and other non-software systems </li></ul></ul></ul><ul><ul><li>A collection of best engineering practices that have proven successful in the modeling of large and complex systems. </li></ul></ul><ul><ul><li>The slides on UML are compiled based on [1] UML Resource page , OMG.; [2] UML, Wikipedia ; [3] UML tutorial by Kennesaw State University . </li></ul></ul>
    28. 28. Goals of UML <ul><ul><li>Provide users with a ready-to-use, expressive visual modeling language.  </li></ul></ul><ul><ul><li>Provide extensibility and specialization mechanisms to extend the core concepts. </li></ul></ul><ul><ul><li>Be independent of particular programming languages and development processes.  </li></ul></ul><ul><ul><li>Provide a formal basis for understanding the modeling language.  </li></ul></ul><ul><ul><li>Encourage the growth of the OO tools market.  </li></ul></ul><ul><ul><li>Support higher-level development concepts such as collaborations, frameworks, patterns and components.  </li></ul></ul><ul><ul><li>Integrate best practices. </li></ul></ul>
    29. 29. Why use UML? <ul><ul><li>To automate the production of software </li></ul></ul><ul><ul><li>To improve quality and reduce cost and time-to-market.  </li></ul></ul><ul><ul><ul><li>These techniques include component technology, visual programming, patterns and frameworks.  </li></ul></ul></ul><ul><ul><li>To manage the complexity of systems.  </li></ul></ul><ul><ul><ul><li>physical distribution,  </li></ul></ul></ul><ul><ul><ul><li>concurrency,  </li></ul></ul></ul><ul><ul><ul><li>replication,  </li></ul></ul></ul><ul><ul><ul><li>security,  </li></ul></ul></ul><ul><ul><ul><li>load balancing  </li></ul></ul></ul><ul><ul><ul><li>and fault tolerance.  </li></ul></ul></ul><ul><ul><ul><li>World Wide Web has exacerbated these architectural problems </li></ul></ul></ul>
    30. 30. Standardization <ul><ul><li>Officially defined by the Object Management Group (OMG) </li></ul></ul><ul><ul><li>UML models may be automatically transformed to other representations (e.g. Java) by means of QVT-like transformation languages </li></ul></ul>
    31. 31. History Of UML <ul><ul><li>Late 1994  </li></ul></ul><ul><ul><ul><li>Grady Booch, the Booch method </li></ul></ul></ul><ul><ul><ul><li>Jim Rumbaugh, OMT (Object Modeling Technique) method  </li></ul></ul></ul><ul><ul><li>Fall of 1995 </li></ul></ul><ul><ul><ul><li>Ivar Jacobson (with his Objectory company), the OOSE (Object-Oriented Software Engineering) method </li></ul></ul></ul><ul><ul><li>Reasons for Merging </li></ul></ul><ul><ul><ul><li>Evolving toward each other independently </li></ul></ul></ul><ul><ul><ul><li>Bring some stability to the OO marketplace </li></ul></ul></ul><ul><ul><ul><li>Yield improvements in all three earlier methods </li></ul></ul></ul><ul><ul><li>1996, the international consortium UML partners was formed </li></ul></ul><ul><ul><li>Jan 1997, UML partners proposed UML 1.0 spec draft to the OMG </li></ul></ul>
    32. 32. Diagrams Overview <ul><ul><li>Structure diagrams </li></ul></ul><ul><ul><ul><li>Emphasize what things must be in the system being modeled </li></ul></ul></ul><ul><ul><li>Behavior diagrams </li></ul></ul><ul><ul><ul><li>Emphasize what must happen in the system being modeled </li></ul></ul></ul><ul><ul><li>Interaction diagrams  </li></ul></ul><ul><ul><ul><li>Subset of behavior diagrams </li></ul></ul></ul><ul><ul><ul><li>Emphasize the flow of control and data among the things in the system being modeled </li></ul></ul></ul>
    33. 33. Diagrams Overview <ul><ul><li>Structure diagrams </li></ul></ul><ul><ul><ul><li>Emphasize what things must be in the system being modeled </li></ul></ul></ul><ul><ul><li>Behavior diagrams </li></ul></ul><ul><ul><ul><li>Emphasize what must happen in the system being modele d </li></ul></ul></ul><ul><ul><li>Interaction diagrams  </li></ul></ul><ul><ul><ul><li>Subset of behavior diagrams </li></ul></ul></ul><ul><ul><ul><li>Emphasize the flow of control and data among the things in the system being modeled </li></ul></ul></ul>
    34. 34. Behavior diagrams <ul><ul><li>Use case diagram : Displays the relationship among actors and use cases </li></ul></ul><ul><ul><li>Activity diagram : describe the workflow behavior of a system </li></ul></ul><ul><ul><li>State diagram : Displays all of the possible states of an object as events occur </li></ul></ul>
    35. 35. Use case diagram <ul><ul><li>Definition: A use case is a set of scenarios that describing an interaction between a user and a system </li></ul></ul><ul><ul><li>Two main components </li></ul></ul><ul><ul><ul><li>Actors: represents a user or another system that will interact with your system </li></ul></ul></ul><ul><ul><ul><li>Use cases </li></ul></ul></ul>
    36. 36. Use case diagram <ul><ul><li>Start by listing a sequence of steps a user might take in order to complete an action </li></ul></ul><ul><ul><li>E.g. a user placing an order with a sales company might follow these steps  </li></ul></ul><ul><ul><ul><li>Browse catalog and select items.  </li></ul></ul></ul><ul><ul><ul><li>Call sales representative.  </li></ul></ul></ul><ul><ul><ul><li>Supply shipping information.  </li></ul></ul></ul><ul><ul><ul><li>Supply payment information.  </li></ul></ul></ul><ul><ul><ul><li>Receive conformation number from salesperson.  </li></ul></ul></ul><ul><ul><ul><li>These steps would generate this simple use case diagram </li></ul></ul></ul>
    37. 37. Activity diagram <ul><li>When </li></ul><ul><ul><li>To model a workflow </li></ul></ul><ul><ul><li>To analyze a use case </li></ul></ul><ul><ul><li>To describing a complicated sequential algorithm </li></ul></ul><ul><ul><li>To model applications with parallel processes </li></ul></ul><ul><li>How </li></ul><ul><ul><li>Top to bottom </li></ul></ul><ul><ul><li>A fork is used when multiple activities are occurring at the same time </li></ul></ul><ul><ul><li>A branch describes what activities will take place based on a set of conditions. </li></ul></ul>
    38. 38. Activity diagram Example <ul><li>Example: processing an order </li></ul><ul><ul><li>the order is received </li></ul></ul><ul><ul><li>two parallel sets of activities </li></ul></ul><ul><ul><li>One side fills and sends the order </li></ul></ul><ul><ul><li>One handles the billing  </li></ul></ul><ul><ul><li>close the order </li></ul></ul>
    39. 39. State Diagram <ul><li>When </li></ul><ul><ul><li>To demonstrate the behavior of an object through many use cases of the system </li></ul></ul><ul><ul><li>NOT all classes will require a state diagram </li></ul></ul><ul><ul><li>NOT useful for describing the collaboration of all objects in a use case </li></ul></ul>
    40. 40. State Diagram <ul><li>How </li></ul><ul><ul><li>Rounded boxes as states </li></ul></ul><ul><ul><li>Arrows for transition </li></ul></ul><ul><ul><li>Solid circle as the initial state </li></ul></ul><ul><ul><li>Conditions based on the activities can determine what the next state the object transitions to </li></ul></ul>
    41. 41. State Diagram An Example: Order object
    42. 42. UML Diagrams Overview <ul><ul><li>Structure diagrams </li></ul></ul><ul><ul><ul><li>Emphasize what things must be in the system being modeled </li></ul></ul></ul><ul><ul><li>Behavior diagrams </li></ul></ul><ul><ul><ul><li>Emphasize what must happen in the system being modeled </li></ul></ul></ul><ul><ul><li>Interaction diagrams  </li></ul></ul><ul><ul><ul><li>Subset of behavior diagrams </li></ul></ul></ul><ul><ul><ul><li>Emphasize the flow of control and data among the things in the system being modeled </li></ul></ul></ul>
    43. 43. Interaction diagram <ul><li>When </li></ul><ul><ul><li>To model the behavior of several objects in a use case </li></ul></ul><ul><li>Two kinds </li></ul><ul><ul><li>Sequence diagrams : generally show the sequence of events that occur </li></ul></ul><ul><ul><li>Collaboration diagrams : demonstrate how objects are statically connected </li></ul></ul>
    44. 44. Interaction diagram <ul><li>Sequence diagrams </li></ul><ul><ul><li>How : left to right and descending </li></ul></ul><ul><ul><li>Example: placing an order [InStock] [OutOfStock] are conditions </li></ul></ul>
    45. 45. Interaction diagram <ul><li>Collaboration diagrams </li></ul><ul><ul><li>How: Objects listed as icons and arrows; Sequence numbers </li></ul></ul><ul><ul><li>Example: placing an order </li></ul></ul>
    46. 46. Activity vs. State vs. Interaction <ul><ul><li>Activity Diagram </li></ul></ul><ul><ul><ul><li>Workflow (activity) of a system </li></ul></ul></ul><ul><ul><li>State Diagram </li></ul></ul><ul><ul><ul><li>All possible states of an object </li></ul></ul></ul><ul><ul><ul><li>Through many use cases (as long as the object is involved in the use case) </li></ul></ul></ul><ul><ul><li>Interaction Diagram </li></ul></ul><ul><ul><ul><li>Interaction of several objects </li></ul></ul></ul><ul><ul><ul><li>Within a use case </li></ul></ul></ul>
    47. 47. Characteristics of Components <ul><li>Let us return to the idea of a software component. There are many different aspects to this simple idea, we will consider just a few: </li></ul><ul><ul><li>Behavior and State  </li></ul></ul><ul><ul><li>Instances and Classes  </li></ul></ul><ul><ul><li>Coupling and Cohesion  </li></ul></ul><ul><ul><li>Interface and Implementation  </li></ul></ul>
    48. 48. Behavior and State <ul><ul><li>All components can be characterized by two aspects:  </li></ul></ul><ul><ul><ul><li>The behavior of a component is the set of actions a component can perform. The complete set of behavior for a component is sometimes called the protocol.  </li></ul></ul></ul><ul><ul><ul><li>The state of a component represents all the information (data values) held within a component.   </li></ul></ul></ul><ul><ul><li>Notice that it is common for behavior to change state. For example, the edit behavior of a recipe may change the preparation instructions, which is part of the state. </li></ul></ul>
    49. 49. Instances and Classes There are likely many instances of recipe, but they will all behave in the same way. We say the behavior is common to the class Recipe. Since earlier our goal was to identify behavior, we ignored this distinction and concentrated on prototypical objects.
    50. 50. Coupling and Cohesion <ul><li>The separation of tasks into the domains of different components should be guided by the concepts of coupling and cohesion. </li></ul><ul><ul><li>Cohesion is the degree to which the tasks assigned to a component seem to form a meaningful unit. Want to maximize cohesion.  </li></ul></ul><ul><ul><li>Coupling is the degree to which the ability to fulfill a certain responsibility depends upon the actions of another component. Want to minimize coupling.  </li></ul></ul>
    51. 51. Interface and Implementation <ul><ul><li>We have characterized software components by what they can do.  </li></ul></ul><ul><ul><li>The user of a software component need only know what it does, not how it does it.  </li></ul></ul>
    52. 52. Two views of a Software System <ul><ul><li>This naturally leads to two views of a software system.  </li></ul></ul><ul><ul><li>The term information hiding is used to describe the purposeful hiding of implementation details  </li></ul></ul>
    53. 53. Parnas' Principles <ul><li>These ideas were captured by computer scientist David Parnas in a pair of rules, which are known as Parnas' Principles: </li></ul><ul><ul><li>The developer of a software component must provide the intended user with all the information needed to make effective use of the services provided by the component, and should provide no other information.  </li></ul></ul><ul><ul><li>The implementor of a software component must be provided with all the information necessary to carry out the given responsibilities assigned to the component, and should be provided with no other information.  </li></ul></ul>
    54. 54. Public and Private View <ul><li>In C++ and Java, Parnas's Principles lead to the ideas of a public and private view. </li></ul><ul><ul><li>Public view - those features (data or behavior) that other components can see and use  </li></ul></ul><ul><ul><li>Private view - those features (data or behavior) that are used only within the component  </li></ul></ul>
    55. 55. Formalize the Interface <ul><li>The next step is to formalize the channels of communication between the components.  </li></ul><ul><ul><li>The general structure of each component is identified.  </li></ul></ul><ul><ul><li>Components with only one behavior may be made into functions.  </li></ul></ul><ul><ul><li>Components with many behaviors are probably more easily implemented as classes.  </li></ul></ul><ul><ul><li>Names are given to each of the responsibilities - these will eventually be mapped on to procedure names.  </li></ul></ul><ul><ul><li>Information is assigned to each component and accounted for.  </li></ul></ul><ul><ul><li>Scenarios are replayed in order to ensure all data is available.  </li></ul></ul>
    56. 56. Names Selection <ul><li>Government bureaucrats have long shown us that obscure names can make even the simplest operation sound intimidating. The selection of names is an important task. </li></ul><ul><ul><li>Names should be evocative in the context of the problem.  </li></ul></ul><ul><ul><li>Names should be short.  </li></ul></ul><ul><ul><li>Names should be pronounceable (read them out load).  </li></ul></ul><ul><ul><li>Names should be consistent within the project.  </li></ul></ul><ul><ul><li>Avoid digits within a name.  </li></ul></ul>
    57. 57. Documentation <ul><ul><li>Besides CRC cards, it is important that the development of other documentation be performed almost from the beginning.  </li></ul></ul><ul><ul><li>The two most important documents are the user manual and the design documentation of the software system. </li></ul></ul>
    58. 58. User Manual <ul><li>The user manual describes the application as seen by the user. </li></ul><ul><ul><li>Does not depend upon the implementation, so can be developed before the implementation.  </li></ul></ul><ul><ul><li>Can naturally flow from the process of walking through scenarios.  </li></ul></ul><ul><ul><li>Can be carried back to the clients to make sure the users and the implementors have the same ideas.  </li></ul></ul>
    59. 59. Quality <ul><ul><li>You should always remember that the primary measure of quality is the degree to which your customers (clients) are satisfied with your product.  </li></ul></ul><ul><ul><li>Since often customers do not know exactly what it is they want, it is important to work with the client early in the design phase to make sure the system your are developing is the desired product. One very important way to do this is to create the user manual even before the software is written. </li></ul></ul>
    60. 60. System Design Documentation <ul><li>Record the decisions made during the process of system design. </li></ul><ul><ul><li>Record the arguments for and against any major decision, and the factors influencing the final choice.  </li></ul></ul><ul><ul><li>Record CRC cards for the major components.  </li></ul></ul><ul><ul><li>Maintain a log or diary of the process schedule.  </li></ul></ul><ul><ul><li>Important to produce this while the ideas are fresh, not in hindsight when many details will have been forgotten.  </li></ul></ul><ul><ul><li>Note the code only records the outcome of decisions, not factors that lead up to decisions being made.  </li></ul></ul>
    61. 61. Preparing for Change <ul><li>Your design team should also keep in mind that change is inevitable. Users requirements change with experience, hardware changes, government regulations change. </li></ul><ul><ul><li>Try to predict the most likely sources of change, and isolate the effect. Common changes include interfaces, file formats, communication protocols.  </li></ul></ul><ul><ul><li>Isolate interfaces to hardware that is likely to change.  </li></ul></ul><ul><ul><li>Reduce dependency of one software component on another.  </li></ul></ul><ul><ul><li>Keep accurate record of the reasoning behind every major decision in the design documentation. </li></ul></ul>
    62. 62. Next Step - Select Representations for Subsystems <ul><ul><li>Next the internal representation of the software subsystem corresponding to each component is selected.  </li></ul></ul><ul><ul><li>Knowledge of the classic data structures of Computer Science is important here.  </li></ul></ul><ul><ul><li>Often once data structures have been selected, the code is almost self-evident. </li></ul></ul>
    63. 63. Step - Implement and Test Subsystems <ul><ul><li>Classic techniques, such as stepwise refinement, are used to implement each of the subsystems.  </li></ul></ul><ul><ul><li>Subsystems are validated in isolation.  </li></ul></ul><ul><ul><ul><li>Informal proofs of correctness for the subsystem are developed.  </li></ul></ul></ul><ul><ul><ul><li>Identify necessary conditions for correct functioning. Try to minimize conditions, and test input values whenever possible.  </li></ul></ul></ul><ul><ul><ul><li>Software testing is used as a confidence building measure.  </li></ul></ul></ul>
    64. 64. Step - Integration and Testing <ul><ul><li>Components are slowly integrated into completed system.  </li></ul></ul><ul><ul><li>Stubs can be used to perform testing all during integration.  </li></ul></ul><ul><ul><li>Errors discovered during integration to cause reinvestigation of validation techniques performed at the subsystem level. </li></ul></ul>
    65. 65. Maintainence and Evolution <ul><ul><li>Software does not remain fixed after the first working version is released.  </li></ul></ul><ul><ul><ul><li>Errors or bugs can be discovered. Must be corrected.  </li></ul></ul></ul><ul><ul><ul><li>Requirements may change. Say as a result of government regulations, or standardization among similar products.  </li></ul></ul></ul><ul><ul><ul><li>Hardware may change.  </li></ul></ul></ul><ul><ul><ul><li>Users expectations may change. Greater functionality, more features. Often as a result of competition from similar products.  </li></ul></ul></ul><ul><ul><ul><li>Better documentation may be required.  </li></ul></ul></ul><ul><ul><li>A good design recognizes the inevitability of change, and plans an accommodation for these activities from the very beginning. </li></ul></ul>
    66. 66. Common Design Flaws <ul><ul><li>Direct modification: Components that make direct modification of data values in other components are a direct violation of encapsulation. Such coupling makes for inflexible designs.  </li></ul></ul><ul><ul><li>Too Much Responsibility: Components with too much responsibility are difficult to understand and to use. Responsibility should be broken into smaller meaningful packages and distributed.  </li></ul></ul><ul><ul><li>No Responsibility: Components with no responsibility serve no purpose. Often arise when designers equate physical existence with logical design existence. &quot;Money is no object''  </li></ul></ul><ul><ul><li>Components with unused responsibility:  Usually the result of designing software components without thinking about how they will be used.  </li></ul></ul><ul><ul><li>Misleading Names:  Names should be short and unambiguously indicate what the responsibilities of the component involve. </li></ul></ul>
    67. 67. <ul><ul><li>Ex 3.1: Describe the responsibilities of a hospital that includes at least six types of members. For each member type, describe the responsibilities and the collaborators using CRC cards. </li></ul></ul><ul><ul><li>Ex 3.2: Create a scenario for the hospital you described in Ex 3.1 using an interaction diagram.   </li></ul></ul><ul><ul><li>Deadline: Wed, October 7th, 2009. </li></ul></ul>Assignment 3:
    68. 68. About these slides <ul><li>These slides are created by Dr. Ji Ruan on top of the lecture notes by Prof. Wendy MacCaull and Dr. Hao Wang from their previous years' teaching on this course at StFX University.  </li></ul><ul><li>The core materials are based on book: An introduction to Object-Oriented Programming, 3rd edition, by Timothy Budd. </li></ul><ul><li>The slides are licensed under Creative Commons Attribution-Share Alike 3.0 </li></ul><ul><li>You are free to Share and Remix this work, under the following conditions:  </li></ul><ul><ul><li>Attribution </li></ul></ul><ul><ul><li>Share Alike </li></ul></ul>