Why avoid extension?

What is wrong with the previous implementation? Well, there's nothing inherently wrong with it. However, it can be highly improved. The LoginFormLayout class violates encapsulation! Clients of the class know that a VerticalLayout is used. All public methods of VerticalLayout are exposed to clients of LoginFormLayout. If, for some reason, the implementation needs to change to a different layout (a FormLayout, CssLayout, or even a Panel, for instance), clients calling any method in VerticalLayout that are not in the new base layout class would break.

To the outside world, LoginFormLayout is a Layout. The purpose of a login form is not to serve as a layout (to position other components), but to show the fields that are required to authenticate users with the application. So, let's try to get more encapsulation into the design!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset