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.
2 Comments:
Tod, unless Echo2 performs some scary voodoo Java magic, I think you overstate the scope of StyleSheets. A StyleSheet is NOT shared across an entire Servlet container server. Instead it is shared throughout a classloader. Most, if not all, Servlet and J2EE servers place each Web application in its own ClassLoader to avoid namespace conflicts between different Web applications. Thus, a developer should expect the StyleSheet to be shared across all instances of the application (i.e., one per user session), but not across multiple Echo2 applications on the same Servlet container.
Regards,
David L Kinney
By Anonymous, at 7:49 PM
David,
I think you must have misread what Todd has written. He explicitly says it will be shared across all application instances. He didn't say it would be shared across multiple applications. From my experience of Echo2 so far I would want seperate stylesheets for each application anyway :)
- Ciaran
By bob, at 1:15 AM
Post a Comment
<< Home