Creational Pattern: Provide various object creation mechanisms, which increase flexibility and reuse of existing code.
Creational Pattern: Provide various object creation mechanisms, which increase flexibility and reuse of existing code.
###Singleton: Singletonis a creational design pattern that lets you ensure that a class has only one instance, while providing a global access point to thisinstance.
A class will be instantiated to only one object.
230753359671
111229263775504180135103Object1
Class
1125361762900229298581119X
Object2
** Eager loading and lazy loading:
While lazy loading delays the initialization of a resource, eager loading initializes or loads a resource as soon as the code is executed. Eager loading also involves pre-loading related entities referenced by a resource.
###Factory: Factory Methodis a creational design pattern that provides an interface for creating objects in a superclass but allows subclasses to alter the type of objects that will becreated.
If client ask for an object to factory, factory will provide that object, client does not care about how this object will be created.
For example, bothTruckandShipclasses should implement theTransportinterface, which declares a method calleddeliver. Each class implements this method differently: trucks deliver cargo by land; ships deliver cargo by sea.
Structural Pattern: explain how to assemble objects and classes into larger structures, while keeping these structures flexible and efficient.
###FACADE Pattern:
A facade is a class that provides a simple interface to a complex subsystem which contains lots of moving parts.
Suppose the client orders a big task. To complete this task, there are lots of small tasks that need to be done. After completing those small tasks, that big task will be completed. Then the big task will be delivered to the client.
47698946416002799715266861607041258454T1
48942771732510039714992091700
48375632673440039714996334800396467527579001801503124763Client TASKT2
1765963965390371759322619300T3
So, the client does not know whats happening with those small tasks.
So, Faade pattern provides a big common interface, which does big tasks for client.
4292221768600Real Life Example:Water
441505117231200001195070513080219329082553364865857250033578803778250033648653752850031121358832851161415749300
435991026377100Client OrderCoffeeMilk
Coffee
UML:
Adapter: (one type of class make bridge with another type of class)
Adapteris a structural design pattern that allows objects with incompatible interfaces tocollaborate.
Problem: Imagine that youre creating a stock market monitoring app. The app downloads the stock data from multiple sources in XML format and then displays nice-looking charts and diagrams for the user.
At some point, you decide to improve the app by integrating a smart 3rd-party analytics library. But theres a catch: the analytics library only works with data in JSON format.
Solution:
You can create anadapter. This is a special object that converts the interface of one object so that another object can understand it.
Behavioural Pattern: concerned with algorithms and the assignment of responsibilities between objects.
###Strategy:
One day you decided to create a navigation app for casual travellers. The app was centred around a beautiful map which helped users quickly orient themselves in any city.
The first version of the app could only build the routes over roads. People who travelled by car were bursting with joy.
You added an option to build walking routes. Right after that, you added another option to let people use public transport in their routes.
Later you planned to add route building for cyclists. And even later, another option for building routes through all a citys tourist attractions.
The code of the navigator becamebloated.
While from a business perspective the app was a success, the technical part caused you many headaches. Each time you added a new routing algorithm, the main class of the navigator doubled in size.
Solution
The Strategy pattern suggests that you take a class that does something specific in a lot of different ways and extract all these algorithms into separate classes calledstrategies.
The original class, calledcontext, must have a field for storing a reference to one of the strategies. The context isnt responsible for selecting an appropriate algorithm for the job.
Instead, the client passes the desired strategy to the context. In fact, the context doesnt know much about strategies.
It works with all strategies through the same generic interface, which only exposes a single method for triggering the algorithm encapsulated within the selected strategy.
This way the context becomes independent of concrete strategies, so you can add new algorithms or modify existing ones without changing the code of the context or other strategies.
Observer
Imagine that you have two types of objects: aCustomerand aStore. The customer is very interested in a particular brand of product (say, its a new model of the iPhone) which should become available in the store very soon.
The customer could visit the store every day and check product availability. But while the product is still en route, most of these trips would be pointless.
Visiting the store vs. sendingspam
On the other hand, the store could send tons of emails (which might be considered spam) to all customers each time a new product becomes available. This would save some customers from endless trips to the store. At the same time, itd upset other customers who arent interested in new products.
It looks like weve got a conflict. Either the customer wastes time checking product availability or the store wastes resources notifying the wrong customers.
Solution
Publisher notifies subscribers by calling the specific notification method on theirobjects.
Business Requirements Example
The following sections document the various business requirements of this project.
Examples:
NOTES:
Priority: 1 5
1 - Critical
2 - High
3 - Medium
4 - Low
5 Future
Stage: Stage 1 / Stage 2 / Stage 3
Example-1: Non-profit Community Portal
A web-based non-profit organization or community portal that can help manage communication with the members and volunteers in an easy and effective way. Additionally, it also manages inventory of the assets available in the community and let community members order the available products when required. This system helps manage community members (volunteers, paid members, executives, sponsors, and administrators of the system) and provides minimal access as per the requirement of the system users. Some of the basic functionalities of the system are listed below:
The requirements for the system are as follows:
The system shall allow users to register as a member or volunteer and paid members shall be charged as per the amount specified by the community executives.
The system shall allow the registered and active members to login and access the inventory services.
The system shall provide inventory booking and order of the products and it shall provide an option to select the number of days the item is required for. Additionally, all the payments required for the orders shall be processed using the stripe.
The strong password policy, password expiry, password length, etc. should be created. Additionally, easy to use dynamic access management should be created for the system.
The system shall allow administrators to create a new administrator and assign the roles required for the users.
The system shall allow administrators to create and update a roles and permissions as required for each user.
The system shall provide an option to set the required prefix and amount and expiration date required for each membership type.
System shall create backups in a regular basis.
The system shall create an invoice and shall email orders details and invoice attached to the community members.
The system shall allow to create an email group dynamically and email processing and history should be captured.
The system shall provide an address recommendation when registering as a volunteer or members.
Requirement Type ID Prefix ?? ID Number
Function Feature - Requirement Use Case Reference Stage priority Dependencies Comments
Business User Requirements
Uf 0001 The system shall allow new users to into the system as members or volunteers.
UC001 1 1 SF-0001 Members type can be multiple, and it is pre-defined by the administrator of the system.
Uf 0002 The system shall allow registered and active users to login with correct credentials.
UC002 1 1 UF-0001 Members and volunteers with credentials which is not expired.
Uf 0003 The logged in user shall be able to access the inventory services in the system. UC003 1 1 UF-0002 Users should be able to view the available products.
Uf 0004 The system shall allow users to create a booking and order of products. UC004 1 1
UF-0002 Users must be able to add required products in the cart process to checkout.
F 0005 The system shall take payments for the booking using the stripe payment. UC005 2 1 UF-0004 Payment processing should be made using stripe and no credit card information should be recorded.
F 0007 The system shall allow administrator to verify and process the booking. 1 1 All the submitted orders need to be verified by the administrator.
f 0008 The system shall provide an option to add prefix, set amount and expiration date for each membership type. 1 1 Prefix, expiration date and amount for each membership should be dynamic.
f 0009 The system shall create email groups and assign registered and new emails into the group.
2 1 F 0010 The system shall allow administrators to send bulk emails to the email groups. 2 3 Bulk email to users assigned in the group.
Reporting Requirements
Rf 0001 The system shall list all the orders and easy to use search.
1 2 Tables and chart reports should be created for booking and orders.
Rf 0002 The system shall prepare reports for the number of registrations. 2 3 Table and chart reports for registrations. (Monthly and yearly)
Rf 0003 Security Requirements
Sf 0001 The system should not allow users to create password length of less than 8 characters. 1 1 f 0002 The system shall notify newly registered users to change password in first login. 2 2 Newly registered administrator should be notified for password change.
f 0003 The system shall check for the expiry/active status of each member before logging in. 1 1 Access should be blocked for Inactive and expired members/volunteers.
f 0004 The system shall check for the access granted for each administrator while performing operations. 1 2
Granted minimal access needs to be checked before any operations.
F 0005 The system shall record each and every operation performed by the administrator. 1 3 Auditing for each operation for each users needs to be managed.
F 0007 f 0007 f 0008 Service Level/Performance Requirements
Nf 0001 The system shall not take than 3 seconds for each order processing. 3 1 Nf 0002 System shall backup the daily transactions and data during the minimal use time. 2 3 Automatic backups for the important data need to be managed.
Nf 0003 The system shall show the address options automatically. 1 4 Automatic address filling during the registration.
Nf 0004 NF 0005 NF 0007 Nf 0007 Nf 0008 Scalability Requirements
Nf 0001 The system shall be able to handle more than 5000 logged in sessions at a time. 3 3 Nf 0002 Nf 0003 Nf 0004 NF 0005 NF 0007 Nf 0007 Nf 0008 Support and Maintenance Requirements
s 0001 The system shall allow users to report any errors encountered during operations. 2 3 Users should be able to report errors and submit feedbacks when required.
S 0002 The system shall email feedback report to administrators in a regular basis. 3 3 Option to configure feedback messages frequency.
Use Cases Diagram:
Business Requirements Example
The following sections document the various business requirements of this project.
Examples:
NOTES:
Priority: 1 5
1 - Critical
2 - High
3 - Medium
4 - Low
5 Future
Stage: Stage 1 / Stage 2 / Stage 3
Example-1: Non-profit Community Portal
A web-based non-profit organization or community portal that can help manage communication with the members and volunteers in an easy and effective way. Additionally, it also manages inventory of the assets available in the community and let community members order the available products when required. This system helps manage community members (volunteers, paid members, executives, sponsors, and administrators of the system) and provides minimal access as per the requirement of the system users. Some of the basic functionalities of the system are listed below:
The requirements for the system are as follows:
The system shall allow users to register as a member or volunteer and paid members shall be charged as per the amount specified by the community executives.
The system shall allow the registered and active members to login and access the inventory services.
The system shall provide inventory booking and order of the products and it shall provide an option to select the number of days the item is required for. Additionally, all the payments required for the orders shall be processed using the stripe.
The strong password policy, password expiry, password length, etc. should be created. Additionally, easy to use dynamic access management should be created for the system.
The system shall allow administrators to create a new administrator and assign the roles required for the users.
The system shall allow administrators to create and update a roles and permissions as required for each user.
The system shall provide an option to set the required prefix and amount and expiration date required for each membership type.
System shall create backups in a regular basis.
The system shall create an invoice and shall email orders details and invoice attached to the community members.
The system shall allow to create an email group dynamically and email processing and history should be captured.
The system shall provide an address recommendation when registering as a volunteer or members.
Requirement Type ID Prefix ?? ID Number
Function Feature - Requirement Use Case Reference Stage priority Dependencies Comments
Business User Requirements
Uf 0001 The system shall allow new users to into the system as members or volunteers.
UC001 1 1 SF-0001 Members type can be multiple, and it is pre-defined by the administrator of the system.
Uf 0002 The system shall allow registered and active users to login with correct credentials.
UC002 1 1 UF-0001 Members and volunteers with credentials which is not expired.
Uf 0003 The logged in user shall be able to access the inventory services in the system. UC003 1 1 UF-0002 Users should be able to view the available products.
Uf 0004 The system shall allow users to create a booking and order of products. UC004 1 1
UF-0002 Users must be able to add required products in the cart process to checkout.
F 0005 The system shall take payments for the booking using the stripe payment. UC005 2 1 UF-0004 Payment processing should be made using stripe and no credit card information should be recorded.
F 0007 The system shall allow administrator to verify and process the booking. 1 1 All the submitted orders need to be verified by the administrator.
f 0008 The system shall provide an option to add prefix, set amount and expiration date for each membership type. 1 1 Prefix, expiration date and amount for each membership should be dynamic.
f 0009 The system shall create email groups and assign registered and new emails into the group.
2 1 F 0010 The system shall allow administrators to send bulk emails to the email groups. 2 3 Bulk email to users assigned in the group.
Reporting Requirements
Rf 0001 The system shall list all the orders and easy to use search.
1 2 Tables and chart reports should be created for booking and orders.
Rf 0002 The system shall prepare reports for the number of registrations. 2 3 Table and chart reports for registrations. (Monthly and yearly)
Rf 0003 Security Requirements
Sf 0001 The system should not allow users to create password length of less than 8 characters. 1 1 f 0002 The system shall notify newly registered users to change password in first login. 2 2 Newly registered administrator should be notified for password change.
f 0003 The system shall check for the expiry/active status of each member before logging in. 1 1 Access should be blocked for Inactive and expired members/volunteers.
f 0004 The system shall check for the access granted for each administrator while performing operations. 1 2
Granted minimal access needs to be checked before any operations.
F 0005 The system shall record each and every operation performed by the administrator. 1 3 Auditing for each operation for each users needs to be managed.
F 0007 f 0007 f 0008 Service Level/Performance Requirements
Nf 0001 The system shall not take than 3 seconds for each order processing. 3 1 Nf 0002 System shall backup the daily transactions and data during the minimal use time. 2 3 Automatic backups for the important data need to be managed.
Nf 0003 The system shall show the address options automatically. 1 4 Automatic address filling during the registration.
Nf 0004 NF 0005 NF 0007 Nf 0007 Nf 0008 Scalability Requirements
Nf 0001 The system shall be able to handle more than 5000 logged in sessions at a time. 3 3 Nf 0002 Nf 0003 Nf 0004 NF 0005 NF 0007 Nf 0007 Nf 0008 Support and Maintenance Requirements
s 0001 The system shall allow users to report any errors encountered during operations. 2 3 Users should be able to report errors and submit feedbacks when required.
S 0002 The system shall email feedback report to administrators in a regular basis. 3 3 Option to configure feedback messages frequency.
Use Cases Diagram:
Business RequirementsThe following sections document the various business requirements of this project.
Examples:
NOTES:
Priority: 1 5
1 - Critical
2 - High
3 - Medium
4 - Low
5 Future
Stage: Stage 1 / Stage 2 / Stage 3
Example-1: Sales Inventory Management System
A cloud-based inventory management that can help to facilitate both e-commerce or brick-and-mortar establishments. The system should allow access through the website and provide minimal mandatory input and report functions on the android app.
The requirements for the system are as follows:
The system must record the existing stock details and generate easy-to-read online report for the manager level.
The system must alert supervisor-level users of the shortage of the products when the stock is running below par level and provide an option to generate a purchase order for suppliers.
The system must update the inventory upon each sales transaction on the real-time basis.
The system must cater for different warehouses when there are more than 1 warehouse available.
The system should help to predict future demand and generate the yearly forecast report which includes the cost occurring in stocking up the products based on the record of the inventory on the previous year.
The system must store the log report to record all transactions requested or sent by all user levels.
The system must be easy to use and does not allow overwriting of the data.
Requirement Type ID Prefix ?? ID Number
Function Feature - Requirement Use Case Reference Stage priority Dependencies Comments
Business User Requirements
Uf 0001 The system should allow managers to Register new employees into the system.
UC001 1 5 SF-0001 Manager should be able to create new employees.
Uf 0002 The system should allow employees to login with correct credentials.
UC002 1 5 UF-0001 Uf 0003 The system should allow employees to manage products. UC003 1 5 UF-0002 Create, read, and update but should not be able to delete the products.
Uf 0004 The system should allow employees to create new sales order. UC004 1 5
UF-0002 F 0005 The employees should be able to generate new invoices for the sales.
UC005 2 3 UF-0004 F 0007 f 0007 f 0008 Reporting Requirements
Rf 0001 The system should give the total number of registered users in real time.
1 3 Rf 0002 The system should provide overall daily, monthly, and yearly sales report in dashboard. 2 3 Rf 0003 f 0004 F 0005 F 0007 f 0007 f 0008 User Access/Security Requirements
Sf 0001 The system should not allow users to create password length of less than 8 characters. 1 1 f 0002 f 0003 f 0004 F 0005 F 0007 f 0007 f 0008 Service Level/Performance Requirements
Nf 0001 The response time of a system should note be more than 3 seconds for each payment transactions. 3 1 Nf 0002 Nf 0003 Nf 0004 NF 0005 NF 0007 Nf 0007 Nf 0008 Scalability Requirements
Nf 0001 The system should be able to handle more than 1000 sessions at a time. 3 3 Nf 0002 The system should allow employees to create more than 10 orders in a minute. 3 2 Nf 0003 Nf 0004 NF 0005 NF 0007 Nf 0007 Nf 0008 Support and Maintenance Requirements
s 0001 S 0002 S 0003