Theory, Coding script and system design activities

UML

During my study, I had to create many UML design (Unified Modelling Language).

This activity for this unit involves me putting my object-oriented design skills into practice. My first attempt was to design a supermarket model. The purpose of this activity was to demonstrate my understanding of new concepts such as classes, inheritance, composition and how they link together.

That diagram was my first trial. It is important to consider all the different kind of interactions between all the actors. With more and more practice, it will become easier to make a logical design.

The first connection possible is an association. It is a relationship between 2 objects where there is no particular ownership in place ('HAS A' relationship). Another 'HAS A' relationship is called aggregation. It is a form of association which has a 'use' connection. If the parent class would be destroyed, the child could still exist independently (weak 'HAS A' relationship).
The last one is a Composition. It is a stronger form of aggregation that implies an ownership, where the child class is dependent completely to the parent class. (strong 'HAS A' relationship)

As a practical exercise, I had to develop UML diagrams for a doctor’s surgery based on the following scenario:

Before a patient can see a doctor, or nurse, they will be required to make an appointment. The appointment will be made by the receptionist. However, before making the appointment, the receptionist needs to ask the patient which doctor they would like to see, and whether the appointment is standard consultation or an emergency appointment. The receptionist will use this information to check the appointment schedule, find an available appointment and make the booking. During the appointment itself, the doctor may issue the patient with a prescription. It is possible for a patient to request a repeat prescription be raised. Receptionists are able to cancel appointments as well as create them. A doctor at the clinic may have a maximum of 500 patients registered to them at any one time.
I had to design:

  • A class diagram for the system
  • A sequence diagram for booking an appointment
  • An activity diagram for a receptionist booking an appointment
  • After the practice, comes the real first assignment of this module, I had to design a UML class diagram for an online store. One of the challenges was to meet all the business requirements.

    The UML class diagram for the online store has 16 classes:

    The main class is the User.

  • User
  • Customer
  • Administrator
  • Website
  • Shopping cart
  • Order
  • Warehouse
  • Payment
  • Shipping
  • Delivery Company
  • The class Customer and Administrator inherit from the User class in order to stay DRY (Don’t Repeat Yourself) with the code and avoid repetitions.
    The same way the class Website and seller inherit from the Administrator class.

    There are 2 different kind of administrators:

  • The website itself, who can manage and access the entire online store features in addition of selling his own items on his own shop.
  • The seller, who can manage only his own shop, add products, delete products, update the price, modify the layout.

  • All classes have their own attributes and methods.
    The Customer can select 0 or many Items. Item can have 0 or many customers. There is a relation between those 2 classes (Association between Customer class and Item class).

    There are 2 composition relations connected to the class Customer with the class:
  • Order
  • Shopping cart

  • If the customer deletes his account, the order and his shopping cart will be deleted as well. (Strong relationship between those 3 classes)
    Order class can have only 1 customer. Customer can have 0 or many orders. Same multiplicity for the shopping cart class. From the Order class, there are 2 composition relations with the class Shipping and Payment.
    If there is no order, the shipping and payment does not exist. (Strong relationship between those 3 classes) The Warehouse class has one aggregation relation with the Order class. Even though there is an order or not, the Warehouse still exist. The Warehouse class has an association relation with the database class.

    For the activity diagram, the user starts by visiting the website and then browsing some items. The user can view the item and if he/she likes, can select the quantity and add the item to the basket. If not, he/she can leave the website or come back to the main page and continue browsing. When shopping is done, he/she select the payment method, enter details and confirm the order. The order can be approved or cancelled. The last scenario would be, he/she abandons the shopping cart.

    Here you can find the UML diagram

    Databases

    Data is today's new oil in terms of its value and importance. A database is a systematic collection of data. The data in a database is organized and makes data management easier. A DBMS (Database Management System) is a collection of programs which enables its users to access database, manipulate data, and help in representation of data. It can also control access to the database by various users.

    Database is made of 3 things:

  • Entities: Tables
  • Attributes: Columns (Variables)
  • Relationships: 2 entities might be joined together
  • Attributes describe the different characteristics of an entity. Each row corresponds to a different instance of an entity.

    At this stage of the module, I am going through all the fundamental aspects of database design with a focus on normalisation.

    In 1970, Edgar Codd defined 3 rules for organizing the data in a database called Normalisation rules. It helps to reduce redundancy and improve the integrity of our data. After going all through the theorical part, I had to develop a table structure that conforms to third normal form (3NF).

  • Existing table structure:

  • Properties Table: Street, Postcode, Type, Bedrooms, Owner name, Owner address, Owner telephone, Price, Client name, Client Date of Birth, Client telephone, Rental start date, Duration, Pets allowed, Deposit amount, Deposit paid,
    Maintenance Table: Street, Postcode, Owner name, Owner telephone, Tenant name, Tenant telephone, Issue, Contractor name, Contractor telephone, Estimated cost, Resolved

    Here is my diagram of a relational database structure after applying the 3 rules of Normalisation.