[cvs] [Wiki] changed: RampageFramework

Chuck Hagenbuch chuck at horde.org
Tue Jul 5 12:16:55 PDT 2005


chuck  Tue, 05 Jul 2005 12:16:55 -0700

Modified page: http://wiki.horde.org/RampageFramework
New Revision:  1.3
Change log:  more thoughts

@@ -58,4 +58,76 @@
 
 base catalyst on: ulaform, giapeto, wicked, should replace those ... ? what else?
 
 Iterators! Only loop through data once!
+
+
+Use Turba as basis for RDO_Storage objects
+
+get PEAR channel up for Horde so new code can be distributed.
+
+
+
+need basic classes for each backend (SQL, LDAP, Kolab, IMSP, etc) that provide a unified api
+try hard not to use more than that api; write specific adapters when necessary (WhupsBackend implemented
+by WhupsBackend_sql, etc.).
+
+
+
+Task object
+
+returned by any of the DA backends (table gateway? row gateway? data mapper?) - Mapper.
+
+no set/get
+just pass it a $form object
+commands come in somewhere
+Builder: http://www.javaworld.com/javaworld/jw-01-2004/jw-0102-toolbox-p2.html
+http://www.javaworld.com/javaworld/jw-08-2003/jw-0801-toolbox.html - Listing 0.1.Elim... !
+
+take interfaces that implement Iterator wherever possible
+
+
+MVC is 30 years old
+
+
+
+Data dictionary - description of fields, basis for validation? required, etc... pull some from database ala
+ActiveRecord?
+
+
+
+double orderTotal;
+Money amount = ...;
+//...
+orderTotal += amount.getValue(); // orderTotal must be in dollars
+
+The problem with this approach is that the foregoing code makes a big assumption about how the Money class is implemented (that the "value" is stored in a double). Code that makes implementation assumptions breaks when the implementation changes. If, for example, you need to internationalize your application to support currencies other than dollars, then getValue() returns nothing meaningful. You could add a getCurrency(), but that would make all the code surrounding the getValue() call much more complicated, especially if you persist in using the getter/setter strategy to get the information you need to do the work. A typical (flawed) implementation might look like this:
+
+Money amount = ...;
+//...
+value       =  amount.getValue();
+currency    =  amount.getCurrency();
+conversion  =  CurrencyTable.getConversionFactor( currency, USDOLLARS );
+total       += value * conversion;
+//...
+
+This change is too complicated to be handled by automated refactoring. Moreover, you would have to make these sorts of changes everywhere in your code.
+
+The business-logic-level solution to this problem is to do the work in the object that has the information required to do the work. Instead of extracting the "value" to perform some external operation on it, you should have the Money class do all the money-related operations, including currency conversion. A properly structured object would handle the total like this:
+
+Money total  = ...;
+Money amount = ...;
+
+total.increaseBy( amount );
+
+
+FlowLayoutPanel, GridLayoutPanel, BorderLayoutPanel, etc., but that mandates too many classes and a lot of duplicated code in those classes. A single heavyweight-class solution (adding methods to Container like layOutAsGrid(), layOutAsFlow(), etc.) is also impractical because you can't modify the source code for the Container simply because you need an unsupported layout. In the Strategy pattern, you create a Strategy interface (LayoutManager) implemented by several Concrete Strategy classes (FlowLayout, GridLayout, etc.). You then tell a Context object (a Container) how to do something by passing it a Strategy object. (You pass a Container a LayoutManager that defines a layout strategy.)
+
+
+ Frameworks
+A discussion of fragile base classes would be incomplete without a mention of framework-based programming. Frameworks such as Microsoft Foundation Classes (MFC) have become a popular way of building class libraries. Though MFC itself is blessedly fading away, MFC's structure has been ingrained in countless Microsoft shops where programmers assumed that the Microsoft way was the best way.
+
+A framework-based system typically starts with a library of half-baked classes that don't do everything they need to do, but rather rely on a derived class to provide missing functionality. A good example in Java is the Component's paint() method, which is effectively a place holder; a derived class must provide the real version.
+
+You can get away with this sort of thing in moderation, but an entire class framework that depends on derivation-based customization is brittle in the extreme. The base classes are too fragile. When I programmed in MFC, I had to rewrite all my applications every time Microsoft released a new version. The code would often compile, but then not work because some base-class method changed.
+
+All Java packages work quite well out of the box. You don't need to extend anything to make them function. This works-out-of-the-box structure is better than a derivation-based framework. It's easier to maintain and use, and doesn't put your code at risk if a Sun Microsystems-supplied class changes its implementation. 


More information about the cvs mailing list