EchoTwo

Friday, July 15, 2005

A Few Pointers

I wanted to pass along a few general pointers for those writing applications in Echo2 or porting Echo1 apps to the new platform:
  • Externalize all Strings as though you were going to support multiple languages. I've found this to be an extremely beneficial practice, even when developing apps that are extremely unlikely to ever be translated. It keeps code cleaner, and enables one to quickly review (and even spell-check) all text that is used within an application.
  • JavaDoc every class and method. Maintain the JavaDocs when you update the classes and methods. I believe this to be a worthwhile practice even if you will never actually generate JavaDocs based on the code, and even if you will always be the sole maintainer of a particular piece of code. I've also always found that in the event that I begin to have a difficult time explaining a particular method/class with JavaDoc documentation, then chances are that piece of code could use a good refactoring.
  • Use StyleSheets wherever practical. They clean up your code and result in less memory being used on the application server. When you use StyleSheets, a single instance of the defined style properties is shared across ALL application instances on the server, which can result in a substantial reduction in memory usage. StyleSheets can also make it quite easy to change the theme of an application, and/or allow an application to have multiple user-selectable themes.
  • Do not use the Grid Component unless you absolutely need to. The Row and Column components will render more quickly, and have substantially more capability to perform fine-grained client-server updates when cells are added and removed. Grids do not have this capability. Also, don't use the Grid Component to render tabular data; the Table component is designed specifically for this purpose.
  • Don't perform unnecessary component add/remove operations. The Echo2 "UpdateManager" is watching your application for component hierarchy and property changes in order to determine the simplest course of action to update its state on the client web browser. If you remove and re-add a component, for example, the UpdateManager won't know that in fact nothing has changed, and the re-added component will thus be re-rendered on the client, consuming more bandwidth than necessary.