Hey HN,<p>I'm currently modifying my b2b application to allow custom extensions. After some futile Google and SO searches, I can't find many best practices or patterns on how to support this.<p>As a quick example, say my application has support for Users (exotic, I know). A company purchases the software and decides they want to store (and display) social security numbers. Any suggestions on how to go about storing custom data in the database? Suggestions on how they modify the app to display data in X spots?<p>I was thinking database-wise, either a column in the Users table that stores all extended data, or else somehow update the schema itself.<p>For display, tons and tons of hooks might be the way to go...<p>Anyways, I'd be grateful for any tips, hard lessons learned, documents, ebooks, really anything about this.
Ideally build some of your main functionality as an extensions. You'll quickly discover pain points if you have to live with the same API and contexts as a 3rd party. I just recently rewrote TaffyDB to a version allowing extensions and a key goal was to build most if not all of the public default methods as extensions.
Decouple it as best as you can. For example, authentication; make an API/Library/Class for that. Means better development security as no one can write a class that pulls all the username+passwords because that API has the configuration. (I don't know SSN that well to give a more relevant example)<p>Tons and tons of hooks sounds like very tight integration. While fast and procedural like, maintenance will be hard down the road. If management really want the cheap quick solution, go procedural.<p>Recommended reading: Object Oriented programming, Case study of Amazon's decoupling.
The ExpressionEngine CMS uses the idea of "hooks" [1], which are basically global events that are fired at key points in other modules and extensions. Extensions can register to be notified of these hooks, which allows them to modify data at those key points, or modify output.<p>Extensions can check when they are first instantiated if their schema changes have been made, and if not, apply them.<p>It works out pretty well.<p>[1] <a href="http://expressionengine.com/user_guide/development/extensions.html" rel="nofollow">http://expressionengine.com/user_guide/development/extension...</a>
You can setup a dev account in salesforce.com and make some customization to contact, account objects with custom fields, etc. This will give you some ideas on how to architect your system for easy customization.