[Skip Navigation] [CSUSB] / [CNS] / [CSE] / [R J Botting] / [CSci202] / lab02
[Text Version] [Syllabus] [Schedule] [Glossary] [Resources] [Grading] [Contact] [Question] [Search ]
Notes: [01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]
Labs: [01] [02] [03] [04] [05] [06] [07] [08] [09] [10]
Mon Apr 11 16:41:55 PDT 2011

Contents


    CSci202 Laboratory 02 Diagrams


      (previous): See [ lab01.html ]

      Goals

      To have compiled and tested the Person class from [ 02.html ] session 2 using a Makefile.

      By the end of the lab you should know how to draw and print diagrams using the Dia tool.

      Dia is a simple, free, and useful diagramming tool. It runs on UNIX and MSWindows platforms (Mac users had similar program 20 years ago).

      Deliverables Due at end of Lab Period

      Show us that you know how to make and run the test.Person program.

      Show us some diagrams that includes at least two UML diagrams. One is from the "Person" class we studied in class and the other from the examples in [ uml0.html ] , pick one and see how well you can duplicate it.

      Demo

      I will start the lab with a demo of how dia and make works.

      First Part -- done in a terminal window

      1. Create a directory to work in -- lab02 would be a good name.
         		mkdir lab02
      2. Change directory to lab02
         		cd lab02
      3. Download these files into lab02 [ 02ex/Person.h ] (declare class interface), [ 02ex/Person.cpp ] (implement functions), [ 02ex/test.Person.cpp ] (unit test), and [ 02ex/Makefile ] (makefile for directory).
      4. Type the command
         		make
        to compile the programs.
      5. Type the command
         		make test
        to test the code.

      . . . . . . . . . ( end of section First Part) <<Contents | End>>

      Ideal Procedure

      1. Start Dia. This may be on the desktop, in a "Start" menu (under Graphics?), or you may have to open a terminal window and type the command
         			dia &
        The "&" means that "dia" starts up in a new window and returns control to your terminal. You can use the terminal and "Dia" windows at the same time.
      2. Wait for a "Dia" control/toolkit window to pop up.
      3. In the toolkit look for the drop down menu of diagram types and select UML.
      4. Stretch the toolkit window to see all the "UML" symbols. This is important.
      5. Use the "File"->"New Diagram" to start a new diagram.
      6. Draw a diagram of the class "Person" that you just downloaded.
        1. Select the "Class" icon in the toolkit and click on the diagram to create it.
        2. Double click on the class and change its name to "Person".
        3. Select the "Attributes" tab and add the two attributes -- with types.
        4. Select the "Operations" tab to describe the functions -- with arguments etc.
        5. Close the properties window to look at the result.
        6. If ok, use the file menu to save it.

      7. Draw any other diagram from my notes [ uml0.html ]
        1. Select a shape in the toolkit, and use the mouse in the drawing window to draw something.
        2. Repeat with different figures in the tool kit.
        3. Select a figure by clicking on it. Right click and a menu pops up. The Edit submenu lets you copy, cut, paste, delete, etc. the selected figure. Try it.
        4. Double click a symbol to see what other options are available. These are fun and useful.

        5. At the bottom of the toolkit is a line and arrow menu. You can specify just about any kind of arrow or line. The left box is the first end as you draw it, and the right hand box selects the other end. The middle selects dots, dashes, solid, etc. Select the symbols in the third line of the top toolkit to get lines, curves, rectilinear lines, etc. Experiment with drawing some arrowhead lines of different types.
        6. When you draw a line, you can drop one end on to a blue connection point and the line will attach itself so that when the symbol moves, so does the end of the arrow. Try this out.
        7. You can draw an arrow from one blue cross to another and connect two symbols.
        8. In the toolkit: T means Text. Try using it to add words to a diagram. Double click text to change font.

        9. Double clicking most objects lets you change their colors and other properties... try this out. Creating UML classes and objects always involves double clicking and filling in some tabs.

        10. When in doubt: double click a symbol to change details. This is how you change the name of a class and add attributes and operations. Try it!
        11. You can also hide attributes and operations by double clicking and unchecking check boxes. Try this! Simplified diagrams with just names make complex software and data bases much clearer.

      8. Printing
        1. Before you print from Dia you may have to select a default printer for it to use. Select the System Menu -> Preferences -> Hardware -> ...Printer and pick the printer in your laboratory.
        2. To print a diagram, first Right Click in the drawing and pull down to File->Page Setup In this dialog select "Fit to 1 by 1" in the scaling section. Then "OK".
        3. Print by right Click->File->Print diagram.

      . . . . . . . . . ( end of section Ideal Procedure) <<Contents | End>>

      Dia options

      1. To save a file: right-click the diagram and select File->Save...
      2. Reopen a saved file by menu File->Open in the Dia Tool window.
      3. Use File->Defaults/Options/Properties? menu to change things you dislike about Dia.
      4. To learn how to put your diagram on the web, take CSci320 with me!

      . . . . . . . . . ( end of section Dia options) <<Contents | End>>

      Next

      Classes [ lab03.html ]

    . . . . . . . . . ( end of section CSci202 Laboratory 02 Diagrams) <<Contents | End>>

    Glossary

  1. accessor::=`A Function that accesses information in an object with out changing the object in any visible way". In C++ this is called a "const function". In the UML it is called a query.
  2. Algorithm::=A precise description of a series of steps to attain a goal, [ Algorithm ] (Wikipedia).
  3. class::="A description of a set of similar objects that have similar data plus the functions needed to manipulate the data".
  4. constructor::="A Function in a class that creates new objects in the class".
  5. Data_Structure::=A small data base.
  6. destructor::=`A Function that is called when an object is destroyed".
  7. Function::programming=A selfcontained and named piece of program that knows how to do something.
  8. Gnu::="Gnu's Not Unix", a long running open source project that supplies a very popular and free C++ compiler.
  9. mutator::="A Function that changes an object".
  10. object::="A little bit of knowledge -- some data and some know how". An object is instance of a class.
  11. objects::=plural of object.
  12. OOP::="Object-Oriented Programming", Current paradigm for programming.
  13. Semantics::=Rules determining the meaning of correct statements in a language.
  14. SP::="Structured Programming", a previous paradigm for programming.
  15. STL::="The standard C++ library of classes and functions" -- also called the "Standard Template Library" because many of the classes and functions will work with any kind of data.
  16. Syntax::=The rules determining the correctness and structure of statements in a language, grammar.
  17. Q::software="A program I wrote to make software easier to develop",
  18. TBA::="To Be Announced", something I should do.
  19. TBD::="To Be Done", something you have to do.
  20. UML::="Unified Modeling Language".
  21. void::C++Keyword="Indicates a function that has no return".

End