This site is from a past semester! The current version will be here when the new semester starts.
CS2113/T 2021 Jan-May
  • Full Timeline
  • Week 1 [Mon, Jan 11th]
  • Week 2 [Mon, Jun 21st]
  • Week 3 [Mon, Jun 28th]
  • Week 4 [Mon, Jul 5th]
  • Week 5 [Mon, Jul 12th]
  • Week 6 [Mon, Jul 19th]
  • Week 7 [Mon, Jul 26th]
  • Week 8 [Mon, Aug 9th]
  • Week 9 [Mon, Aug 16th]
  • Week 10 [Mon, Aug 23rd]
  • Week 11 [Mon, Aug 30th]
  • Week 12 [Mon, Sep 6th]
  • Week 13 [Mon, Sep 13th]
  • Textbook
  • Admin Info
  • Dashboards
  •  Individual Project (iP):
  • Individual Project Info
  • iP Upstream Repo
  • iP Code Dashboard
  • iP Progress Dashboard

  •  Team Project (tP):
  • Team Project Info
  • Reference AB3
  • Team List
  • tP Code Dashboard
  • tP Progress Dashboard
  • Java exercises
  • Report Bugs
  • Forum
  • Gitter (Chat)
  • Instructors
  • Announcements
  • Files (handouts, submissions etc.)
  • Tutorial Schedule
  • Java Coding Standard
  • Git Conventions
  • Forum Activities Dashboard
  • Participation Dashboard
  • Week 8 [Mon, Aug 9th] - Tutorial

    1 Exercise: interpret a class diagram

    • Do the following exercise as directed by the tutor.

    Explain the associations, navigabilities, and multiplicities in the class diagram below:

    2 Exercise: draw an object diagram

    [Image source: this article]

    Hand-drawing diagrams on a white-board and on paper is an important practical skill (e.g., for technical interviews, project discussions). It's possible that the diagrams you draw in your first few attempts to look amateurish, messy, and hard to read, and the drawing itself will take a long time. With more practice, you will be able to draw such diagrams quicker (e.g., draw as you explain verbally your design), with less need for corrections, and the diagrams will look more professional too.

    That is why we have structured these tutorials to get everyone to practice this skill so that your first few (not-so-good) diagram drawing experiences happen in the tutorial, not in an interview or during your internship.

    Note the following:

    • Draw on paper or on a whiteboard or use a free-hand drawing software (e.g., Bamboo paper). If latter, do not use UML software or predefined shapes.
    • For the same reason, don't use rulers.
    • When the tutor asks you to, take a screenshot or a photo of the drawing and post in the tutorial workspace document.
    • There are mobile apps (example) that can take a photo of a document and and convert it to a high-quality scan.
    • Do the following exercise while noting the info in the box above.

    Suppose we wrote a program to follow the class structure given in this class diagram:

    Draw object diagrams to represent the object structures after each of these steps below. Assume that we are trying to minimize the number of total objects.

    i.e. apply step 1 → [diagram 1] → apply step 2 on diagram 1 → [diagram 2] and so on.

    1. There are no persons.

    2. Alfred is the Guardian of Bruce.

    3. Bruce's contact number is the same as Alfred's.

    4. Alfred is also the guardian of another person. That person lists Alfred's home address as his home address as well as office address.

    5. Alfred has an office address at the Wayne Industries building which is different from his home address (i.e. Bat Cave).

    After step 2, the diagram should look like this:

    • Discuss answers as guided by the tutor.

    3 Exercise: draw a class diagram

    • Do the following similar to the earlier exercise.

    Draw a class diagram for the code below. Show the attributes, methods, associations, navigabilities, and multiplicities.

    class Box {
        private Item[] parts = new Item[10];
        private Item spareItem;
        private Lid lid; // lid of this box
        private Box outerBox;
    
        public void open() {
            // ...
        }
    }
    
    class Item {
        public static int totalItems;
    }
    
    class Lid {
        Box box; // the box for which this is the lid
    }