Quantcast

New plugin - grails inflector

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

New plugin - grails inflector

tomas lin
Hi,

Would like to add a new plugin to the repo.

https://github.com/tomaslin/grails-inflector

It's basically a simple set of tag libraries that allow you to do
simple text inflections like <g:pluralize>Pain</g:pluralize> -> Pains.

Not a huge plugin but fills a gap between the cool stuff available in
Rails Text Helpers.

Unit tests are in the test folder.

Not sure what the new procedure for adding plugins is, as the howto
doesn't really distinguish between existing plugin authors and
non-authors.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: New plugin - grails inflector

Jeff Brown-3
Tomas Lin wrote:

> Hi,
>
> Would like to add a new plugin to the repo.
>
> https://github.com/tomaslin/grails-inflector
>
> It's basically a simple set of tag libraries that allow you to do
> simple text inflections like<g:pluralize>Pain</g:pluralize>  ->  Pains.
>
> Not a huge plugin but fills a gap between the cool stuff available in
> Rails Text Helpers.
>
> Unit tests are in the test folder.
>
> Not sure what the new procedure for adding plugins is, as the howto
> doesn't really distinguish between existing plugin authors and
> non-authors.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>      http://xircles.codehaus.org/manage_email
>
>

FYI... You should probably put your tags in a namespace.



jb

--
Jeff Brown
SpringSource
http://www.springsource.com/

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: New plugin - grails inflector

tomas lin
it is now in the inf namespace

On Wed, May 23, 2012 at 12:55 AM, Jeff Brown <[hidden email]> wrote:

> Tomas Lin wrote:
>>
>> Hi,
>>
>> Would like to add a new plugin to the repo.
>>
>> https://github.com/tomaslin/grails-inflector
>>
>> It's basically a simple set of tag libraries that allow you to do
>> simple text inflections like<g:pluralize>Pain</g:pluralize>  ->  Pains.
>>
>> Not a huge plugin but fills a gap between the cool stuff available in
>> Rails Text Helpers.
>>
>> Unit tests are in the test folder.
>>
>> Not sure what the new procedure for adding plugins is, as the howto
>> doesn't really distinguish between existing plugin authors and
>> non-authors.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>
> FYI... You should probably put your tags in a namespace.
>
>
>
> jb
>
> --
> Jeff Brown
> SpringSource
> http://www.springsource.com/
>
> Autism Strikes 1 in 166
> Find The Cause ~ Find The Cure
> http://www.autismspeaks.org/
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: New plugin - grails inflector

Nick Vaidyanathan
+1. Pretty sweet functionality. I'm also a fan of the existence of tests.

You know what would make you a God and a King?

  1. cleaning up the directory structure  (get rid of the nasty .idea and other stuff that can be .gitignore d)
  2. stripping out the contents of org.modeshape.common.text.Inflector's initialize() into i18n/ and reading the one for the current locale dynamically, so contributors can augment with Spanish, German, and other pluralizations
From an aesthetic point of view, you may want to consider making Inflector the only public class, but breaking out Rule into a package-private class, and making other similar package-private Service type classes for Underscore, CamelCase, etc etc. (Underscorer, CamelCaser) 

This would make Inflector more like a Domain Driven Design Aggregate Root. Also similar to a Grails Controller that delegates processing to services. Hence, it can expose the same public API, while internally delegating and  returning the results of logic applied in the services.

This would make future maintainability simpler. This would be helpful when the inevitable "could you add underscore support for words that have spaces between them so the preceding looks like could_you_add_underscore_support_for_words_that_have_spaces_between_them" instead of only supporting camelCase words feature request comes in.   

Of course, if this is JBoss code, you may want to consider making that a JBoss contribution as well.   

On Tue, May 22, 2012 at 5:29 PM, Tomas Lin <[hidden email]> wrote:
it is now in the inf namespace

On Wed, May 23, 2012 at 12:55 AM, Jeff Brown <[hidden email]> wrote:
> Tomas Lin wrote:
>>
>> Hi,
>>
>> Would like to add a new plugin to the repo.
>>
>> https://github.com/tomaslin/grails-inflector
>>
>> It's basically a simple set of tag libraries that allow you to do
>> simple text inflections like<g:pluralize>Pain</g:pluralize>  ->  Pains.
>>
>> Not a huge plugin but fills a gap between the cool stuff available in
>> Rails Text Helpers.
>>
>> Unit tests are in the test folder.
>>
>> Not sure what the new procedure for adding plugins is, as the howto
>> doesn't really distinguish between existing plugin authors and
>> non-authors.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>
> FYI... You should probably put your tags in a namespace.
>
>
>
> jb
>
> --
> Jeff Brown
> SpringSource
> http://www.springsource.com/
>
> Autism Strikes 1 in 166
> Find The Cause ~ Find The Cure
> http://www.autismspeaks.org/
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: New plugin - grails inflector

burtbeckwith

Package-private makes it unfriendly for external customization though. I've recently worked with a frustrating API with way too much private and package-private code that forced me to copy/paste entire classes to  customize a trivial aspect of a class. Public and protected ftw :-)

Burt



-----Original Message-----
From: Lead Visionary <[hidden email]>
To: [hidden email]
Sent: Wed, 23 May 2012 2:33 AM
Subject: Re: [grails-dev] New plugin - grails inflector

+1. Pretty sweet functionality. I'm also a fan of the existence of tests.

You know what would make you a God and a King?

  1. cleaning up the directory structure  (get rid of the nasty .idea and other stuff that can be .gitignore d)
  2. stripping out the contents of org.modeshape.common.text.Inflector's initialize() into i18n/ and reading the one for the current locale dynamically, so contributors can augment with Spanish, German, and other pluralizations
From an aesthetic point of view, you may want to consider making Inflector the only public class, but breaking out Rule into a package-private class, and making other similar package-private Service type classes for Underscore, CamelCase, etc etc. (Underscorer, CamelCaser) 

This would make Inflector more like a Domain Driven Design Aggregate Root. Also similar to a Grails Controller that delegates processing to services. Hence, it can expose the same public API, while internally delegating and  returning the results of logic applied in the services.

This would make future maintainability simpler. This would be helpful when the inevitable "could you add underscore support for words that have spaces between them so the preceding looks like could_you_add_underscore_support_for_words_that_have_spaces_between_them" instead of only supporting camelCase words feature request comes in.   

Of course, if this is JBoss code, you may want to consider making that a JBoss contribution as well.   

On Tue, May 22, 2012 at 5:29 PM, Tomas Lin <[hidden email]> wrote:
it is now in the inf namespace

On Wed, May 23, 2012 at 12:55 AM, Jeff Brown <[hidden email]> wrote:
> Tomas Lin wrote:
>>
>> Hi,
>>
>> Would like to add a new plugin to the repo.
>>
>> https://github.com/tomaslin/grails-inflector
>>
>> It's basically a simple set of tag libraries that allow you to do
>> simple text inflections like<g:pluralize>Pain</g:pluralize>  ->  Pains.
>>
>> Not a huge plugin but fills a gap between the cool stuff available in
>> Rails Text Helpers.
>>
>> Unit tests are in the test folder.
>>
>> Not sure what the new procedure for adding plugins is, as the howto
>> doesn't really distinguish between existing plugin authors and
>> non-authors.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>
> FYI... You should probably put your tags in a namespace.
>
>
>
> jb
>
> --
> Jeff Brown
> SpringSource
> http://www.springsource.com/
>
> Autism Strikes 1 in 166
> Find The Cause ~ Find The Cure
> http://www.autismspeaks.org/
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: New plugin - grails inflector

pledbrook
> Package-private makes it unfriendly for external customization though. I've
> recently worked with a frustrating API with way too much private and
> package-private code that forced me to copy/paste entire classes to
> customize a trivial aspect of a class. Public and protected ftw :-)

Wasn't it Josh Bloch who said "design for extensibility or forbid it"? :)

--
Peter Ledbrook
Grails Advocate
SpringSource - A Division of VMware

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: New plugin - grails inflector

tomas lin
Is there anything else I need to do to get this plugin published? Am getting 40x errors with grails 2.0.2 and the publish plugin 2.0.0

The process is not very clear for existing plugin authors.

On May 23, 2012, at 9:30 AM, Peter Ledbrook <[hidden email]> wrote:

>> Package-private makes it unfriendly for external customization though. I've
>> recently worked with a frustrating API with way too much private and
>> package-private code that forced me to copy/paste entire classes to
>> customize a trivial aspect of a class. Public and protected ftw :-)
>
> Wasn't it Josh Bloch who said "design for extensibility or forbid it"? :)
>
> --
> Peter Ledbrook
> Grails Advocate
> SpringSource - A Division of VMware
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: New plugin - grails inflector

Graeme Rocher-4
Administrator
What is your grails.org username?

Cheers

On Wed, May 23, 2012 at 12:42 PM, Tomas Lin <[hidden email]> wrote:

> Is there anything else I need to do to get this plugin published? Am getting 40x errors with grails 2.0.2 and the publish plugin 2.0.0
>
> The process is not very clear for existing plugin authors.
>
> On May 23, 2012, at 9:30 AM, Peter Ledbrook <[hidden email]> wrote:
>
>>> Package-private makes it unfriendly for external customization though. I've
>>> recently worked with a frustrating API with way too much private and
>>> package-private code that forced me to copy/paste entire classes to
>>> customize a trivial aspect of a class. Public and protected ftw :-)
>>
>> Wasn't it Josh Bloch who said "design for extensibility or forbid it"? :)
>>
>> --
>> Peter Ledbrook
>> Grails Advocate
>> SpringSource - A Division of VMware
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>



--
Graeme Rocher
Grails Project Lead
SpringSource - A Division of VMware
http://www.springsource.com

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

RE: New plugin - grails inflector

jonspalmer
In reply to this post by tomas lin
Does the plugin have i18n support or is it English only?

-----Original Message-----
From: Tomas Lin [mailto:[hidden email]]
Sent: Tuesday, May 22, 2012 8:29 PM
To: [hidden email]
Subject: Re: [grails-dev] New plugin - grails inflector

it is now in the inf namespace

On Wed, May 23, 2012 at 12:55 AM, Jeff Brown <[hidden email]> wrote:

> Tomas Lin wrote:
>>
>> Hi,
>>
>> Would like to add a new plugin to the repo.
>>
>> https://github.com/tomaslin/grails-inflector
>>
>> It's basically a simple set of tag libraries that allow you to do
>> simple text inflections like<g:pluralize>Pain</g:pluralize>  ->  Pains.
>>
>> Not a huge plugin but fills a gap between the cool stuff available in
>> Rails Text Helpers.
>>
>> Unit tests are in the test folder.
>>
>> Not sure what the new procedure for adding plugins is, as the howto
>> doesn't really distinguish between existing plugin authors and
>> non-authors.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>
> FYI... You should probably put your tags in a namespace.
>
>
>
> jb
>
> --
> Jeff Brown
> SpringSource
> http://www.springsource.com/
>
> Autism Strikes 1 in 166
> Find The Cause ~ Find The Cure
> http://www.autismspeaks.org/
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email




This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: New plugin - grails inflector

tomas lin
In reply to this post by Graeme Rocher-4
My user name is tomaslin

On Wed, May 23, 2012 at 12:06 PM, Graeme Rocher <[hidden email]> wrote:

> What is your grails.org username?
>
> Cheers
>
> On Wed, May 23, 2012 at 12:42 PM, Tomas Lin <[hidden email]> wrote:
>> Is there anything else I need to do to get this plugin published? Am getting 40x errors with grails 2.0.2 and the publish plugin 2.0.0
>>
>> The process is not very clear for existing plugin authors.
>>
>> On May 23, 2012, at 9:30 AM, Peter Ledbrook <[hidden email]> wrote:
>>
>>>> Package-private makes it unfriendly for external customization though. I've
>>>> recently worked with a frustrating API with way too much private and
>>>> package-private code that forced me to copy/paste entire classes to
>>>> customize a trivial aspect of a class. Public and protected ftw :-)
>>>
>>> Wasn't it Josh Bloch who said "design for extensibility or forbid it"? :)
>>>
>>> --
>>> Peter Ledbrook
>>> Grails Advocate
>>> SpringSource - A Division of VMware
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>
>
>
> --
> Graeme Rocher
> Grails Project Lead
> SpringSource - A Division of VMware
> http://www.springsource.com
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: New plugin - grails inflector

Graeme Rocher-4
Administrator
Approved

Cheers

On Wed, May 23, 2012 at 2:49 PM, Tomas Lin <[hidden email]> wrote:

> My user name is tomaslin
>
> On Wed, May 23, 2012 at 12:06 PM, Graeme Rocher <[hidden email]> wrote:
>> What is your grails.org username?
>>
>> Cheers
>>
>> On Wed, May 23, 2012 at 12:42 PM, Tomas Lin <[hidden email]> wrote:
>>> Is there anything else I need to do to get this plugin published? Am getting 40x errors with grails 2.0.2 and the publish plugin 2.0.0
>>>
>>> The process is not very clear for existing plugin authors.
>>>
>>> On May 23, 2012, at 9:30 AM, Peter Ledbrook <[hidden email]> wrote:
>>>
>>>>> Package-private makes it unfriendly for external customization though. I've
>>>>> recently worked with a frustrating API with way too much private and
>>>>> package-private code that forced me to copy/paste entire classes to
>>>>> customize a trivial aspect of a class. Public and protected ftw :-)
>>>>
>>>> Wasn't it Josh Bloch who said "design for extensibility or forbid it"? :)
>>>>
>>>> --
>>>> Peter Ledbrook
>>>> Grails Advocate
>>>> SpringSource - A Division of VMware
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>>    http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>
>>
>>
>> --
>> Graeme Rocher
>> Grails Project Lead
>> SpringSource - A Division of VMware
>> http://www.springsource.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>



--
Graeme Rocher
Grails Project Lead
SpringSource - A Division of VMware
http://www.springsource.com

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: New plugin - grails inflector

tomas lin
In reply to this post by jonspalmer
It only supports English, but you can add your own rules via the
inflector interface,

i.e,

def inflect = Inflector.instance
inflect.clear()
inflect.addPluralize("$", "s");

etc. See the java file under src for how it is done.

On Wed, May 23, 2012 at 1:19 PM, Jon Palmer <[hidden email]> wrote:

> Does the plugin have i18n support or is it English only?
>
> -----Original Message-----
> From: Tomas Lin [mailto:[hidden email]]
> Sent: Tuesday, May 22, 2012 8:29 PM
> To: [hidden email]
> Subject: Re: [grails-dev] New plugin - grails inflector
>
> it is now in the inf namespace
>
> On Wed, May 23, 2012 at 12:55 AM, Jeff Brown <[hidden email]> wrote:
>> Tomas Lin wrote:
>>>
>>> Hi,
>>>
>>> Would like to add a new plugin to the repo.
>>>
>>> https://github.com/tomaslin/grails-inflector
>>>
>>> It's basically a simple set of tag libraries that allow you to do
>>> simple text inflections like<g:pluralize>Pain</g:pluralize>  ->  Pains.
>>>
>>> Not a huge plugin but fills a gap between the cool stuff available in
>>> Rails Text Helpers.
>>>
>>> Unit tests are in the test folder.
>>>
>>> Not sure what the new procedure for adding plugins is, as the howto
>>> doesn't really distinguish between existing plugin authors and
>>> non-authors.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>     http://xircles.codehaus.org/manage_email
>>>
>>>
>>
>> FYI... You should probably put your tags in a namespace.
>>
>>
>>
>> jb
>>
>> --
>> Jeff Brown
>> SpringSource
>> http://www.springsource.com/
>>
>> Autism Strikes 1 in 166
>> Find The Cause ~ Find The Cure
>> http://www.autismspeaks.org/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>   http://xircles.codehaus.org/manage_email
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>
>
> This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: New plugin - grails inflector

Eric Berry
This is a great plugin. It would probably make a good addition to the core taglibs in Grails. I found that I used it all the time in my Rails projects. Just a thought.

On Wed, May 23, 2012 at 7:12 AM, Tomas Lin <[hidden email]> wrote:
It only supports English, but you can add your own rules via the
inflector interface,

i.e,

def inflect = Inflector.instance
inflect.clear()
inflect.addPluralize("$", "s");

etc. See the java file under src for how it is done.

On Wed, May 23, 2012 at 1:19 PM, Jon Palmer <[hidden email]> wrote:
> Does the plugin have i18n support or is it English only?
>
> -----Original Message-----
> From: Tomas Lin [mailto:[hidden email]]
> Sent: Tuesday, May 22, 2012 8:29 PM
> To: [hidden email]
> Subject: Re: [grails-dev] New plugin - grails inflector
>
> it is now in the inf namespace
>
> On Wed, May 23, 2012 at 12:55 AM, Jeff Brown <[hidden email]> wrote:
>> Tomas Lin wrote:
>>>
>>> Hi,
>>>
>>> Would like to add a new plugin to the repo.
>>>
>>> https://github.com/tomaslin/grails-inflector
>>>
>>> It's basically a simple set of tag libraries that allow you to do
>>> simple text inflections like<g:pluralize>Pain</g:pluralize>  ->  Pains.
>>>
>>> Not a huge plugin but fills a gap between the cool stuff available in
>>> Rails Text Helpers.
>>>
>>> Unit tests are in the test folder.
>>>
>>> Not sure what the new procedure for adding plugins is, as the howto
>>> doesn't really distinguish between existing plugin authors and
>>> non-authors.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>     http://xircles.codehaus.org/manage_email
>>>
>>>
>>
>> FYI... You should probably put your tags in a namespace.
>>
>>
>>
>> jb
>>
>> --
>> Jeff Brown
>> SpringSource
>> http://www.springsource.com/
>>
>> Autism Strikes 1 in 166
>> Find The Cause ~ Find The Cure
>> http://www.autismspeaks.org/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>   http://xircles.codehaus.org/manage_email
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>
>
> This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: New plugin - grails inflector

Nick Vaidyanathan
In reply to this post by pledbrook
That sounds interesting. I'd love to take a look at the package in question and see how you did that. Are you sure you didn't just hack up someone's design decision? :P

Alas, Effective Java is still on my .TODO.

Naively, you could probably get the same type of future extensibility by having pieces you want to be externally customizable via implementation of a public interface. 

So package-private class StandardInflectionRule (the refactored out Rule from Inflector) could implement the Rule interface, which exposes apply(). Then Inflector can just use the Rule interface anywhere.

At this point, you're Programming to an Interface, Not An Implementation. That makes the Gang of Four love you long, long time. It also makes future programmers high five you for treating them like human beings instead of lowly animals. (since they can inject in their own Rules)  

If you don't want to do this-- in that Rule is a final, internal class whose behavior is supposed to be invariant hence why we're trying to limit access to it by nesting it inside of Inflector-- I'd still strip it out, make it final and use package-private.

I guess my main objection is aesthetic. Architectural. Nested inner classes just feel so dirty. So very, very dirty...(>_>) and not in the good way! Rather in the "my eyes! ze Goggles do nothing!" kind of way. 

I know the standard arguments for nesting. I assert they're dead wrong. They make a strong upfront assertion of a tight coupling that may later be proven incorrect, reaching inside to instantiate makes Demeter cry, and they result in code that ultimately leads to "tl;dr, hope it works." 

Programming is writing. The most cognitive we do. The closer we get to Miller's Magic Number and Graham's idea of being able to hold the program in your head, the better we're doing it. Nested classes get in the way of keeping things small. There are better ways to accomplish what they're trying to do. Especially in the age of multiple tabs/files in editor windows. 

I call Regions a modern-day Anti-Pattern. If there's any pieces of code that you're supposed to skip when trying to understand a bigger concept, it shouldn't be there. Put it elsewhere.

Bottom line: Don't use classes as namespaces. Use classes as concepts. Use packages as namespaces, logical groupings of those concepts (in DDD parlance, a Bounded Context). 

One could argue this leads to an explosion in package count. I would turn around and say that feature complete packages should exist separately, be released as JARs/plugins, and included. 

Modularity, in terms of small (and smaller than that!) loosely coupled and highly cohesive components >>> hulking monoliths/Big Ball of Mud.

I see the highest level of programming as immutable, well-tested small and narrowly focused packages that expose useful functionality, which can in turn be chained together to achieve even greater functionality. Like ls and grep...

...or Grails. After all, any framework is a just a collection of useful packages/libraries that simplify application development, included with sugar that glues them together. Packages that use other packages are a Great Honking Idea, let's do more of it! :) 

 On Wed, May 23, 2012 at 1:30 AM, Peter Ledbrook <[hidden email]> wrote:
> Package-private makes it unfriendly for external customization though. I've
> recently worked with a frustrating API with way too much private and
> package-private code that forced me to copy/paste entire classes to
> customize a trivial aspect of a class. Public and protected ftw :-)

Wasn't it Josh Bloch who said "design for extensibility or forbid it"? :)

--
Peter Ledbrook
Grails Advocate
SpringSource - A Division of VMware

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Loading...