Re: Separating business logic from data store logic
| From: | Manuel Lemos | Date: | Mon, 03 Nov 2003 21:19:39 +0000 |
| Subject: | Re: Separating business logic from data store logic | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-23212@lists.php.net to get a copy of this message | ||
Hello,
On 11/03/2003 06:21 PM, Arthur Hundiak wrote:
===================================================== To Summarize, here are the classes I think we need to make an application less dependent on data store details: BO_Item - Represent one business object such as a game or team. BO_Items - Represents a collection of business objects BO_ItemIter - Helper class used to cycle through items in a collection. Includes custom sorting and filtering capability. BO_ItemPersist - Data store specific information about a given BO_Item object. It's basically an interface which allows persisting and retrieving BO_Item objects from/to different data stores. It can also be used by admin classes to do things like table creation.If you care for an opinion, the problem is this approach is that it leads to very fat base classes that bundle all possible functionality that your application may or may not need. This leads to bloated applications that take more time and memory to load. A better approach is to have a code generation engine that will only generates what your data object classes need. The way to do it is follow a Model Driven Architecture (buzzword of the moment MDA) where the generator engine generates data object classes that do not inherit any code from any fat base classes because they already have only the code they need. There would be a lot more to say about this, but to sum it up, this is is the approach followed by Metastorage. You just design your data model in a simple XML file, that includes classes with variables, relationships and validation rules, as well the definition of functions that perform standard operations to manipulate the objects. Then Metastorage generates all the code for your classes. It will not generate code that may not be necessary. For instance, if you do not need a function to delete objects from storage, it will not generate such function. It just generates the functions you specify based on your own knowlegde of what you need. If later you need more or less, just change your data model definition and ask Metastorage to regenerate the code for you. It just takes few seconds, despite the compiler is fully written in PHP. Additionally, Metastorage may also generate classes to handle Web based forms to perform standard user interface operations on your class objects. The user interface presentation is defined by theme based template definitions. Templates do not contain absolutely no code, just place holders, so you can produce the templates in any HTML designer program. But to avoid you to waste time on producing new templates just to test your projects, Metastorage comes with pre-built themes that make your applications look very much like desktop applications of well known operating systems. Take a look: http://www.meta-language.net/screenshots.html Conceptually your model, business and user interface logic are all separate, but since Metastorage makes it easy to rebuild optimal code for what you need in a few seconds, the generate code is tightly couple for greater efficiency. If you want to know more about Metastorage, just go in here: http://www.meta-language.net/metastorage.html There is a tutorial to get beginners quickly started that is still under productions but a copy of the current version can be obtained here: http://groups.yahoo.com/group/metal-dev/files/metastorage/tutorial.html -- Regards, Manuel Lemos Free ready to use OOP components written in PHP http://www.phpclasses.org/