Object Oriented
Object Oriented
Patterns
Presented By:
Kanak Khandelwal
Ahmed Ifthaquar Hussain
Overview
About
What it provides
Guide How it helps
Software Designs
Creational
Structural
Behavioral
Overview
e-Milma Shopee
Your Milma goes online
An online shopping cart and in-house
delivery system made to make student's
life easy and pull them out from the tidious
process of standing in queues
What it provides
A list of all prodcuts in the Retail shop
What it Provides
A list of all food items in the Cafe
What it Provides
Efficient Cart System
What it Provides
Final Order Overview
What it provides
Delivery to any location inside the campus
What it provides
Order Tracker
What it provides
Order Tracker
What it provides
An online queue to replace the token system
What it provides
An online queue to replace the token system
Deliverer’s Dashboard
Admin’s Dashboard
Admin’s Dashboard
How it helps
During exams
If you fall sick
https://github.com/Kanak0202/e-Milma-Shopee.git
Software Designs
Software Designs Used
Creational:
Factory Method
Structural:
Decorator
Behavioural:
Chain of Responsibility
State
Creational Design
Pattern
Factory Method
Abstract
Our project employs the Factory Method design pattern to
efficiently manage the creation of different user types. This
pattern centralizes object creation, promoting flexibility and
code reusability. By implementing the Factory Method pattern,
we've streamlined the process of creating Customer, Admin,
and Deliverer users, each tailored to their specific roles.
Implementation
Within our project, the User class acts as the
superclass for different user types. By
implementing a virtual create_user method in the
User class, subclasses such as Customer, Admin,
and Deliverer can override this method to
instantiate objects tailored to their roles.
Factory Classes
Customer, Admin, and Deliverer Classes:
Each subclass overrides the create_user method to initialize
attributes specific to their roles. For instance, the Customer
class initializes customer-related attributes like
roll_no,hostel,room_number while the Admin class sets
administrative privileges, and the Deliverer class configures
delivery-related attributes such as aadhar number and
address.
Factory Classes
Behavioural Design
Pattern
Chain of Responsibility
Introduction
The Chain of Responsibility pattern is a behavioral design pattern where
a request is passed through a chain of handlers. Each handler has the
ability to process the request or pass it to the next handler in the chain.
If a handler cannot handle the request, it delegates it to the next handler
in the chain until the request is processed or the end of the chain is
reached.
Chain of Responsibility
Key Components:
1. BaseHandler Class:
Base class defining the structure for all handlers.
Contains an abstract method, handle_request(), which must be implemented by concrete
handler classes.
2. Concrete Handler Classes:
UsernameValidationHandler: Validates the username provided by the user.
EmailValidationHandler: Validates the email provided by the user.
PasswordValidationHandler: Validates the password provided by the user.
PhoneNumberValidationHandler: Validates the phone number provided by the user.
3. Chain Construction:
Handlers are linked together in a chain.
Each handler holds a reference to the next handler in the sequence.
Chain of Responsibility Steps:
User Registration (Chain_of_Responsibility)
Chain_Of_Responsibility
Chain_Of_Responsibility
State Design Pattern
Introduction
The code separates the behavior of an order into individual state classes,
making it easier to manage and extend the logic for different states. This
pattern promotes modularity, maintainability, and flexibility in handling
the lifecycle of an order in our milma system.
State Design Pattern
Implementation: Step1
unauthenticated_user(view_func):
This decorator checks if the user is already authenticated.
If the user is not authenticated, it redirects them to the home page ('/').
If the user is authenticated, it allows them to access the view.
Usage: Applied to views that should only be accessible to authenticated users,
such as checking out and placing an order.
Decorator
Implementation
allowed_users(allowed_roles):
This decorator checks if the authenticated user belongs to a specific role (group).
It takes a list of allowed roles as an argument.
If the user belongs to one of the allowed roles, it allows them to access the view.
If the user does not belong to any allowed role, it returns an "Unauthorized"
message.
Usage: Applied to views that should only be accessible to users with specific
roles, such as checkout page can be accessed by customer and admin but not by
deliverer.
Decorator
Implementation
admin_only(view_func):
This decorator restricts access to views based on the user's role (group).
It checks if the authenticated user is an admin.
If the user is not an admin, it redirects them to the home page ('/').
If the user is an admin, it allows them to access the view.
Usage: Applied to views that should only be accessible to admin users,
such as administrative dashboard pages.
Thank You