Applying Code Generation Approach in Fabrique
Wrap up
Here is a quick summary of neat things implemented with Business Object Framework:
- We can create the business model with visual editors – no need to specify any xml-deployment descriptors or implement any interfaces (or any other boring things!)
- Fabrique provides support for transactions which is extremely easy to use
- Fabrique Complier generates platform-independent interfaces for business objects which are strictly typed and easy to use, and also specific implementations for a target platform.
- Visual Fabrique provides robust, intelligent coding assistance for those times when you do have to write some code.
- We can alter the complier settings so that it generates implementations for different specifications and application server vendors with no need to change the business model
Libraries vs. Generators
I think I've clearly outlined how Fabrique is different from typical web development platforms in general, but let me point out some specific things to make it even clearer. We can consider EJB CMP vendors or Hibernate to be typical representatives of such families of tools. So, what do we mean?
Libraries take care of some difficult things and provide a business-task oriented API (thus hopefully making programming simpler). However, we still have the following issues:
- Libraries don't change with the way we express our tasks. Even if we deal with a high-level API, we have to write code in the same low-level language which may not be well suited for expressing higher level things.
- A code editor cannot provide additional assistance to help the developer manage high level things (it still only knows about classes/packages/methods and has no idea that you use a library that can do something with persistence or user interface).
- It's very hard to build a library that would balance well between ease of use and functionality/flexibility. Type systems of most programming languages are not flexible enough to seamlessly integrate with libraries.
- Program becomes dependant on a library and, more importantly, the technology behind it.
Code generators, like Fabrique, ask us to write a task with some higher-level language and then generate the lower-level code. Having a high-level description of a task results in a number of benefits:
- it's simpler to read, understand and modify
- we are not stuck with only one code generator; we can choose/write/tune generators however we want
- we can generate new data types instead of using a generic mechanism
- we can make our IDE more intelligent and assistive to the developer since we know about high-level constructs, not just classes/packages/methods
As we outlined in the first chapter, there's still a lot of work to address problems of communicating between hand-written code and generated counterparts and refactoring of the whole project. But much of this work can be delegated to an intelligent IDE for the user's convenience. This is what Visual Fabrique does.
Fabrique Status
Fabrique is now is open in the JetBrains Early Access Program (EAP) and can be downloaded and tried for free. It's still in development and your feedback and participation in the EAP will make it a better product. Please visit http://www.jetbrains.com/fabrique for more information about Fabrique and participation in the EAP.