I advocate always writing code as if it were for a library. Once in library form, you can easily write a frontend to use the library. If one day in the future you need to change the interface drastically, you can do that. If someone wants to use your code in a way that it wasn't originally intended for, it is much easier to use code that was written for a library.
I recently needed to write a reporting system. I wanted something that was really easy for the other developers to create a new report without training. There were lots of reporting engines out there, but they all had their own syntax. Everything required some training to create a new report. I wanted something that looks like everything else we write. My idea was to use the JSP engine as the report generating engine. I could use the same charting software that I use for websites. I don't have to use some complicated template engine. I started looking at the Tomcat source code to look at the JSP compilation code.
This is where I ran into a problem. The JSP engine looked like it was tightly coupled to the Tomcat codebase as a whole. I know I would need to use the servlet engine under the JSP engine, bit it was a bit more than that. There was no easy way to separate the JSP engine from the web container. If the JSP engine was written as a library, then I would be able to use the JSP engine as a reporting engine as well.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.