RenderSnake is a Java library for creating components and pages that produce HTML using only Java. Its purpose is to support the creation of Web applications that are better maintainable, allows for easier reuse, have testable UI components and produces compact HTML in an efficient way.
This blog post explains how to start from a carefully designed rich HTML page and create new or use the components available in the library.
Web developmentThe tasks of developing web applications include implementing the application domain logic, database access for persistence and the presentation layer for user-interaction handling and page rendering. For most development teams, members have different roles in the process. Typically, web and interaction designers have the responsibility to create the page flow and construct initial versions of the HTML pages needed. These mockup pages need to be translated into a form that can be served by a web application, make them interactive and present dynamic information.
LayoutThe master design of a Web application typically has a small number of layouts. Popular HTML compositions include a Heading, Menu, Search and Footer section. Each of these sections can be defined by its own Renderable component. The composition can defined by creating a subclass of RenderableWrapper. Wrappers can be used in places where you see a standard decoration of dynamic information. Examples are contacts in a list view, search results and product galleries.
UnitGiven the set of HTML mockup pages, the developer has to decide what functional or decoration parts will be translated into Renderable components. Components that render too much HTML are likely to change more frequently over time. Components that are too small require more work, produce more code to maintain and therefore makes development less productive and hard to keep an overview.
Because all components are defined in Java, as a developer you can use all the available language features. Parameterising components translate to adding fields to components classes. Specializing components translate to using class inheritance and composition. Decorations such as layouts translate to Wrapper subclasses. And finally, as a Java developer you have powerful IDE tools with refactoring and debugging support. Changing your component designs is therefore much easier to do and contributes to a more agile development process.