Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I am a relative beginner to programming. I want to take what I have learned and create a simple inventory system, more specifically an asset management system that could track IT hardware types (laptop, workstation, monitor, etc) and then assign values to it. I don't think this should be too difficult but I am stuck on one thing. When using design patterns, I am not sure which ones to use. I think this would be a fun project for me to work on.

I think a decorator pattern would be an obvious one to use. That way I could create an object (laptop for example) and decorate it with brand, OS, RAM, HD size, etc. I could maybe use a factory pattern so that each specific object is encapsulated so that if I am creating (adding) a monitor, I am not requiring the user to add the OS/RAM/HD size etc.

What do you think would be a good selection of patterns for this? Any help or suggestions you could offer would be great.

What I have tried:

Nothing yet as I am still in the planning phases
Posted
Updated 10-Sep-18 7:07am
Comments
Richard MacCutchan 10-Sep-18 12:17pm    
I would suggest getting more experience with the basics before going on to design patterns.
Member 13979315 10-Sep-18 13:23pm    
When I say beginner, I have taken 5 Udemy classes, Object oriented programming in a masters level class as well as algorithms and data structures. So I have the basics down, I am just now learning design patterns and want to put build something out of them.

1 solution

Short answer: Do whatever you want to, just don't over engineer the software, that is becomes a mess to manage and less useful.

The first thing I would ask myself is, who is going to use the software? A consumer on his own machine, or a bunch of users consuming the API, or my web app? So the first thing comes in, is it a desktop app, or a web app?

The patterns you talk about are to create the objects, and then provide them over. That is merely a part of the "inventory management system". You would require a bunch of provider patterns, inversion of control (or dependency injection at least) to decouple the services and modules, that will help you in order to better test the software later on. The service oriented architecture of the application will help you in case you are going to host it on the web app, the services can scale up/down independent of other modules.

java - What is Dependency Injection? - Stack Overflow[^] I remember a really useful library was google/guice: Guice (pronounced 'juice').[^], you can consider checking it out.

Quote:
I could maybe use a factory pattern so that each specific object is encapsulated so that if I am creating (adding) a monitor, I am not requiring the user to add the OS/RAM/HD size etc.
I think you can just select the hardware component from a service or something, that knows what other hardware components relate—if they choose a RAM of 8 GB, go for a 64-bit CPU, 32-bit won't work and much more stuff. Just a factory will not work and might make things complicated, and contain a bunch of if...else, like the one I just mentioned. In this case, a database-like service would be useful that will be able to related the resources and build up the components. It is less about the pattern, more about the business logic.

So, in a nutshell, it is a long list of the patterns that you can check and implement, but remember, only implement if that benefits the software. Do not add every pattern, that will only make it complex.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900