Friday, July 14, 2006

Significant refactoring comming up.

I'm putting the development of the shipments module temporarily on hold since I came up with a very cool idea that will reduce a lot of the amount of code required in the web commands.

One of the tasks for a web command is to convert the values of the parameters that are comming out from the HttpServletRequest object to their right types. For example a textfield element in a screen module my prompt for a number, when the form is submitted this value is sent to the server side component as an String due to HTTP. The web command then gets this value using the method getParameter(String) and converts it to Integer placing it later in a collection that will contain all the parameters for the required ejb command. This results in writing a lot of code to convert all the non String values to their right types.

By modifying the xsd definition for the input elements to require a type property, their values can be sent in the following way:


Then a single method can parse all the value and convert them using the information provided.

This refactoring effort will eliminate up to 30% of the code that has already been written however it will require modify all the stylesheets to provide the type property in the definition of each input element.

No comments: