You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kishore Subramanian <ki...@agilesoft.com> on 2001/02/15 19:40:28 UTC

Need for a Facade for Data Transformation

Hi Craig,

Thanks for the reply on the ActionServlet design.

Let me take this oppurtunity to thank you and the Struts team at large for the wonderful framework that effectively handles the GUI framework issues.

I had some thoughts on the use of Facades (MartinFowler) between the Action classes and the domain layer (session beans). I wanted to share them with
you to see if Struts offers (will offer) any solution :

I understand that ActionForms lean more towards the GUI than towards the model.  In my opinion, the ActionForms should contain only Strings because
thats what the Presentation layer (JSP) understands. To invoke any methods on the domain layer, these ActionForms should be converted to more
domain-friendly BusinessValueObjects (BVO) that can contain rich data types. The SessionBeans can then work off the BVOs.

Advantages:
1)  The server code can be Unit tested without the GUI. I can write JUnit tests that create BusinessValueObjects with various values of attributes and
call the methods exposed by the SessionBean (domain layer facade). I don't even need the GUI to be ready for me to do this. Once the GUI is developed,
I should (in theory) be able to seamlessly integrate it with the domain layer. 

I can see a need for a "Data Transformation layer" or Facade between the Action and the call to the domain layer. Any thoughts on this ?
On the one side, this Facade takes in the BVOs and creates the string based ActionForms while generating a page. On the way back from the GUI, this
Facade creates the BVOs from the ActionForms. The Facade can maintain a dictionary to convert from the Strings to any form (for instance an Object Id)
that the BVOs need. 

Is there a way to write a generic Facade layer ? 

Thanks,

Kishore Subramanian
Agile Software
Off : 408 999 7128
http://www.agilesoft.com