2005年11月8日 星期二

It is a dark blue Monday indeed, with thoughts on Coding Styles

It is a dark blue Monday, with most of the stuff not going too well. I need to pick up maintaining a set of code that I left when I came over to Shanghai. To my horror, the code has gained YET ANOTHER LIBRARY! I really hate these stuff as they:

1. Increase 3rd party library maintenance burden
2. Non-standard API conventions, which once a person sticks to, it's hard to shake off
3. Importing something for the sake of "easy" coding is sloppy.

Sloppy import means sloppy way to think about approaches to problems, and may result in sloppy code. (this was later proved in the code with upper-case first letter for a package name). I really wouldn't mind anyone inventing something new or great, but doing it because it's more easily done is plainly unacceptable. I spent over 2 weeks with Hanhui trying to convert all dom4j API over to W3C in hope that we might at last rely on a standard base for XML APIs, instead of a patch here and a patch there. XPath was incoporated into JDK1.5 too, making it possible to retain most of the XPath code with very little modification. A line with:

XPath xpath = XPathFactory.newInstance().newXPath();


and anyone can continue using XPath expressions, why another XML4J? And the only file that uses XML4J can be changed in a day if one reads the document and understands enough about XML basics. If one cannot do that, either one knows too little about XML, or is being lazy.

For the past 2 years, I thought what I did to the code regarding styles and coding rules would make a difference to all my teammates, at least they would understand what I was doing. No, apparantly I was wrong. Action does not speak at all. This incident just proves it.

To look on the bright side of things, at least here in Shanghai, I am not preaching to the choir. One of my teammates agreed to what I had in mind and went ahead to implement what BlueStone was supposed to do - render XML-defined Swing Objects. To take this further down the road, combined with what we did previously, we are into:
1. XML-based GUI rendering, with proper ActionListeners and inter-object calls.
2. Renderers and Editors for JTextComponents
3. Form-based designer for non-programmers, virtually creating a much more powerful rendering environment than the standard web-browsers. But browser technology is gaining fast too, we may need to look into XUL. Sadly it's firefox and mozilla only at the moment.
4. Quick business logic -> GUI controllers. Controllers are to be linked to the GUIs rendered by XML, providing mechanisms akin to JSP Custom Tags.

One man has only 24 HRs a day, I need to focus on what I WILL do than what I already DID. Enough whining and get back to work now.

沒有留言:

張貼留言