3
I’m doing a work in Java, where we should implement 3 Design Patterns from the software we created earlier.
The software I created is basically a CRUD for movies. In one tab, you add (Insert) and change (update) the records and in the other tab you have a view of the records as follows:
As this work uses database, I’ve used two Design Patterns: Singleton (I read that it is very criticized, etc. but we are only using to learn it) and DAO (I studied it on the internet and managed to implement).
The professor, if I remember correctly, recommended Command, but I went to take a look at it and I couldn’t see a way to fit it into the code. How could I implement it here?
I’ll leave it to anyone who wants to comment because the answer would be too long. Strategy on your DAO, Command<Input, Output> to perform screen actions and Singleton as you said, to recover database connections for example.
– wryel
I think one that would look good would be the MVC.
– Victor Stafusa
So, how would a Command work for the screen actions in this case? I’ll read on MVC and Strategy tbm.
– user25838
The Swing has support to Action (implementation of
Command Pattern
). The classic example is to have an option in the Menu that does the same thing as a certain UI component (e.g., Update / Close, etc).– Anthony Accioly
See that events and listeners are also implementations of Observer Pattern. Window containers and components follow the Composite Pattern. You probably used the Decorator Pattern not knowing when to decorate components with Scrolls... In fact, being absolutely lazy, you can justify that your work is ready simply by having used Swing hehehe.
– Anthony Accioly
Hmm got it. Thanks a lot for the answers, guys.
– user25838