Re: [jug-discussion] Thanks for the presentation Brian!

2008-07-11 Thread Warner Onstine
I'm not sure as I don't have enough experience with Grails/GORM yet,  
Bashar might know though as he's done a fair amount of work with Grails.


-warner

On Jul 9, 2008, at 10:33 AM, Chad Woolley wrote:

On Wed, Jul 9, 2008 at 9:16 AM, Warner Onstine [EMAIL PROTECTED] 
jug.org wrote:
I just wanted to send out a quick note to everyone (and Brian)  
thanking him

for the presentation last night.


Yes, I enjoyed it.  Regardless of which flavor we prefer, I think that
having all this momentum behind dynamic languages on the JVM is a
great thing.

Also, does anyone have links/examples of extending association proxies
in GORM?  Brian said this was possible, and I'd really like to see how
it is implemented as compared to ActiveRecord.  Does DataMapper have
this, too?  As a reminder, I mean something like defining a custom
published method on the articles association, so that
bob.articles.published results an array of only bob's published
articles.

-- Chad

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Warner Onstine - Programmer/Author
New book on Tapestry 4!
Tapestry 101 available at http://sourcebeat.com/books/tapestrylive.html
[EMAIL PROTECTED]
http://warneronstine.com/blog




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [jug-discussion] Thanks for the presentation Brian!

2008-07-11 Thread Bashar Abdul
Also, does anyone have links/examples of extending association proxies
in GORM?  Brian said this was possible, and I'd really like to see how
it is implemented as compared to ActiveRecord.  Does DataMapper have
this, too?  As a reminder, I mean something like defining a custom
published method on the articles association, so that
bob.articles.published results an array of only bob's published
articles.

-- Chad

If I got your questions right:

Suppose you have this class:

class Article{
String author
boolean published
}

To get all the articles published by Bob:

def articles = Article.findAllByAuthor(Bob)AndPublished(True)


Bashar

- Original Message 
From: Chad Woolley [EMAIL PROTECTED]
To: jug-discussion@tucson-jug.org
Cc: Brian Sam-Bodden [EMAIL PROTECTED]
Sent: Wednesday, July 9, 2008 10:33:13 AM
Subject: Re: [jug-discussion] Thanks for the presentation Brian!

On Wed, Jul 9, 2008 at 9:16 AM, Warner Onstine [EMAIL PROTECTED] wrote:
 I just wanted to send out a quick note to everyone (and Brian) thanking him
 for the presentation last night.

Yes, I enjoyed it.  Regardless of which flavor we prefer, I think that
having all this momentum behind dynamic languages on the JVM is a
great thing.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Re: [jug-discussion] Thanks for the presentation Brian!

2008-07-11 Thread Chad Woolley
On Fri, Jul 11, 2008 at 3:16 PM, Bashar Abdul
[EMAIL PROTECTED] wrote:
 If I got your questions right:

 Suppose you have this class:

 class Article{
 String author
 boolean published
 }

 To get all the articles published by Bob:

 def articles = Article.findAllByAuthor(Bob)AndPublished(True)

Not really.  I still want all bob.articles to return ALL of bob's
articles, but bob.articles.published should return only his
published articles.

And, to take it a step further than a simple property and illustrate
ActiveRecord's ability to define any method, I would also like a
about_paris_hilton method defined on the articles association, so I
could say bob.articles.about_paris_hilton

In ActiveRecord, this would look something like this (simple and
probably somewhat inaccurate, I'm no ActiveRecord guru):

class Person  ActiveRecord::Base

  has_many articles do
def published
  ...
end

def about_paris_hilton
  proxy_target.select { |article| article.about_paris_hilton? }
end
  end
end

With the new named_scope feature (contributed to Rails by one of my
colleagues), this is even easier: http://railscasts.com/episodes/108

Anyway, the point is that the associations themselves are objects
which you can extend with methods and functionality.  You don't have
to implement these helper methods directly on the model class.  This
allows you to make a very expressive and english-like API for your
model layer.

-- Chad

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [jug-discussion] Thanks for the presentation Brian!

2008-07-11 Thread Bashar Abdul
Not really.  I still want all bob.articles to return ALL of bob's
articles, but bob.articles.published should return only his
published articles.

This will return all of Bob's articles:  def articles = 
Article.findAllByAuthor(Bob)

This will return only Bob's published articles:  def articles = 
Article.findAllByAuthor(Bob)AndPublished(True)

And, to take it a step further than a simple property and illustrate
ActiveRecord's ability to define any method, I would also like a
about_paris_hilton method defined on the articles association, so I
could say bob.articles.about_paris_hilton

Given this class

class Person {
String name
def hasMany = [articles:Article]  
}

You can use Hibernate's Criteria Builder:

def c = Person.createCriteria()
def results = c.list{
articles{
like('content','Paris Hilton')
}
}

Bashar




- Original Message 
From: Chad Woolley [EMAIL PROTECTED]
To: jug-discussion@tucson-jug.org
Sent: Friday, July 11, 2008 3:39:48 PM
Subject: Re: [jug-discussion] Thanks for the presentation Brian!

On Fri, Jul 11, 2008 at 3:16 PM, Bashar Abdul
[EMAIL PROTECTED] wrote:
 If I got your questions right:

 Suppose you have this class:

 class Article{
 String author
 boolean published
 }

 To get all the articles published by Bob:

 def articles = Article.findAllByAuthor(Bob)AndPublished(True)



And, to take it a step further than a simple property and illustrate
ActiveRecord's ability to define any method, I would also like a
about_paris_hilton method defined on the articles association, so I
could say bob.articles.about_paris_hilton

In ActiveRecord, this would look something like this (simple and
probably somewhat inaccurate, I'm no ActiveRecord guru):

class Person  ActiveRecord::Base

  has_many articles do
def published
  ...
end

def about_paris_hilton
  proxy_target.select { |article| article.about_paris_hilton? }
end
  end
end

With the new named_scope feature (contributed to Rails by one of my
colleagues), this is even easier: http://railscasts.com/episodes/108

Anyway, the point is that the associations themselves are objects
which you can extend with methods and functionality.  You don't have
to implement these helper methods directly on the model class.  This
allows you to make a very expressive and english-like API for your
model layer.

-- Chad

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Re: [jug-discussion] Thanks for the presentation Brian!

2008-07-11 Thread Chad Woolley
On Fri, Jul 11, 2008 at 4:06 PM, Bashar Abdul
[EMAIL PROTECTED] wrote:
 class Person {
 String name
 def hasMany = [articles:Article]
 }

 You can use Hibernate's Criteria Builder:

 def c = Person.createCriteria()
 def results = c.list{
 articles{
 like('content','Paris Hilton')
 }
 }

OK.  If I understand, def c would be def
articles_about_paris_hilton?  This is still not as nice as
ActiveRecord, I think.  You are having to create custom helper methods
directly on the Model.  For example, bob.articles_about_paris_hilton
vs the (more OO and messagey) bob.articles.about_paris_hilton which
leverages the (nicely decoupled and Demeterish)
Article.about_paris_hilton?

However, Brian's points about the maturity and stability of Hibernate
vs. ActiveRecord are well taken.  I think it all depends on your
project.  For Agile startup social networking projects, the
flexibility, readability, and speed of ActiveRecord trumps.  For a
project where you really care about database integrity or ACID, you
would probably want to think about using some DSL on top of hibernate,
like GORM.  I still think the GORM syntax looks like poop compared to
Ruby and ActiveRecord, though :)

-- Chad

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [jug-discussion] Thanks for the presentation Brian!

2008-07-09 Thread Chad Woolley
On Wed, Jul 9, 2008 at 9:16 AM, Warner Onstine [EMAIL PROTECTED] wrote:
 I just wanted to send out a quick note to everyone (and Brian) thanking him
 for the presentation last night.

Yes, I enjoyed it.  Regardless of which flavor we prefer, I think that
having all this momentum behind dynamic languages on the JVM is a
great thing.

Also, does anyone have links/examples of extending association proxies
in GORM?  Brian said this was possible, and I'd really like to see how
it is implemented as compared to ActiveRecord.  Does DataMapper have
this, too?  As a reminder, I mean something like defining a custom
published method on the articles association, so that
bob.articles.published results an array of only bob's published
articles.

-- Chad

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]