design patterns - Difference between Business Delegate and View Helper -


they seem same thing - seperate presentation tier logic complexities of business tier. difference?

both try separate complexities of components, but:

  • view helper's intent make views lighter (make them display stuff, really);
  • business delegate intends decouple 2 components (leaving details of plumbing work third 1 in between them).

i can see confusion comes from, alike in way. but, in practice, address 2 different issues:

view helper

as systems grow, people tend start putting code on view, jsp, , begins more , more complex. views aren't supposed have lot of code. supposed display data. if put heavy calculation in jsp, instance, on 1 hand code hidden amongst html tags and, on other, can't reuse anywhere in system. imagine having maintenance in code this. you'd go crazy.

view helper teaches way can avoid making views simpler through creation of helper class heavy work , make jsp call instead of keeping complex code inside jsp.

business delegate

when have component, mycalculator, calls external component (say ejb weatherejb) changes lot, end having change component lot too.

think of mycalculator, instance, important class of system, you'll not want change time. if break else? if changing @ branch?

besides, you'll want change mycalculator when your business change, not everytime else changes.

you'll see getting crazier when mycalculator calls ten other components. you'll changing everyday!

business delegate comes rescue advising: add class weatherdelegate can perform calls weatherejb , make mycalculator use instead of calling weatherejb directly.

this way, everytime weatherejb changes, don't need change mycalculator. you'll need edit weatherdelegate accordingly. (also, if someday wish change way weather a, say, web service, once again, you'd have edit weatherdelegate.)

in end...

...they both say: create work you. view helper says don't unecessary work on view; , business delegate tells decouple components, system's responsibilities better distributed. both make system easier maintain.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -