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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access