Analyzing the Problem


The first thing to decide when writing a generic class library is whether the analysis in question should be implemented as such. As the name implies, generic class libraries define methods that perform a generic analysis useful to a variety of applications. Any problem-specific components of the analysis are separated from the generic class library methods. Problem-specific information is generally passed to the generic method as an argument.

So when considering implementing a method as part of a generic class library, ask yourself if the method can be used by more than one application. If the answer is no, stop right there. If the answer is yes, decide if the analysis can be separated into generic and problem-specific parts . If it can, develop the generic part of the analysis as part of a generic class and incorporate the problem-specific part into a separate class.

An example of a generic class library is the ODESolver class we developed in Chapter 20. The ODESolver class defined a number of methods to solve ordinary differential equations using the Runge-Kutta integration technique. The Runge-Kutta solution process is generic. Since they can be applied to any ordinary differential equation, the Runge-Kutta methods were declared inside a generic class. The generic ODE solvers need to know what equation they are supposed to solve. This is problem-specific information. The ODE class was written to encapsulate an ordinary differential equation. An instance of the ODE class or one of its subclasses is passed to the Runge-Kutta method as an argument.



Technical Java. Applications for Science and Engineering
Technical Java: Applications for Science and Engineering
ISBN: 0131018159
EAN: 2147483647
Year: 2003
Pages: 281
Authors: Grant Palmer

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net