I've never been a fan of generated code. Quite frankly, I would rather type it myself so that I understand what's happening than trust a tool, that is arguably more reliable at creating error free code than myself, to spit out something for me to code against.
Laziness however, is a very important motivator for trying new things. :-) The hesitation at coding against generate code has been overcome in this case by the ease of generation, and also writing several unit tests against the generated API's.
The case in point is I decided to use Oracle's JAXB2 generate support to generate the Java Bean to code against for an XML Schema that I wrote for an in house tool I'm working on. The schema is relatively simple, it contains a set of properties and other random bits of information needed to kick off a process on an iAS server.
Although I know hat the generated Java code will function just fine going from bean to XML document, and back to bean, the Unit test serves as an excellent way for me to tell if a future regeneration of the XML schema will break any of my API's that I'm using to code against the bean. This little tiny bit of security was all I needed, coupled with the fact that it's bloody simple to generate the java class from a XML schema, to finally give in and try a small bit of generated code.
Also, before anyone (read: Alex or Brian) else says it, All code is [more than] slightly better with Unit Tests.
Tuesday, March 20, 2007
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment