[pLog-svn] Some programming questions?
Mark Wu
markplace at gmail.com
Tue Mar 4 23:00:52 EST 2008
Hi Howard:
All DAO are extended from Model. And the model object include db connection
and basic CRUD method.
If we change to static method, I am not sure we can do this easily.
Take $blogs->addBlog(xxx) for example, if we change it to static method,
Blogs::addBlog(xxx), we need to change the method to the following(psuedo
code)
function addBlog(xxxx) {
$model = Model::getModelInstance();
$model->table = Model::assignTable("blogs");
....
preare $blog object
....
$model->add($blog);
}
I am no sure it is easier then the current method.
Or maybe you can give some simple pseudo code to make more clear about your
point.
Mark
> -----Original Message-----
> From: plog-svn-bounces at devel.lifetype.net
> [mailto:plog-svn-bounces at devel.lifetype.net] On Behalf Of howard chen
> Sent: Wednesday, March 05, 2008 10:20 AM
> To: LifeType Developer List
> Subject: Re: [pLog-svn] Some programming questions?
>
> On Wed, Mar 5, 2008 at 4:16 AM, Jon Daley
> <plogworld at jon.limedaley.com> wrote:
> > How do you set the _provider variable in your example? A global?
> >
>
> Why not? a Users or Blogs classes should always be the same
> during their life, no matter you create it during action, or view.
>
>
> > There are some classes that could be treated as singletons, and
> > perhaps Users is one of them, I think you would have to be
> careful in
> > applying the "static principle" across the board, because
> I'd expect
> > that sometimes the class objects are meant to be used and thrown
> > away, and not influence other people instances of the objects.
> >
>
>
> One of the reason is reuse, sometimes we need to create a
> User class in Action, sometimes in View (or maybe you can
> pass the reference to view), Plugin developers might also
> need Users and they create their own.
>
> This lead to performance slow down, more memory usage and
> more LOC (line of codes), with static class, caching is even
> more easy.
>
> Howard
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://limedaley.com/mailman/listinfo/plog-svn
More information about the pLog-svn
mailing list