On Mon, Nov 2, 2009 at 12:36 PM, Naftoli Gugenheim <[email protected]>wrote:

>
> I hear that. If you query 1000 items the reflection shouldn't need to be
> done 1000 times!
> But can't the instances locate the companion via reflection, i.e., look for
> the class with the same name with a trailing '$'? Of course it would break
> code--they would have to delete their definition or add 'override'--but is
> there another problem?
>

(1) I wanted to reduce the use of reflection
(2) At the time I coded mapper, companion object class names were in flux
(3) It's still non-trivial to actually get the companion object instance via
reflection (and if this changed/changes as Scala evolves, it's a maintenance
nightmare)

At the end of the day, there's a little more boilerplate to defining Mapper
(and Record) instances, but every time we try something new, it doesn't work
as well.


>
> -------------------------------------
> David Pollak<[email protected]> wrote:
>
> On Mon, Nov 2, 2009 at 12:26 PM, Naftoli Gugenheim <[email protected]
> >wrote:
>
> >
> > What's stopping the instances from managing themselves?
> >
>
> There's a lot of start-up cost associated with the reflection used to
> determine what stuff is fields, etc.  Doing that for each instance would
> destroy performance.
>
> But if any folks out there have a better model, I'm all for reviewing it.
>
>
> >
> > -------------------------------------
> > Jim Barrows<[email protected]> wrote:
> >
> > On Mon, Nov 2, 2009 at 1:16 PM, Vesa <[email protected]> wrote:
> >
> > >
> > > By the way, why orm classes need to be aware of the companion object?
> > > Could this dependency be eliminated somehow?
> > >
> >
> > The Mapper/Record companion object is where the code to do all the DB
> stuff
> > lives.  These are all static methods, they don't really change per
> instance
> > of the class itself.  The companion object is one way Scala allows you to
> > do
> > this.  It's probably also the most convenient.
> > An answer to the question: What is the rationale behind having companion
> > objects in scala.<
> >
> http://stackoverflow.com/questions/609744/what-is-the-rationale-behind-having-companion-objects-in-scala
> > >
> >
> >
> > >
> > > - Vesa
> > >
> > > On 2 marras, 22:02, Vesa <[email protected]> wrote:
> > > > I doubt I can find one, but it still feels awkward having to type the
> > > > name of the class so many times. Another option could be to use some
> > > > shared object to do this stuff, but I guess it wouldn't be as neat to
> > > > use it then.
> > > >
> > > > - Vesa
> > > >
> > > > On 2 marras, 18:33, David Pollak <[email protected]>
> > > > wrote:
> > > >
> > > >
> > > >
> > > > > On Mon, Nov 2, 2009 at 8:14 AM, Vesa <[email protected]> wrote:
> > > >
> > > > > > It seems like boilerplate that every mapped class needs to define
> a
> > > > > > getSingleton method returning companion object. Can't there be
> any
> > > > > > default with this and is there any way to get rid of the manually
> > > > > > defined companion object if user isn't going to define any new
> > > methods
> > > > > > on it, while still having the default meta functionality?
> > > >
> > > > > I know of no mechanism in Scala to discover companion objects.  If
> > you
> > > find
> > > > > one (that's not simply Java Reflection), please let me know.
> > > >
> > > > > > - Vesa
> > > >
> > > > > --
> > > > > Lift, the simply functional web frameworkhttp://liftweb.net
> > > > > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > > > > Follow me:http://twitter.com/dpp
> > > > > Surf the harmonics
> > > >
> > >
> >
> >
> > --
> > James A Barrows
> >
> >
> >
> > >
> >
>
>
> --
> Lift, the simply functional web framework http://liftweb.net
> Beginning Scala http://www.apress.com/book/view/1430219890
> Follow me: http://twitter.com/dpp
> Surf the harmonics
>
>
>
> >
>


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

--~--~---------~--~----~------------~-------~--~----~
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