0% found this document useful (0 votes)
78 views19 pages

SWE30003 Ass2 Group1

The document outlines the object-oriented design for an Online Healthy Foods Store, focusing on creating a software architecture based on Responsibility-Driven Design principles. It includes a comprehensive analysis of user needs, candidate classes, and their interactions, as well as design heuristics and patterns to ensure quality and scalability. The design aims to facilitate efficient management of inventory, orders, and user accounts while providing a user-friendly online shopping experience.

Uploaded by

huyquangph2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views19 pages

SWE30003 Ass2 Group1

The document outlines the object-oriented design for an Online Healthy Foods Store, focusing on creating a software architecture based on Responsibility-Driven Design principles. It includes a comprehensive analysis of user needs, candidate classes, and their interactions, as well as design heuristics and patterns to ensure quality and scalability. The design aims to facilitate efficient management of inventory, orders, and user accounts while providing a user-friendly online shopping experience.

Uploaded by

huyquangph2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

SWE30003

ASSIGNMENT 2

Online Healthy Foods Store


Group 1:
Nguyen Cuong Nhat
Nguyen Dang Duc Anh
Vuong Khang Minh
Phan Huy Quang
Contents
Introduction ....................................................................................................................................... 3
Problem .............................................................................................................................................. 3
Assumptions....................................................................................................................................... 4
Problem Analysis ............................................................................................................................... 5
Simplifications ................................................................................................................................... 5
Candidate Classes .................................................................................................................................. 6
Candidate class list ............................................................................................................................. 6
UML Diagram .................................................................................................................................... 7
Justification........................................................................................................................................ 7
CRC Cards .......................................................................................................................................... 8
Design Quality ......................................................................................................................................13
Design Heuristics ..............................................................................................................................13
Patterns ............................................................................................................................................ 14
Bootstrap Process .................................................................................................................................15
Verification .......................................................................................................................................... 16
Reference ............................................................................................................................................. 19

Assignment 2 2
Executive Summary
This document presents the object-oriented design for the Online Healthy Foods Store, building upon
the case study introduced in Assignment 1. The objective is to formulate an initial software
architecture that aligns with the principles of Responsibility-Driven Design. The design aims to
establish a robust foundation for the subsequent detailed design and implementation in Assignment
3. Throughout this document, a comprehensive list of candidate classes, their interrelationships, and
the bootstrap process for initializing the Online Healthy Foods Store are delineated. The use of CRC
cards facilitates a detailed exploration of each class, outlining their responsibilities and collaborators.
Additionally, the design solution is subjected to critical evaluation in terms of its quality, adherence to
design heuristics and patterns, and fulfillment of system responsibilities. This executive summary
provides a succinct overview of the subsequent sections, offering a glimpse into the holistic approach
adopted in crafting the object-oriented design for the Online Healthy Foods Store.

Introduction
The introduction sets the stage by revisiting the case study introduced in Assignment 1, emphasizing
the need for a meticulous design of the Online Healthy Foods Store. In addressing the complex
requirements of the food retailer, this assignment endeavors to provide an initial object-oriented
design that adheres to the principles of Responsibility-Driven Design. The document outlines the
overarching problem addressed, namely, the formulation of a coherent and effective software
architecture for the Online Healthy Foods Store. The outlook of the solution involves a strategic
identification of candidate classes, their responsibilities, and the interplay between them.

Problem
The Online Healthy Foods Store faces the challenge of establishing an online presence that facilitates
the purchase of healthy food items while ensuring efficient management of inventory, orders, and
user accounts. The system must accommodate the diverse needs of users, ranging from browsing
products to placing orders, while also providing administrators with tools to oversee operations and
maintain the integrity of the platform.

Outlook of Solution
The solution involves the meticulous design of classes and their interactions to encapsulate the core
functionalities of the Online Healthy Foods Store. By adopting Responsibility-Driven Design
principles, the aim is to identify the key responsibilities of each class and define clear collaborations to
ensure seamless integration and operation of the system. The design solution emphasizes modularity,
scalability, and flexibility to accommodate future enhancements and changes in user requirements.
Additionally, it leverages UML diagrams and CRC cards to provide visual representations and detailed
descriptions of the system components, aiding in the understanding and communication of the design
to stakeholders.

Assignment 2 3
Assumptions
In formulating the object-oriented design for the Online Healthy Foods Store, several assumptions
underpin the decision-making process. These assumptions serve as foundational elements to
streamline the design approach and provide clarity to stakeholders.

1. User Interaction: The design assumes a reasonable level of user familiarity with online
shopping interfaces. Basic user navigation skills and an understanding of standard e-commerce
practices are anticipated.

2. Data Security: It is assumed that the Online Healthy Foods Store will operate in a secure digital
environment. Basic security measures, such as data encryption and secure user authentication,
are presumed to be in place.
3. Unique Identifiers: Each product has a unique identifier within the system for tracking and
management purposes.
4. Product Attributes: All products are characterized by essential information such as name,
description, price, availability, and quantity.
5. Sales Cycle: Products may undergo various transactions, including purchases by customers,
returns, and subsequent resale.
6. Sales Transaction Specifics: Each product sale involves one product, one invoice, one customer,
and one salesperson.
7. Customer Information: Customers are required to provide necessary details like name,
address, and contact information for order processing and communication.
8. Customer Identification: New customers receive a unique customer ID upon their initial
purchase.
9. System Registration: All entities, including customers, salespersons, products, orders, and
payments, are registered within the system.
10. Customer Details: Each customer account includes a unique ID, name, address, and contact
information.
11. Return Policy: Customers can initiate returns or exchanges for products, subject to predefined
return conditions.
12. Product Availability: A product may be available in both new and used conditions, depending
on supplier inventory and condition.
13. Sales Volume: The system accommodates a substantial volume of daily transactions, reflecting
the popularity of healthy food choices.
14. Product Condition: Products are categorized as new or used based on supplier sourcing and
inventory status.
15. Payment Terms: Customers can choose from various payment options, including upfront
payments, instalments, or payment upon delivery.
16. System Security: The system operates within a secure environment, ensuring the
confidentiality and integrity of customer and payment information without the need for
extensive encryption measures.

Assignment 2 4
Evidence of Problem Analysis

Problem Analysis
The object-oriented design presented for the Online Healthy Foods Store incorporates a robust
problem analysis, demonstrating a comprehensive understanding of the challenges and requirements
outlined in the case study. The submission delves into the intricacies of the problem domain, ensuring
a thoughtful and informed approach to the design solution.

1. User Needs and Behaviors: The analysis begins by identifying and analyzing the needs and
behaviors of potential users of the Online Healthy Foods Store. This includes considerations
such as user preferences, shopping habits, and expectations from an online healthy food
platform.

2. System Functionality: A detailed examination of the required functionalities is conducted,


encompassing aspects such as product browsing, order placement, payment processing, and
user account management. This ensures that the design aligns with the core objectives of the
Online Healthy Foods Store.

3. Integration of Design Elements: The submission illustrates a thoughtful integration of design


elements to address the complexities of an online food retail platform. It considers the
seamless interaction between different components to create a cohesive and user-friendly
system.

Simplifications
To streamline the design process and manage complexity, certain simplifications were made during
the problem analysis phase. These simplifications are strategic decisions aimed at ensuring a focused
and achievable design within the given constraints.

1. Payment Processing: The analysis acknowledges the complexity of real-time payment


processing systems. To simplify the initial design, a secure payment gateway abstraction is
assumed, deferring detailed implementation considerations to subsequent design phases.

2. Product Categorization: While recognizing the potential diversity of products in an online


healthy foods store, the design simplifies the categorization process, initially focusing on
broader categories and allowing for future refinement.

3. User Authentication: A simplified user authentication process is assumed initially, with


standard username-password mechanisms. Advanced authentication features, such as multi-
factor authentication, are considered for subsequent design iterations.

By documenting these simplifications, the design maintains transparency regarding the chosen focus
areas and provides a clear rationale for deferring certain complexities to later stages of the design
process.

Assignment 2 5
Candidate Classes
Candidate class list
1. Product
2. Account
3. Order
a. CompletedOrder
b. CanceledOrder
4. ShoppingCart
5. User
6. Invoice
7. Receipt
8. Payment
9. Catalog
10. SaleStatistics

Managers:
11. CatalogManager
12. ProductManager
13. InventoryManager
14. ShoppingCartManager
15. AccountManager
16. Administrator

Processes:
17. Shipment
18. Refund

Services:
19. NotificationService
20. AuthenticationService

Assignment 2 6
UML Diagram

Figure 1: UML Diagram

Justification
The chosen classes represent the core components of an e-commerce system, each fulfilling a crucial
role in ensuring its functionality and efficiency. The ‘‘Product’‘ class serves as the cornerstone,
encapsulating essential information about items available for sale. ‘‘Order’‘, ‘‘CompletedOrder’‘, and
‘‘CanceledOrder’‘ handle transactional aspects, tracking purchases, and providing necessary details
for order management and reporting. The ‘‘ShoppingCart’‘ class facilitates the user's shopping
experience by managing selected items and calculating costs. ‘‘User’‘ and ‘‘Administrator’‘ classes
oversee user-related processes and system administration, respectively, ensuring smooth operations.
‘‘InventoryManager’‘ and ‘‘ProductManager’‘ handle inventory and product-related tasks, ensuring
accurate representation and availability of products. ‘‘Invoice’‘, ‘‘Payment’‘, and ‘‘Receipt’‘ classes
manage financial transactions, documenting purchases, and providing users with transaction details.
‘‘StatisticsReport’‘ offers insights for decision-making based on collected data. ‘‘UserManagement’‘
and ‘‘AuthenticationService’‘ ensure proper user access and authentication. ‘‘NotificationService’‘
keeps users and administrators informed about system events, while ‘‘Refund’‘ manages refund

Assignment 2 7
processes. ‘‘Shipment’‘ tracks shipping details, and ‘‘Catalog’‘ provides comprehensive product
listings. Finally, ‘‘CatalogManager’‘ oversees catalog operations, ensuring accurate product
representation. Together, these classes form the backbone of an e-commerce system, enabling
seamless user experiences and efficient system management.

CRC Cards
Class Name: Product
Super Class: -
Represents a product available for sale in the system. Stores essential information
about the product, such as its name, description, price, and quantity. Manages
product data and attributes to facilitate sales and inventory management.
Responsibilities Collaborators
Knows name, description, price,
availability and quantity
Knows product status and attributes ProductManager

Class Name: Order


Super Class: -
Represents a customer's order in the system. Manages order details such as order items,
total price, and status throughout the ordering process.
Responsibilities Collaborators
Knows order ID, customer ID, order date, Invoice, NotificationService
delivery address, payment method and
status.
process of a user ordering a product User
online.

Class Name: CompletedOrder


Super Class: Order
Represents an order that has been successfully completed. Manages order details such
as delivery status, completion timestamp, and statistical data for reporting purposes.
Responsibilities Collaborators
Knows delivery status and completion Shipment
timestamp

Class Name: CanceledOrder


Super Class: Order
Represents an order that has been canceled. Manages order details such as cancellation
reason and cancellation timestamp.
Responsibilities Collaborators
Knows payment status and cancellation Refund
timestamp.

Assignment 2 8
Class Name: ShoppingCart
Super Class: -
Represents a shopping cart in the system. Stores items added by the user for potential
purchase and manages items in the cart. Calculates the total price of items in the cart.
Responsibilities Collaborators
Stores items added by the user for Product
potential purchase
Manages items in the cart and calculates User
the total price

Class Name: Account


Super Class: -
Represents an account within the system. Stores user credentials, preferences, and
permissions.
Responsibilities Collaborators
Knows username, password, idss and User, Administrator
permissions.

Class Name: User


Super Class: Account
Represents a user of the system. Manages user information such as name, email, and
address.
Responsibilities Collaborators
Knows name, email, and address. UserService

Class Name: Administrator


Super Class: Account
Represents an administrator of the system. Manages system administration and user
roles.

Responsibilities Collaborators
Manages system administration. System

Class Name: InventoryManager


Super Class: -
Oversees tasks concerning inventory operations within the system, including
inventory monitoring, replenishment, and modifications.
Responsibilities Collaborators
Handles inventory tracking, restocking, Administrator
and adjustments

Assignment 2 9
Class Name: ProductManager
Super Class: -
Manages responsibilities related to inventory management within the system, such as
monitoring inventory levels, restocking, and making adjustments as necessary.
Responsibilities Collaborators
Handles product creation, modification, Administrator
and deletion
Manages product data and attributes Administrator

Class Name: ShoppingCartManager


Super Class: -
Oversees the management of shopping carts in the system, including the creation,
updating, and deletion of carts.
Responsibilities Collaborators
Facilitates the creation, updating, and Administrator
deletion of shopping carts.

Class Name: Invoice


Super Class: -
Handles the creation of invoices for orders placed in the system. An invoice includes
essential details such as the order ID, customer information, and an itemized list of
products.
Responsibilities Collaborators
Generates invoices for orders Order

Class Name: Payment


Super Class: -
Represents a payment transaction associated with a specific order
Responsibilities Collaborators
Knows payment method, amount, and
transaction status

Class Name: Receipt


Super Class: -
Represents a receipt document for completed transactions within the system.
Responsibilities Collaborators
Generates a receipt document for Payment
completed transactions
Includes details such as transaction ID,
purchase details, payment method, and
transaction timestamp

Assignment 2 10
Class Name: SaleStatistics
Super Class: -
Represents a class responsible for providing statistical data and insights about orders
and sales within the system.
Responsibilities Collaborators
Generates statistical reports based on the Order
collected data

Class Name: AccountManagement


Super Class: -

Encapsulates functionality related to the management of accounts within the system.


Responsibilities Collaborators
Create new accounts, update account Account
information

Class Name: AuthenticationService


Super Class: -
Handles user authentication and access control within the system. Manages login and
authentication processes.
Responsibilities Collaborators
Manages user authentication, including Account
login and logout functionality.

Class Name: NotificationService


Super Class: -
Manages the sending of notifications regarding various events within the system.
Responsibilities Collaborators
Sends receipt notifications to users after a Receipt, User
successful transaction, containing details
of the purchase and payment
Sends delivery status notifications to Shipment, User
users, updating them on the status of
their order shipment
Sends notifications to administrators Order, Administrator
when a new order is created, providing
details of the order for processing
Sends refund information notifications to Refund, User
users, informing them of refunds
processed for their orders

Assignment 2 11
Class Name: Refund
Super Class: -
Manages the refund process for canceled orders, ensuring that users receive
appropriate refunds for their canceled purchases.
Responsibilities Collaborators
Initiates refund transactions for canceled CanceledOrder
orders.

Class Name: Shipment


Super Class: -
Represents the process of shipping orders to customers, managing delivery details
and tracking information.
Responsibilities Collaborators
Tracks the status of shipments, including
shipping carrier information and delivery
updates

Class Name: Catalog


Super Class: -
Represents a collection of products available for sale, providing functionalities for
browsing and searching products within the system.
Responsibilities Collaborators
Contains product listings within the Product
catalog, providing detailed information
about each product
Allows users to browse and search the User
catalog to find desired products.

Class Name: CatalogManager


Super Class: -
Manages the operations related to the product catalog, handling tasks such as product
addition, modification, and removal.
Responsibilities Collaborators
Adds new products to the catalog, Administrator
including specifying product details and
assigning them to appropriate categories.

Updates existing product information, Administrator


such as price, description, and availability
status.

Removes products from the catalog that Administrator


are discontinued or no longer available
for sale.
Automatically assigns new categories to Product
products.

Assignment 2 12
Design Quality
Design Heuristics

Heuristic Class Details

Single Responsibility Administrator Each class is responsible for only a type of


Principle (SRP) User account, avoiding creating a “god class”

Description: CompletedOrder Each class is responsible for only a type of order,


Each class should only CancelledOrder avoiding creating a “god class”
has one responsible or
concern

Open/Closed Principle Account User and Administrator all derived from Account,
(OCP) Administrator so if we want to add a new functionality, such as
User Manufacturer (in case there is a third party that
Description: want to sell their product through the system),
Classes are open for then this class is a newly added one, deriving
extensions through from Account, and we don’t have to modify
addition of classes, but existing classes
not modification of
existing classes

Liskov Substitution Account Administrator and User all derive from Account,
Principle (LSP) Administrator and they keep the behavior of the base class:
User require authentication to login and manage
Description: content of that account. However the subclass
Derived class can be have extended features, for example the
extended from base Administrator can manage
class without changing ShoppingCartManager class and interact with the
behavior, affecting the System class
program or system
Order CompletedOrder and CancelledOrder all derived
CompletedOrder from Order, and have similar behavior such as
CancelledOrder being able to trigger NotificationService.
However, the CancelledOrder have an extension
of being able to trigger Refund.

Interface Segregation Order CompletedOrder and CancelledOrder all derived


Principle (ISP) CompletedOrder from Order, they all include methods to trigger
CancelledOrder notification to customer and administrator.
Description: However, only CompletedOrder will trigger
When deriving from a Shipment and only CancelledOrder will trigger
base class, unused Refund
functionality will not be
included

Assignment 2 13
Dependency Inversion Account The AuthenticationService and
Principle (DIP) Administrator AccountManagement interfaces is dependent on
User the base class Account instead of its 2 subclasses
Description: AuthenticationService Administrator or User.
High-level modules AccountManagement
should depend on
abstractions, instead of
details

Don't Repeat Yourself ShoppingCart The ShoppingCart is an entity responsible for


(DRY) User containing products. It is also reused as an entity
Product responsible for storing all the products that the
Description: Order customer buy. Moreover, it is reused to help
Reuse code, generate the cost that customer have to pay in
components, extracted Order.
functionality
Invoice The NotificationService class is reused to trigger
Receipt notification to Accounts in each oth the Invoice,
Payment Receipt, Payment
NotificationService

Law of Demeter (LoD) ShoppingCart User does not directly access the Products, but it
User access through the List<Product> attribute of the
Description: Product ShoppingCart class.
Interactions with
neighbor components
to avoid complex
coupling

Separation of Concerns Invoice The aspect of the software is separated into


(SoC) Receipt different aspects:
Description: Separate Payment • Payment roles:
different aspects of Statistics Report o Invoice
software into distinct Product o Receipt
modules or layers. Catalog o Payment
• Selling, advertising:
o Product
o Catalog
• Business report:
o Statistics Report

Encapsulation All classes All data unique to a class should be kept hidden
inside of that class.

Patterns
Strategy Pattern

Assignment 2 14
AccountManagement and AuthenticationService are the 2 interfaces implemented to the ‘’Account’’
base class, which means that the 2 derived classes ‘’Administrator’’ and ‘’User’’ will be given specific,
different way of behaving.

Factory method design pattern

This approach allow the creation of a range of subclasses with a lot of commonalities by reusing the
methods and classes, while also allowing each subclass to have extended features:
• The ‘’CompletedOrder’’ and ‘’CancelledOrder’’ inherit their relationship with
‘’NotificationService’’, ‘’User’’, ‘’ShoppingCart’’,.. From the ‘’Order’’ class, but also having
specific relationship: Association with ‘’Shipment’’ class for ‘’CompletedOrder’’ and ‘’Refund’’
class for ‘’CancelledOrder’’ class.

Singleton design pattern

This approach ensures that a class has only one instance and provides a global point of access to that
instance. This facilitates controlled access, reduces memory occupation, and only require initialization
for once. For example, there is only 1 instance of the ‘’Catalog’’ class.

Observer Pattern

The Observer Pattern is exemplified by the ‘NotificationService’ class within the system architecture.
Acting as a subject, ‘‘NotificationService’‘ notifies observers, such as users and administrators, of
system events like successful transactions and order status updates. In adherence to the Observer
pattern, observers subscribe to receive notifications from the subject, ‘‘NotificationService’‘, and are
subsequently informed when relevant events occur.

Bootstrap Process

This bootstrapping process reflects the initialization and interaction of various


components in an online healthy food store system.

• Main creates instances of CatalogManager, ShoppingCartManager, and UserManagement.


• ShoppingCartManager creates an instance of ShoppingCart for each user.
• CatalogManager creates an instance for each Product (healthy food item).
• ShoppingCart adds or removes Product based on user actions.
• Main creates an instance of SalesInvoice when a user checks out.
• SalesInvoice creates an instance of Payment for the transaction.
Assignment 2 15
• SalesInvoice creates an instance of Receipt for transaction confirmation.

Verification
The proposed approach was validated by simulating many use cases indicated below.

Add new products to the catalogue

The system begins with the administrator querying available products. Upon request, the Product
integrates with the Inventory Manager. Admin then interacts with the Product Manager to add and
retrieve product descriptions. Following this, Admin categorizes products with the Catalog Manager.
Depending on uniqueness, the Catalog Manager either employs machine learning for categorization
or assigns existing categories. If matched, tags are bound to the product.

Assignment 2 16
Generate sale statistical report

The system facilitates online access for a healthy food store's admin to retrieve sales reports. Upon
request, the Sales Statistic module prompts the system's Authentication Service for authentication.
The admin provides credentials, and the system either grants or denies access. Once authenticated,
the Sales Statistic module generates and delivers the requested sales report to the admin.

Tracking Order

The system facilitates online ordering for a healthy food store. Users can retrieve their completed
orders and monitor them. Upon request, the system interacts with a shipment service to obtain
delivery status information. Finally, it delivers the updated delivery information back to the users.

Assignment 2 17
Create a new user account

The system facilitates the online registration process for customers interested in accessing the healthy
food store's services. Upon registration, it verifies the uniqueness of provided contact numbers. If a
number is already in use, it prompts customers to provide an alternative. Once a unique number is
obtained, the system proceeds to create the account and prompts users to fill out their profiles.

Assignment 2 18
Processing payment

The user starts by creating a shopping cart. An order is then generated from the items in the shopping
cart. The user then initiates payment for the order. If the payment is successful, an invoice is created,
followed by the generation of a receipt, which is then returned to the user.

Reference
- Hanmer, Robert S. Pattern-oriented software architecture for dummies. John Wiley & Sons, 2013.
- Clements, P. C. (2002). Software architecture in practice. Diss. Software Engineering Institute.
- Rohnert, H. (1996). {Pattern-Oriented} Software Architecture. In 2nd USENIX Conference on
Object-Oriented Technologies (COOTS 96).

Assignment 2 19

You might also like