5187

UML Class Diagram construction

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

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

    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 </li> </ul>

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

    Answer1:

    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]

Recommend

  • Multi Dem php string to array - comma separated, colon separated array
  • Add Quantity Selected to Cart Instead of Just Updating
  • AngularJS: Summing nested objects from multiple objects
  • Join 2 tables on dynamically changing column
  • clang vs gcc CRTP: constexpr variable cannot have non-literal type
  • Eliminate units when using quantities for Python
  • When add include netfilter.h i got error that fields 'in','in6' has incomplete t
  • Best modern way of creating indentation in a ?
  • How to extend Relationship class in neo4django
  • Why shared pointer assignment does 'swap'?
  • Injecting service into a mixin Ember2.3+
  • Rails 3, Custom Actions, and HTML request methods
  • Create a multiple screen android application
  • Javascript unload page condition
  • Run script file on remote server
  • CKeditor stripping font tags instead of converting to span
  • Neo4j: Legacy Indexes and auto index vs new label bases schema indexes
  • XNU incudes in Kext
  • Are there any side effects from calling SQLAlchemy flush() within code?
  • How do I import an existing Grails 3 (3.0.12) project in IntelliJ 15
  • Issue with routerLink directive
  • Compare struct to a constant in C
  • Python cosine function precision [duplicate]
  • vectorized indexing/slicing in numpy/scipy?
  • Rest Services conventions
  • Sequential (transactional) API calls in angular 4 with state management
  • Access Android Market through SSH tunnel
  • Not able to aggregate on nested fields in elasticsearch
  • gspread or such: help me get cell coordinates (not value)
  • How do I exclude a dependency in provided scope when running in Maven test scope?
  • Rails Find when some params will be blank
  • Make VS2015 use angular-cli ng at build time in a .NET project
  • Q promise. Difference between .when and .then
  • Can I have the cursor start on a particular column by default in jqgrid's edit mode?
  • Convert array of 8 bytes to signed long in C++
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Circular dependency while pushing http interceptor
  • Linker errors when using intrinsic function via function pointer
  • C# - Getting references of reference
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET