These are PHP 5.2+ libraries, in some cases PHP 5.3+, that are E_STRICT compliant, that will be part of Horde 4 and the Rampage framework:
Take a look at the Horde_Block system. Take a look at the *_View objects in Kronolith and a few other apps. Come up with something that unifies them into a lightweight way to encapsulate content in an easy-to-reuse, easy-to-render elsewhere package.
New structure for views/commands:
see ruby on rails and DB_DataObject pdf
Encapsulated globals in Rampage:: namespace. Goal to avoid global $conf, $prefs, etc. variables and to do lazy-loading of conf and prefs so they're not loaded when they're not needed. Maybe encapsulate prefs in a User object/namespace?
everything else pear installable
- apps - Horde/Rampage/App/Appname, or Apps?
- blocks - Horde/Rampage/Block/, or Horde/Block?
Each app has:
Dir structure for distributable apps:
Use .phar (php archive) files for installing rampage sites?
Rampage::log() - just for admin messages
Rampage::message() or Rampage::notify()
For user level notification - html alerts, ajax, send email, jabber, etc. Can be triggered by an Observer but doesn't implement object relationshps. What should? Workflow...
Data dictionary - description of fields, basis for validation? required, etc... pull some from database, some from object hardcoded metadata?
just pass it a $form object
commands come in somewhere
http://www.javaworld.com/javaworld/jw-08-2003/jw-0801-toolbox.html - Listing 0.1.Elim... !
take interfaces that implement Iterator wherever possible
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 (Whups with encapsulated specialized Mapper objects, etc.).
Should be a way to cache table meta data
Need a way to specify which fields to load (for example like Turba only loads fields being displayed). When this is done, the rest should be lazy-loaded.
Should be possible to greedy-load related objects (lazy is the default).
ViewBuilder/PageBuilder custom views
Web services, command line, GET/web layout should be identical
FeedBuilder - strategy interface for building multiple kinds of feeds (atom, rss versions, etc.) Takes any object that implements a Feedable interface, or a result set that implements FeedableCollection. Should RDO_Result implement that? Or should we use a more general Describable interface, like below?
Interface with different form building implementations.
takes an RDO_ResultSet or a single RDO object and builds a form based on that (array is for row based renderers, etc). Or use a more general Describable interface. Need anything besides describe()? Have a DescribableCollection, too, and have RDO_ResultSet implement that?
MVC is 30 years old
A rant on installing software: http://www.lastcraft.com/blog/index.php?p=11
Top Ten website mistakes: http://www.useit.com/alertbox/990502.html
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 );
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.)
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.