Skip to content

🐉 Solved problems demonstrating the use of Factory, Singleton and Strategy Design Patterns using Java. These problems were solved during the course "Object Oriented Analysis and Design CS309"

License

Notifications You must be signed in to change notification settings

OSSpk/Factory-Singleton-and-Strategy-Design-Patterns_Examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Examples Demonstrating Factory, Singleton and Strategy Design Patterns 🐉

views Open Source Love svg1 GitHub Forks GitHub Issues contributions welcome

To study more about Design Patterns, visit Source Making Design Patterns

Factory Method

Q1: In a ‘Drawing’ system, depending on user’s input, different pictures like square, rectangle, circle can be drawn. Here we can use factory method to create instances depending on user’s input. For adding new type of shape, no need to change client’s code.

Q2: In travel site, we can book train ticket as well bus tickets and flight ticket. In this case user can give his travel type as ‘bus’, ‘train’ or ‘flight’. Here we have an abstract class ‘AnyTravel’ with a static member function ‘GetObject’ which depending on user’s travel type, will create & return object of ‘BusTravel’ or ‘ TrainTravel’. ‘BusTravel’ or ‘ TrainTravel’ have common functions like passenger name, Origin, destination parameters.

Strategy and Singleton Patterns

Q. You are asked to develop a mobile application for a Famous Shopping Cart system. This application has the option for the user to shop in either an online mode or in an offline mode. If the user is connected to the network, your application would fetch the product list from the server, which will be called by the NetworkManager and if the user is not connected to the server the product list will be fetched from local database using DatabaseManager. You have a product object which contains product id, name and price. The database manager and network manager has one method getProductList which will return array of products.

Note: You will require a global method in your main named bool checkAccessibility() it will return true if internet is connected and false if internet is not connected

Hint: Use singleton and strategy pattern.

How to Run

1- Install these:

2- Open NetBeans IDE. Click on File -> Open Project and browse to the project you want to open say "Factory Method" and select it. It will load the NetBeans project. (There are basically two separate NetBeans Projects named Factory Method and Strategy and Singleton Patterns)


Hey there, I'm Haris Ultimate Facebook Scraper (UFS) - Maker of Things

Creator of Ultimate Facebook Scraper (one of the best software to collect Facebook data for research & analysis)


🌐 Connect

🤝 Consulting / Coaching

Stuck with some problem? Need help in solution development, guidance, training or capacity building? I am a Full Stack Engineer turned Project Manager with years of technical and leadership experience in a diverse range of technologies and domains. Let me know what problem you are facing at haris.muneer5@gmail.com and we can schedule a consultation meeting to help you get through it.

👨‍💻 Technical Skills & Expertise

  • Development of Web Applications, Mobile Applications, and Desktop Applications
  • Development of Machine Learning/Deep Learning models, and deployment
  • Web Scraping, Browser Automation, Python Scripting

❤️ Support / Donations

If you or your company use any of my projects, like what I’m doing or have benefited from my projects in any way then kindly consider backing my efforts.

For donations, you can follow these simple steps:

1) Free signup at TransferWise using this link: https://transferwise.com/invite/u/harism95. (Signing up through this link will save you from any transcation fee on the donation)

2) Select the amount e.g (15$) and choose the receiving/recipient's currency to be PKR. It supports multiple payment options (credit card, debit card, wire transfer etc)

3) Then it will show my info as the recipient, select it. If my name isn't shown, then type my email haris.muneer5@gmail.com in recipients.

4) Choose the reason for transfer to the one that suits you the most (in this case it could be 'General expenses') and in the reference section, you can mention 'Support'

If you face any issue in sending donation then feel free to get in touch with me at haris.muneer5@gmail.com

Thank you for your contribution!

Author

You can get in touch with me on my LinkedIn Profile: LinkedIn Link

You can also follow my GitHub Profile to stay updated about my latest projects: GitHub Follow

If you liked the repo then kindly support it by giving it a star ⭐ and share in your circles so more people can benefit from the effort.

Contributions Welcome

forthebadge

If you find any bug in the code or have any improvements in mind then feel free to generate a pull request.

Issues

GitHub Issues

If you face any issue, you can create a new issue in the Issues Tab and I will be glad to help you out.

License

MIT

Copyright (c) 2018-present, harismuneer

About

🐉 Solved problems demonstrating the use of Factory, Singleton and Strategy Design Patterns using Java. These problems were solved during the course "Object Oriented Analysis and Design CS309"

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages