Reputation: 3038
I have just starterted using facelets. Please, tell me, what are the advantages of using <ui:fragment>
. Where the differences between using this tag and just paste code in a necessary place?
Upvotes: 1
Views: 2235
Reputation: 346260
<ui:fragment>
, <ui:component>
and <ui:composition>
are the facelets equivalent of methods/functions.
Reusing code via copy/paste bloats your code and makes it unmaintainable, because you end up with dozens of copies of the same code, often with some subtle changes in some of them, and when you discover a bug in that code, you have to find all those dozens of copies and fix it everywhere, and then deal with the bugs when the fix conflicts with some of those subtle changes.
To avoid this, code reuse should happen via methods/functions whenever possible, and differences dealt with via parameters.
Upvotes: 2
Reputation: 43088
The advance is the profit of code reuse. If you decide to change the specific code you won't have to go through all places you ve copypasted the code. Instead you will change it in one place.
Upvotes: 0