Statiscal lazy loading idea

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

User avatar
allspiritseve
DevNet Resident
Posts: 1174
Joined: Thu Mar 06, 2008 8:23 am
Location: Ann Arbor, MI (USA)

Re: Statiscal lazy loading idea

Post by allspiritseve »

PCSpectra wrote:That goes for any problem. Everything is simple once it is understood
Man, you and jshpro2 sure like your philosophy, don't you ;)
PCSpectra wrote:I recall reading a study/article years ago, titled: "what makes a super programmer" or something similar...the study was from 1978 in an old book I have so it's a little dated. The conclusion was that of all backgrounds tested (Psychologists, physicists, etc about a dozen in total) mathematicians made the best programmers. Assumingly because they are 'experts' at breaking complex problems into atomic problems.
That made me laugh... I'm picturing my abnormal psych prof trying to program. :D (I'm a psychology major)
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Statiscal lazy loading idea

Post by alex.barylski »

Man, you and jshpro2 sure like your philosophy, don't you
Sure I guess....I think he's probably more formal than me.

Most of my understanding of philosophy, spirituality and psychology is from self-observation and just spending a lot of time thinking about thinking... :P

Cheers,
Alex
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Statiscal lazy loading idea

Post by josh »

PCSpectra wrote:
Man, you and jshpro2 sure like your philosophy, don't you
Sure I guess....I think he's probably more formal than me.
It takes one debauched by the process of learning to question 'why' :-)
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Statiscal lazy loading idea

Post by alex.barylski »

One will slide further in bullsh*t when compared to gravel. :P :lol:

Now that were getting all Filisofical and all...I'd just like to add:

2b || !2b --- That is the question...
User avatar
allspiritseve
DevNet Resident
Posts: 1174
Joined: Thu Mar 06, 2008 8:23 am
Location: Ann Arbor, MI (USA)

Re: Statiscal lazy loading idea

Post by allspiritseve »

An interesting variation on the original post:
Fowler wrote:The way to deal with [situations where different use cases work best with different varieties of laziness] is to have separate database interaction objects for the different use cases. Thus, if you use DataMapper (165), you may have two order mapper objects: one that loads the line items immediately and one that loads them lazily. The application code chooses the appropriate mapper depending on the use case. A variation on this is to have the same basic loader object but defer to a strategy object to decide the loading pattern.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: Statiscal lazy loading idea

Post by Kieran Huggins »

So would a strategy object essentially be a model wrapper with embedded laziness settings?

Like:

Code: Select all

class User extends SmartORM # vanilla User class, default laziness
  # properties
  property id, Integer, auto-inc
  property username, String
  property name, String
  property description, Text
  property signature, Text
 
  # associations  
  belongs_to groups
  has_many posts, order_by(date, desc)
end
 
class Poster extends User # the class to use when displaying posts
  lazy [description,username,groups]
  eager [id,name,signature,posts]
end
 
class Profile extends User # the class to use when displaying profiles
  lazy [username,posts]
  eager [id,name,signature,description,groups]
end
User avatar
allspiritseve
DevNet Resident
Posts: 1174
Joined: Thu Mar 06, 2008 8:23 am
Location: Ann Arbor, MI (USA)

Re: Statiscal lazy loading idea

Post by allspiritseve »

Kieran Huggins wrote:So would a strategy object essentially be a model wrapper with embedded laziness settings?
That's probably one way to do it. I think he meant injecting an object through a method, such as setLoader (LoadingStrategy $loader) ...but subclassing works as well.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Statiscal lazy loading idea

Post by josh »

Or any kind of compositional inheritance / "behavioral" design pattern :wink:
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Statiscal lazy loading idea

Post by alex.barylski »

compositional inheritance
:|
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Statiscal lazy loading idea

Post by josh »

Composition is inheritance. Sub classing is static inheritance, only a subset of kinds of ways to inherit functionality. Delegation is a way to inherit functionality, despite it's de-facto usage. I guess head first books don't teach you that, only GoF. The confusion, I guess, comes from implementation specific terms vs the context I'm using them in being for analysis / design phases.
Post Reply