Skip to main contentCal State San Bernardino / [CNS] / [Comp Sci Dept] / [R J Botting] >> [CSci202] >> 08
[Index] [Schedule] [Syllabi] [Text] [Labs] [Projects] [Resources] [Search] [Contact] [Grading]
Notes: [01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]
Thu Apr 26 09:13:24 PDT 2007

Contents


    CSci202 Computer Science II, Session 08 Modeling


      (Previous): C++ Classes [ 07.html ]

      Preparation

      Study this page and [ uml0.html ] (handed out in meeting 07) and write down the questions, doubts, and surprises that you have on a piece of paper.

      Assigned Work Due

      Hand in one question, doubt or surprise with a page number. Include your printed name!

      Quick Demo -- UML on the web

      [ search?q=%22Unified+Modeling+Language%22 ] (5 million items!) [ images?hl=en&ie=ISO-8859-1&oe=ISO-8859-1&q=UML&gbv=1 ] (646,00 images).

      Quick Exercise on the UML

      [ links.png ] (Dia [ link.dia ] model).

      Quick Exercise -- Universal Widgets

      Write a C++ main program that tests the Widget and Wodget classes written in the last class [ 07.html#Quick Exercise ]

       [UML diagram of exercise]

      Here is the code for the Widget classes [ widgets.h ] and my unit tests [ testWidgets.cpp ]

      Input on the UML -- Software Development -- Fruit to Nuts and back

      Models: An object-oriented program keeps a simulation model of a real system outside the computer. We also construct models of computer software either to help design it, or or to help understand it.

      TBA -- possible CDROM played.

      Demo based on [ applications.2007spring.html ]

      Questions

        .What arrows are used in the UML The ones used betweeen classes are here [ links.png ] and there are many other in other kinds of diagrams.

        I must prepare a cheatsheet.

        What about artifacts

        Just the name for anything created when developing software.

        Use a diagram when it gets complicated -- 10 or more of them.

        How do algorithms fit into the UML

        They describe how an operation soves a complex problem. A step towards coding the body of functions.

        What is an Algorithm

        A precisely defined process for solving a problem -- typically as a set of terminating steps.

        Typically an algorithm is used to design the code inside a function.

        As an example: the problem is to find the Student that has a given name. Here is an algorithm called sequential search:

        1. Start with the first student
        2. If it has the right name, exit,
        3. Else go on to the next student and repeat the previous step.
        4. But if there are no more students, signal an error.

        We will cover lots more of these later.

        How do you decide what classes to create and what function to put in them

        Good question. There are several answers. I like the one in [ cs375 ] which takes a quarter to start to learn:-(

        The steps go:

        1. Analyse the users needs into use cases.
        2. Analyse use cases into scenarios
        3. Select an interstin scenario or two to work on.
        4. Draw a daomian model for the scenarios
        5. Draw an SSD naming the steps in a scenario as function calls to system
        6. For each step map out some interactions and objects needed. Use the domain model to supply names for the classes.
        7. Collect the operations into a class diagram
        8. Code the classes, and test them
        9. Code the us case and test.
        10. With the user's help plan the next best scenario to tackle.
        11. Repeat with another scenario, or another usecase.

        Who would we draw diagrams for

        Your self, your future self, team members, managers, colleagues, the web, job interviewees, teachers, and (future) your students.

        Note --- putting UML diagrams where people can see them in your office or cubicle, is a lot more impressive than a picture of your favorite pop star or film actor.

      Exercises If Time

      Here is the code for some improved WIdget and Wodget classes: [ widgets2.h ] and my unit tests [ testWidgets2.cpp ] , draw the UML diagram of these classes. What changes have I made and why did I do them?

      Next -- Quiz 2 on chapter 6 thru 9 on Objects and Classes

      Demonstrate one or more of these skills
      1. Given C++ classes draw UML diagram. May have generalization.
      2. Given UML class with attributes and operations write C++ Class declaration.
      3. Given small useless classes with inheritance predict what will compile in a program trying to use them.
      4. Given small useless classes with virtual functions and inheritance and a program that uses them work out what it outputs. May involve pointers.
      5. Answer a series of T/F questions about C++ classes and their members including the following words: inline, public, private, static, friend, virtual, const, this, protected, operator, class.
      6. Recognize where these words fit: inline, public, private, static, friend, virtual, const, this, protected, operator in a class.
      7. Complete a set of simple inline constructors for a class.
      8. Complete one of the common operators as members: +,-,*, ==, [], ...
      9. Complete one of the common IO operators as friends: << and >>
      10. Given class declaration and a short test program write/complete a definition for a member function.

      Preparation for the quiz

      Review this page plus [ inheritance.html ] [ polymorphism.html ] [ abstraction.html ] [ 05.html ] [ 06.html ] [ 07.html ] [ lab04.html ]

      Lab

      [ lab04.html ] TBA where you will create a safe array class and practice some of the above skills.

    . . . . . . . . . ( end of section CSci202 Computer Science II, Session 08 Modeling) <<Contents | End>>
    (Next): Exceptions, when bad things happen to good programs: [ 09.html ]


    (More): For more on modeling and the UML see [ UML in resources ]

    Abreviations

  1. TBA::="To Be Announced", something I have to do.
  2. TBD::="To Be Done", something you have to do.
  3. Dia::="A free Open Source Diagramming tool for Linux, Windoze, etc. ".

End