2. Solution – Exercise 6.1 (Frameworks)
Chosen Pattern: Factory Design Pattern
Properties of the pattern:
• Define the class of an object at run time.
In our case, the UI component like comboBox are created in run time. If for further cases its
required to use any other component like radio box, we can easily add the class and the class will be loaded
at the run time.
• It also allows to encapsulate object creation so that you can keep all object creation code in one place.
In our case, to create the comboBox we write newComboBox.OrderComponent. If we have to
create the radio box then we will define the newRadioBox.OrderComponent.
• Generally its has a method named factory methods which returns one of several possible classes that
share a common super class.
For our scenario, the name of the method is orderComponent which returns the component as
per as requested.
• It obeys the “DEPENDENCY INVERSION PRINCIPLE” means depend upon abstraction. Do not depend
upon concrete classes.
In this class, the abstraction class is javax.swing.Jcomponent. This class acts as a bridge between
the creator and product.
3.
4.
5. Followed Principles
• HollyWood Principle:
In our code, user will call the calculationOfFree Spaces, and the framework will
automatically call the corresponding class for executing the method.
• Open For Extension but not for modification:
We can extend the code CalculationOfFlat but we can not modify the existing code.
6. Solution – Exercise 6.2 (RESTful Webservices)
1. We edit the ImageResource class in the given prototype application. addImage()
function will receive the image url via GET method. After getting the file path it
stores the file path in the Image object and then save it to the list which was
provided.
8. Publish from the clint
2. We add a publish button in our SWCArchitect interior design application.
That application is act like a client. Client would also verify if publish is successful. A
popup message is shown according to response. In addition, we do some url decoding
and encoding techniques for passing file url via REST.
13. Implement approve and deny
3. We wrote different functions for deny and allow operations and also they have their own
request mapping. Initially when an image is published, it would not be shown in the Home page. Initially
pictures can be seen in admin tab. Then if you allow a picture it is shown in the home page. And also
there is a option to deny the images again. If the application restart the previous published images will
remove.