Contract-First Development

Contract-First Development (also known as Design by Contract), is a programming approach that, in the age of web services, starts with the schema used in a data exchange, and design the application from there.

I am currently using the same approach in a new personal project. As mentioned in my previous post, I am working on a prototype for an SCSF application, a Resume Builder application built on top of HR-XML standards.

I downloaded the XSD files and worked on creating the entity classes and database schema out of them. The specifications are long, so instead of doing them by hand, I decided to look for tools. For the entity class generation, I used Microsoft’s XSDObjectGen, a sample code generator for creating serializable classes from XSD schemas. For the DDL generation, I downloaded an evaluation version of the Altova XMLSpy, quite a powerful xml developer tool.

Both did a good job in rendering the XSD schemas. The problem I have, though, is that the schemas are so normalized, to the point that types that should have been, for us humans, simple enough, are rendered as separate classes and tables, like Entity ID or phone numbers. I don’t see the sense of keeping them that way as it will take a lot of connectors, even if I used an ORM like NHibernate, and it will also be slow and inefficient on the database.

I am now faced with the following choices: (1)  Use a much simpler Resume schema like the XML Resume Library at Sourceforge; (2) Stick with the HR-XML schema, but code the entity classes and create the database structure from scratch manually; (3) Derive a simpler schema by taking out the normalized “simple” entities such as IDs and phone numbers and replacing them with strings - not so trivial a task as there are many throughout the entire structure; or (4) Clean up the resulting entity classes and database structure.

I have not yet decided which one to take. I am hesitant to go for Option 1 because HR-XML is an industry standard, and though large job sites like Monster.com don’t use it, there is a growing clamor to get them to adopt it. Besides, the XML Resume Library at Sourceforge has been left unupdated since 2004, probably because of the popularity of HR-XML. Option 2 is simply a lot of work. I am deciding between Option 3 and Option 4, depending on which one will be easier to do. Either one violates the XSD contract and will take some intermediate processing before the serializer can generate XML that’s 100% compatible with the schema.

Oh by the way, with regards to database generation, there’s one more issue with using Altova XMLSpy for this purpose. Because container datatypes contain the datatype itself and not a reference value like a key, the rendered tables will not have foreign keys. The relational feature of AltovaXMLSpy’s database generator will only present you with the types’ simple child types. (I believe there SHOULD be a feature that automatically creates an ID field, or identify one. There should also be intelligence in looking at relationships and deciding whether intermediate tables are necessary - ah wishful thinking.) The workaround here is probably to either violate the schema (again) by replacing the contained child types with IDs or manually add the references after the tables have been generated. I’d probably go with the latter. (Given the normalized nature of the schema, this is probably going to be almost like creating the database structure from scratch.)

Any suggestions for a better approach or a better tool (.Net for entity class generation) will be very much welcomed.

Update 02/24/2008 5:11pm

After looking through the generated .cs file and the database tables, and reading in forums, I have decided to start off with a simple structure that is loosely based on the HR-XML schema and go ahead with the development.

(I gave up when realizing that the class structures and tables are too different from each other for me to try to fix it - Option 4 as mentioned above. The class structures contained too many collection objects and enums, and the latter eliminated key information like relationships. The difficulty with dealing with the generated output also eliminates the use of tools, so modifying the schema and doing Option 3 is out.)

I also discovered that HR-XML is coming out with a more streamlined Resume.xsd version 3.0, taking out all the deprecated content in 2.* versions that have been kept for backward compatibility. They will also de-layer structure to make it XML form-tool friendly.

Check out recent developments:
http://docs.hr-xml.org/resources/HR-XML-Resume_final.pdf
http://docs.hr-xml.org/resources/HR-XML-3-0-webinar.ppt

So, it’s set. I am going to instead have my structure and create a transformation utility that will generate a compliant XML file. It will also allow for the generation of other formats, like the more popular (though less enterprise-oriented) hResume microformat.

So much for Contract-First Development. Contract Guided Development is probably more appropriate now.

Current Endeavors

I currently spend my Saturdays studying for my CAPM (Certified Associate in Project Management) and ITIL Certifications. The former is on project-based work which will be useful for development roles, and the latter is for IT support and focuses on IT operations.

CAPM

CAPM is a junior Project Management certification by the Project Management Institute, and tests knowledge of the Project Management Book of Knowledge (PMBOK), and does not require actual PM experience.

The gold standard in PM certification, the Project Management Professional, requires documented 4,500 hours of Project Management work which will be subject to audit. Because my colleagues in my previous PM work have left the company, there’s no one to validate my experience. I instead opted for CAPM.

For this certification, I primarily use Rita Mulcahy’s CAPM Exam Prep Third Edition, which I had to order from Amazon because I couldn’t find this book anywhere locally. I also read Information Technology Project Management, Fourth Edition, by Kathy Shwalbe, as a supplement, and the official PM bible, A Guide to the Project Management Book of Knowledge, Third Edition, of course.

I currently am about to start on the Quality Management chapter, having finished the chapters on Introduction, Project Lifecycle, PM Processes, Integration Management, Scope Management and Cost Management.

ITIL

ITIL stands for the IT Infrastructure Library, and the certification I’m going for, ITIL Foundation, covers foundation knowlege on ITIL Service Support and ITIL Service Management processes.

My current role is in technical support, so certified knowledge in ITIL is very important. For this, I use online training materials from Skillsoft.

I currently am on Configuration Management, having finished the Service Desk and Incident Management modules.

.Net

Aside from the 2 above study tracks, I am also continuing my SCSF activities. Having finished up to the Services portion of the lab, I am going to start working on a prototype project, and I chose it to be a Resume Builder software.

I currently am studying the HR-XML standard for resumes, and am currently looking at the Resume schema. I intend to try using a XSD to SQL tool, and then use NHibernate to help out in the data access portion of the code. I will be trying out XSD.EXE from VS 2005 if it can easily generate entity classes from these documents. (I have not yet started getting into the newly released ADO.NET Entity Framework of Microsoft, as I’d like to use .Net 2.0 as the foundation for my piece.)