7 Design And Implementation

Software Engineering · Unit 7 · 5 hrs

Design and Implementation

Exam-focused notes for Design and Implementation (Software Engineering, CSC375): what the TU syllabus asks and how it has actually been tested, with 2 solved past questions from this unit.

Design and Implementation in short

Software design turns a system's specification into a structure a program can be built from, and implementation turns that structure into working, delivered code.

Design and Implementation: notes

Introduction

Software design is the stage at which a conceptual, logical model of what the system must do is converted into a physical model of how it will do it; it is the process by which a designer creates a specification of a software system, intended to meet its goals, built from a set of components. Implementation is the process of realising that design as an actual program, transforming the design model, in a systematic, structured way, into a working product.

Object-Oriented Design using UML

Object-oriented design structures software so that its functional components represent objects, each with its own private state and its own operations, rather than a system built purely from stand-alone functions; it involves designing a system's object classes and the relationships between them. Software built from object classes is generally easier to change than software built with a purely functional approach. Although the exact process varies by organisation, common activities in object-oriented design include: defining the context and modes of use of the system; designing the system's architecture; identifying its principal objects; developing design models for those objects; and specifying the interfaces between objects.

What this unit covers

  • Introduction
  • Object-Oriented Design using UML
  • Design Patterns
  • Implementation Issues
  • Open-Source Development

Object-Oriented Design using UML

2081 · 10 marks

Draw use case diagram, class diagram and sequence diagram for online book recommendation system. Make your own assumptions.[10]

Show solved answer

Online Book Recommendation System - UML Diagrams

Assumptions

  • Users can register, login, browse books, and receive recommendations
  • The system recommends books based on user preferences, reading history, and ratings
  • Users can search for books, add them to a wishlist, and rate/review books
  • An Admin manages the book catalog and user accounts
  • The system interacts with an external Payment Gateway for purchases

1. Use Case Diagram

Purpose: Shows interactions between the system and its environment (actors and use cases), focusing on functional requirements and providing an outside view of the system.

+----------------------------------------------------------+
|          Online Book Recommendation System               |
|                                                          |
|   +----------------+      +-------------------------+   |
|   |   Register     |      |   Manage Book Catalog   |   |
|   +----------------+      +-------------------------+   |
|                                          ^               |
|   +----------------+                    | (Admin)        |
|   |   Login        |      +-------------------------+   |
|   +----------------+      |   Manage Users          |   |
|          |                +-------------------------+   |
|          v                                               |
|   +----------------+      +-------------------------+   |
|   |  Search Book   |      | View Recommendation     |   |
|   +----------------+      +-------------------------+   |
|          |                          |                    |
|          v                          v                    |
|   +----------------+      +-------------------------+   |
|   |  Rate & Review |      |  Update Preferences     |   |
|   +----------------+      +-------------------------+   |
|                                                          |
|   +----------------+      +-------------------------+   |
|   |  Add to        |      |  Purchase Book          |   |
|   |  Wishlist      |      +-------------------------+   |
|   +----------------+                 |                   |
|                              <<include>>                 |
|                     +-------------------------+          |
|                     |  Process Payment        |          |
|                     +-------------------------+          |
+----------------------------------------------------------+

   [User] -----> (Register, Login, Search Book,
                  Rate & Review, Add to Wishlist,
                  View Recommendation, Update Preferences,
                  Purchase Book)

   [Admin] -----> (Login, Manage Book Catalog,
                   Manage Users)

   [Payment Gateway] <----- (Process Payment)

Textual Description of Relationships

ActorUse CaseRelationship
UserRegisterAssociation
UserLoginAssociation
UserSearch BookAssociation
UserView RecommendationAssociation
UserRate and ReviewAssociation
UserAdd to WishlistAssociation
UserUpdate PreferencesAssociation
UserPurchase BookAssociation
Purchase BookProcess Payment<<include>>
View RecommendationUpdate Preferences<<extend>>
AdminManage Book CatalogAssociation
AdminManage UsersAssociation
Payment GatewayProcess PaymentAssociation

2. Class Diagram

Purpose: Shows the static structure of the system - the object classes and associations between them, used when developing an object-oriented system model.

+------------------+          +----------------------+
|      User        |          |       Book           |
+------------------+          +----------------------+
| - userID: int    |          | - bookID: int        |
| - name: String   |          | - title: String      |
| - email: String  |          | - author: String     |
| - password: String|         | - genre: String      |
| - preferences:   |          | - ISBN: String       |
|   List<String>   |          | - price: float       |
+------------------+          | - rating: float      |
| + register()     |          +----------------------+
| + login()        |          | + getDetails()       |
| + updateProfile()|          | + getAverageRating() |
| + logout()       |          +----------------------+
+------------------+                   |
        |                              |
        | 1                            | 1..*
        |                              |
        v                              v
+------------------+          +----------------------+
|    WishList      |          |      Review          |
+------------------+          +----------------------+
| - wishlistID:int |          | - reviewID: int      |
| - userID: int    |  1    *  | - userID: int        |
| - bookList:      |<-------->| - bookID: int        |
|   List<Book>     |          | - rating: int        |
+------------------+          | - comment: String    |
| + addBook()      |          | - date: Date         |
| + removeBook()   |          +----------------------+
| + viewWishlist() |          | + submitReview()     |
+------------------+          | + editReview()       |
                              +----------------------+
        |
        | 1
        |
        v
+----------------------+          +-------------------------+
| RecommendationEngine |          |       Order             |
+----------------------+          +-------------------------+
| - engineID: int      |          | - orderID: int          |
| - algorithm: String  |          | - userID: int           |
+----------------------+          | - bookID: int           |
| + generateRecommend()|          | - amount: float         |
| + updateModel()      |          | - status: String        |
| + fetchUserHistory() |          +-------------------------+
+----------------------+          | + placeOrder()          |
        |                         | + cancelOrder()         |
        | uses                    | + getOrderStatus()      |
        v                         +-------------------------+
+----------------------+                    |
|    BookCatalog       |                    | 1
+----------------------+          +-------------------------+
| - catalogID: int     |          |      Payment            |
| - bookList:          |          +-------------------------+
|   List<Book>         |          | - paymentID: int
|                       |          | - orderID: int         |
|                       |          | - amount: float        |
|                       |          | - method: String       |
|                       |          | - status: String       |
|                       |          +-------------------------+
|                       |          | + processPayment()     |
|                       |          | + refund()              |
|                       |          +-------------------------+
+----------------------+

Key Relationships

ClassRelated ClassMultiplicityRelationship
UserWishList1 to 1Composition
WishListBook1 to manyAssociation
BookReview1 to manyAssociation
RecommendationEngineBookCatalogusesDependency
OrderPayment1 to 1Composition

3. Sequence Diagram (Purchase Book Use Case)

Purpose: Shows the time-ordered sequence of messages exchanged between objects to accomplish a specific use case, useful for understanding dynamic, run-time behaviour.

User          BookCatalog       Order         Payment       PaymentGateway
 |                 |               |              |                |
 |--selectBook()-->|               |              |                |
 |                 |--getDetails()-|              |                |
 |<--bookDetails---|               |              |                |
 |                 |               |              |                |
 |--placeOrder()------------------>|              |                |
 |                 |               |--createOrder-|                |
 |                 |               |              |--processPayment()-->|
 |                 |               |              |                |--validateCard()-->
 |                 |               |              |                |<--paymentApproved--
 |                 |               |              |<--paymentResult-|                |
 |                 |               |<--orderConfirmed--             |                |
 |<--orderStatus("Confirmed")------|              |                |                |
 |                 |               |              |                |                |

Flow Description:

  1. The User selects a book, and the system fetches its details from BookCatalog.
  2. The User places an order, which Order creates and forwards to Payment.
  3. Payment calls the external PaymentGateway to validate the card and process the transaction.
  4. On success, the payment result flows back through Payment to Order, and a confirmation is shown to the User.

Summary

The Use Case Diagram captures what the system does from the outside (registering, searching, rating, purchasing, and administering the catalog), the Class Diagram captures the static structure that makes those use cases possible (User, Book, WishList, Review, RecommendationEngine, BookCatalog, Order, and Payment, with their attributes, methods, and relationships), and the Sequence Diagram captures how objects collaborate over time to carry out one specific scenario, purchasing a book, from selection through payment confirmation. Together, these three views give a complete picture of the Online Book Recommendation System's structure and behaviour, which is exactly why UML modelling typically combines a structural view (class diagram), a behavioural/interaction view (sequence diagram), and a requirements view (use case diagram) rather than relying on any single diagram alone.

Open this answer on its own page →

Design Patterns

2081 · 5 marks

What do you understand by design patterns? What role does it have in object oriented design. [5]

Design patterns are typical solutions to common problems in software design. Each pattern acts like a blueprint that can be customized to solve a particular design problem in code. They represent formalized best practices that programmers can use when designing an application or system. Key chara...

Open this answer on its own page →