A typical Internet application usually begins with an architectural diagram. For example, a database connection component might be connected to a data cache, which is accessed by a search engine that is attached to some UI component. Creating such an architectural plan takes some practice, but there are some basic rules that one can follow:
Use existing components where appropriate. If there is no existing component that does the job, try subclassing an existing component.
Break down large components into smaller components. Smaller components are easier to test, reuse, inspect at runtime, etc. This may result in a larger number of components, but this should not be a problem as Nucleus is designed to handle large numbers of components. Large monolithic components are sometimes difficult to spot, so always be on the lookout. A good rule of practice is to design each component to perform a single function that can be described in a short paragraph.
Centralize the functions that are shared by multiple components. For example, one component might spin off a Thread that causes e-mail to be sent every hour, while another component might spin off another Thread that causes a log file to be archived every day. Both of these timing Threads can be eliminated if the components take advantage of a centralized Scheduler component.
If a component cannot be completely self-contained (which is usually the result of following the previous point), be sure that the component’s dependencies on other components are clearly enumerated. These dependencies are usually listed as properties of the component (see below). For example, a component may require a pointer to a Scheduler component and a
DatabaseConnection
component, so the component would have properties of those types. A component should never need to know about its position in the grand scheme of the architecture — it should only need to know its most immediate dependencies.
Once the architectural plan is complete, the plan can be transferred directly to an implementation using Nucleus and JavaBeans. If each component is designed as a JavaBean, then Nucleus can be used to create, initialize, and establish the relationship between Beans. This allows the components to be built without regard for their initialization values, or how their dependencies on other components will be satisfied. These application-specific concerns are contained in configuration files that are read and interpreted by Nucleus.