On Sat, May 16, 2009 at 2:39 PM, g-man <[email protected]> wrote:

>
> As I create the Models to define the real-world things of interest to
> my webapp, I'm wondering what to put into either the class or the
> object. Here is some pseudocode as I understand the Model table
> definition pattern:
>
> // first comes the class, which defines fields and creates the
> singleton:
> class Thing extends LongKeyedMapper[Thing] with IdPK {
>  def getSingleton = Thing
>  // define a field...
>  object field extends mappedWhatever(this) {
>    // and define some constraints and validations for the field...
>  }
>  // global class methods here plus xml, json, etc output...
> }
> // then the object:
> object Thing extends Thing with LongKeyedMetaMapper[Thing] {
>  // define an instance method:
>  def instanceMethod() = {
>    doSomething
>  }
>  // more instance methods, etc...
> }
>
> My question is: how do I know what kinds of methods and other goodies
> should go into either the class or the object, that is, into each
> 'half' of the Model specification?


The "object Thing" is a singleton object in your system.  It is a good place
for methods associated with the model, but not a particular instance of the
model.  If you're a java programmer, this is the place to put methods that
would be static in Java.

The "class Thing" is an instance that contains one model object.  Methods on
the instance should operate on the instance data.

Hope this helps.

Thanks,

David


>
>
> >
>


-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to