UML Class Diagram construction

LeDoc

Having a bit of trouble coming with a class diagram using the following information:

  • A person owns zero or more houses.
  • A mortgage has a start date and an end date.
  • A mortgage has a total and consists of monthly payments.
  • The bank stores information on the National Insurance Number and salary of each person, that request a mortage for a house.
  • A mortgage belongs to one person.
  • A house can have zero or more mortgages on it but it is owned by only one person.
  • A house has a value and acts as a bank security for associated mortgages.
  • A person has zero or more mortgages.
  • A person may apply for a mortgage to buy a house.

             1   Owns    *              hasSecurity
     Person  ------------> House    <--------------- Bank
     -NINumber             -address          
     -salary               -value
     |
     | has
     |
     \/*
    Mortgage
    -startDate
    -EndDate
    -total
    -monthlyPayments
    

Would someone be able to suggest how this is modeled. Examples using diagrams would be appreciated.

umlcat

I think you are getting confused with all those information.

(1) You may start with class diagrams by identifying which classes interact, leaving quantities , properties, & relationships for the next steps.

Like these:

............................................
..+--------------+........+--------------+..
..|    Person    |........|   Mortage    |..
..+--------------+........+--------------+..
............................................
..+--------------+........+--------------+..
..|    House     |........|    Bank      |..
..+--------------+........+--------------+..
............................................
..+--------------+..........................
..|   Payment    |..........................
..+--------------+..........................
............................................

Watch, that this incomplete diagram, doesn't have properties, relationships, operations, etc., yet. There are some dots that represent the blank page.

(2) From the given information, identify & assign values, & properties for each entity or class.

Do not mix those properties that represent an internal value ("Mortage.StartDate"), from properties that represent a relationship to other classes or objects ("A House can have Zero or More Mortages").

An example of a classs with only internal properties could be:

....................
..+--------------+..
..|   Mortage    |..
..+--------------+..
..|  StartDate   |..
..|  EndDate     |..
..|  Total       |..
..+--------------+..
....................

Properties are represented by a list of bullets, we commonly use "+" before each property, later, you see it can be changed:

.......................
..+-----------------+..
..|    Mortage      |..
..+-----------------+..
..| [+] StartDate   |..
..| [+] EndDate     |..
..| [+] Total       |..
..+-----------------+..
.......................

Do not confuse the "+" on the items, with the "+" on the corners of the classes.

Sometimes, classes may show some of its properties, or not properties at, all, even if the have it. This can be represented by a blank section box, or a box with 3 dots:

..................................................
..+-----------------+........+-----------------+..
..|    Mortage      |........|      House      |..
..+-----------------+........+-----------------+..
..|      ...        |........|                 |..
..+-----------------+........+-----------------+..
..................................................

An Example of a class with properties that represent other objects or classes, wheter links, or references, or subparts:

..................................................
..+-----------------+........+-----------------+..
..|    Mortage      |....+---+      House      |..
..+-----------------+....|...+-----------------+..
..| [+] Owner       +----+...|       ...       |..
..+-----------------+........+-----------------+..
..................................................

And, represent a class or object with both kind of properties, preferably in a different section.

....................................................
..+-----------------+........+-----------------+....
..|    Mortage      |........|     Person      |....
..+-----------------+........+-----------------+....
..| [+] StartDate   |........| [+] Salary      |....
..| [+] EndDate     |........|                 |....
..| [+] Total       |........|                 |....
..+-----------------+........+-----------------+....
..| [+] Owner       +----+...| [+] Houses      |....
..+-----------------+....|...+--------+--------+....
.........................|............|.............
.........................|............|.............
.........................|............|.............
.........................|...+--------+--------+....
.........................|...|      House      |....
.........................|...+-----------------+....
.........................|...|                 |....
.........................+---+      ...        |....
.............................|                 |....
.............................+-----------------+....
.............................| [+] Owner       |....
.............................| [+] Mortages    |....
.............................+-----------------+....
....................................................

Note, also that there are several types of relationships, represented with arrows, triangles, diamonds, lets skip this for a moment, and use just a line, that represents that "there some kind of relationship" between 2 classes.

(3) Once, you have identify the difference between basic properties & properties that represent relationships, you may describe all relationships in your diagram.

............................................
..+--------------+........+--------------+..
..|   Payment    |........|    Person    |..
..+--------------+........+--------------+..
..| [+] Mortage  |........| [+] Houses   |..
..|              |........|              |..
..|              |........|              |..
..+------+-------+........+-------+------+..
.........|........................|.........
.........|........................|.........
.........|........................|.........
..+------+-------+........+-------+------+..
..|   Mortage    |........|    House     |..
..+--------------+........+--------------+..
..| [+] Owner    |........| [+] Owner    |..
..| [+] House    +--------+              |..
..|              |........|              |..
..+-------+------+........+--------------+..
..........|.................................
..........|.................................
..........|.................................
..+-------+------+..........................
..|     Bank     |..........................
..+--------------+..........................
..| [+] Debtors  |..........................
..+--------------+..........................
............................................

Note that there are some relationship, that are indirect, example, a monthly payment is performed to a mortage by a person, yet the payment relationship to the person, is not displayed directly, instead, its displayed thru the mortage.

(4) There are several kinds of relationships among classes, in UML. Some relationships, have to due with object creation.

(5) There also objects where exist independently of others, and, scenarios where an object existance depends on another object. And, that makes 2 different kind of objects.

For example, Payments depends on the existance of a Mortage. A House exist wheter there is a Owner Person, or a Owner Bank, or It has Mortages. A Bank existe wheter there is a Mortage to a House, or a Debtor.

When an object or class depends on another class, its relationship is called "Composition", and its represented by a filled diamond, at the edge of the relationship arrow, where the main class if.

....................
..+--------------+..
..|   Payment    |..
..+--------------+..
..| [+] Mortage  |..
..|              |..
..|              |..
..+------+-------+..
.........|..........
.........|..........
.........|..........
.........^..........
........<*>.........
..+------v-------+..
..|   Mortage    |..
..+--------------+..
..|     ...      |..
..+--------------+..
....................

(6) In cases, where an object exist separatelly from another object, but, there is some kind of association, Its called an "Aggregation", and its represented similar, but, with an non-filled empty diamond, instead.

....................
..+--------------+..
..|    Person    |..
..+--------------+..
..| [+] Houses   |..
..+------^-------+..
........< >.........
.........v..........
.........|..........
.........|..........
.........|..........
..+------+-------+..
..|    House     |..
..+--------------+..
..|     ...      |..
..+--------------+..
....................

(7) In relationships, quantities are applied. The "many" concept, is usually displayed with an asterisk "*".

This diagram, with quantites may be like:

............................................
..+--------------+........+--------------+..
..|   Payment    |........|    Person    |..
..+--------------+........+--------------+..
..| [+] MonthNo  |........|              |..
..+--------------+........|              |..
..| [+] Mortage  |........| [+] Houses   |..
..|              |........|              |..
..+------+-------+........+-------^------+..
.........|..12...................< >.1......
.........|........................v.........
.........|........................|.........
.........^ .......................|.........
........< >.1.....................|..*......
..+------v-------+........+-------+------+..
..|   Mortage    |........|    House     |..
..+--------------+........+--------------+..
..| [+] Ammount  |........| [+] Address  |..
..+--------------+........+--------------+..
..| [+] Owner    |.*...1.^| [+] Owner    |..
..| [+] House    +------< >              |..
..|              |.......v|              |..
..+-------+------+........+--------------+..
..........|..*..............................
..........|.................................
..........|.................................
..........^.................................
.........< >.1..............................
..+-------v------+..........................
..|     Bank     |..........................
..+--------------+..........................
..| [+] Debtors  |..........................
..| [+] Mortages |..........................
..+--------------+..........................
............................................

(8) There are other concepts that apply to Class & Object Diagrams, like Inheritance Relationships. Or, add other classes, such a "Request" class. Lets skip it for now.

A possible final class diagram could be:

...............................................
..+----------------+........+---------------+..
..|    Payment     |........|    Person     |..
..+----------------+........+---------------+..
..| [+] MonthNo    |........| [+] FirstName |..
..| [+] Ammount    |........| [+] LastName  |..
..+----------------+........| [+] NINNo     |..
..| [+] Mortage    |........| [+] Salary    |..
..|                |........+---------------+..
..|                |........| [+] Houses    |..
..|                |........|               |..
..+-------+--------+........+-------^-------+..
..........|..12....................< >.1.......
..........|.........................v..........
..........|.........................|..........
..........^ ........................|..........
.........< >.1......................|..*.......
..+-------v--------+........+-------+-------+..
..|   Mortage      |........|     House     |..
..+----------------+........+---------------+..
..| [+] StartDate  |........| [+] Address   |..
..| [+] FinishDate |........| [+] Value     |..
..| [+] Total      |........|               |..
..+----------------+........+---------------+..
..| [+] Owner      |.*...1.^| [+] Owner     |..
..| [+] House      +------< >               |..
..+-------+--------+.......v+---------------+..
..........|..*................................
..........|...................................
..........|...................................
..........^...................................
.........< >.1................................
..+-------v------+............................
..|     Bank     |............................
..+--------------+............................
..| [+] Name     |............................
..+--------------+............................
..| [+] Debtors  |............................
..| [+] Mortages |............................
..+--------------+............................
..............................................

Cheers.

[Don't forget to open a tuna can for the kitty]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related