RE: [PEAR-DEV] Re: Separating business logic from data store logi c
| From: | Hundiak, Arthur | Date: | Tue, 04 Nov 2003 14:03:48 +0000 |
| Subject: | RE: [PEAR-DEV] Re: Separating business logic from data store logi c | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-23220@lists.php.net to get a copy of this message | ||
Mr Lemos,
Thank you for your comments. I probably should have made clear that my
original email was directed to the PEAR group. I know there are a number of
code generating enviroments out there. And Metastorage certainly appears to
be quite impressive. But I feel it to be somewhat overkill for my modest
applications.
The comment about "very fat base classes" is confusing. The application I
described is real and had been in production for two seasons. The BO_Item
class has 70 lines of code. The BO_Items collection class requires 100
lines while the SQL BO_ItemPersist class has about 250 lines. Standards
vary but I would not term these classes as being "fat". No doubt my
explanation of these classes was unclear.
-----Original Message-----
From: Manuel Lemos [mailto:mlemos@acm.org]
Sent: Monday, November 03, 2003 3:20 PM
To: pear-dev@lists.php.net
Subject: [PEAR-DEV] Re: Separating business logic from data store logic
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/
--
PEAR Development Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php