Re: [jgroups-users] Getters and setters in 4.0
Questions/problems related to using JGroups <[email protected]>
| Newsgroups | gmane.comp.java.javagroups.general |
|---|---|
| Message-ID | <[email protected]> |
On 07/07/16 19:36, Questions/problems related to using JGroups wrote: > I think removing get/set is a bad idea for reasons expressed already. > Furthermore it will reduce the effectiveness of code > analysis/introspection tools which understand the concept of > getters/setters that start with get/set. Which ones? It's not hard to identify methods which return a field as getters and methods which take one parameter and set a field as setters. There's actually code in JGroups which exposes such methods as managed attributes if @ManagedAttribute is used on a method. > It will make > autolookup/complete more frustrating IMO. Get/set imply a usage contract > that could no longer be assumed as in the get/setBlock vs block > example. I prefer longer unambiguous names because my memory is more > conceptual than detailed and I would prefer not to have to refer to the > docs every time I need to do anything 'just to be sure'. OK, I concede that the block() - setBlock() example makes sense. > On top of that I am not a fan of the fluent API approach with the exception of the > builder pattern for immutable objects or perhaps where concatenation is > needed. OK, so I'll stick with getters and setters in the classic sense for now... Thanks for the feedback! > On Thu, Jul 7, 2016 at 9:50 AM, Questions/problems related to using > JGroups <[email protected] > <mailto:[email protected]>> wrote: > > <IMHO> > Removing the "set" or "get" could lead to a reduction in the clarity > of intent of the method. For example, if you have a method named > "setBlock" and it is renamed to "block", that could be confusing > because "block" is now the verb and one might interpret that as a > method to block execution. > > I always lean towards more readable code even if it means more > keystrokes (longer names). Unless the Java standards have changed > to a new pattern for setters and getters, I would make the code > consistent and inline with the industry standard. > </IMHO> > > -----Original Message----- > From: Questions/problems related to using JGroups > [mailto:[email protected] > <mailto:[email protected]>] > Sent: Thursday, July 7, 2016 9:25 AM > To: [email protected] > <mailto:[email protected]> > Subject: Re: [jgroups-users] Getters and setters in 4.0 > > Has there been an Java industry standards change? From setName() to > name()? > > > Thanks, > > Mike. > > > -----Original Message----- > From: Questions/problems related to using JGroups > [mailto:[email protected] > <mailto:[email protected]>] > Sent: Thursday, July 7, 2016 9:22 AM > To: [email protected] > <mailto:[email protected]> > Subject: Re: [jgroups-users] Getters and setters in 4.0 > > > > On 07/07/16 18:18, Questions/problems related to using JGroups wrote: > > Hi Bela, > > > > What do you mean by old-style and new-style setters and getters? > What is the difference? > > getName() versus name(), or setName(String) versus name(String) > > > > > > > Thanks, > > > > Mike. > > > > -----Original Message----- > > From: Questions/problems related to using JGroups > > [mailto:[email protected] > <mailto:[email protected]>] > > Sent: Thursday, July 7, 2016 8:59 AM > > To: jg-users > > Subject: [jgroups-users] Getters and setters in 4.0 > > > > I'm thinking of changing getters and setters in public classes in > 4.0, e.g. > > > > JChannel: > > - Address getAddress() -> Address address() > > - String getName() -> String name() > > - JChannel setName(String name) -> JChannel name(String name) > > > > Message: > > - Address getDest() -> Address dest() > > - Message setDest(Address d) -> Message dest(Address d) > > > > > > This basically removes the 'get' and 'set' prefix, plus setters > always return the current class, so they can be chained (fluent API). > > > > Currently, we have a mix of old-style and new-style > getters/setters, and I want to be consistent in all public APIs. > > > > The only downside I can see is that when browsing a class, one > doesn't immediately see all getters and setters in one place. > > > > I know that this is largely a matter of taste, but I do like the > shorter names... > > > > Comments, thoughts? > > > > -- > > Bela Ban, JGroups lead (http://www.jgroups.org) > > > > > > > ---------------------------------------------------------------------- > > -------- Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T > > Park in San Francisco, CA to explore cutting-edge tech and listen to > > tech luminaries present their vision of the future. This family event > > has something for everyone, including kids. Get more information and > > register today. > > http://sdm.link/attshape > > _______________________________________________ > > javagroups-users mailing list > > [email protected] > <mailto:[email protected]> > > https://lists.sourceforge.net/lists/listinfo/javagroups-users > > > > > ---------------------------------------------------------------------- > > -------- Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T > > Park in San Francisco, CA to explore cutting-edge tech and listen to > > tech luminaries present their vision of the future. This family event > > has something for everyone, including kids. Get more information and > > register today. > > http://sdm.link/attshape > > _______________________________________________ > > javagroups-users mailing list > > [email protected] > <mailto:[email protected]> > > https://lists.sourceforge.net/lists/listinfo/javagroups-users > > > > -- > Bela Ban, JGroups lead (http://www.jgroups.org) > > > ------------------------------------------------------------------------------ > Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San > Francisco, CA to explore cutting-edge tech and listen to tech luminaries > present their vision of the future. This family event has something for > everyone, including kids. Get more information and register today. > http://sdm.link/attshape > _______________________________________________ > javagroups-users mailing list > [email protected] > <mailto:[email protected]> > https://lists.sourceforge.net/lists/listinfo/javagroups-users > > ------------------------------------------------------------------------------ > Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San > Francisco, CA to explore cutting-edge tech and listen to tech luminaries > present their vision of the future. This family event has something for > everyone, including kids. Get more information and register today. > http://sdm.link/attshape > _______________________________________________ > javagroups-users mailing list > [email protected] > <mailto:[email protected]> > https://lists.sourceforge.net/lists/listinfo/javagroups-users > > ------------------------------------------------------------------------------ > Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San > Francisco, CA to explore cutting-edge tech and listen to tech luminaries > present their vision of the future. This family event has something for > everyone, including kids. Get more information and register today. > http://sdm.link/attshape > _______________________________________________ > javagroups-users mailing list > [email protected] > <mailto:[email protected]> > https://lists.sourceforge.net/lists/listinfo/javagroups-users > > > > > ------------------------------------------------------------------------------ > Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San > Francisco, CA to explore cutting-edge tech and listen to tech luminaries > present their vision of the future. This family event has something for > everyone, including kids. Get more information and register today. > http://sdm.link/attshape > > > > _______________________________________________ > javagroups-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/javagroups-users > -- Bela Ban, JGroups lead (http://www.jgroups.org) ------------------------------------------------------------------------------ Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San Francisco, CA to explore cutting-edge tech and listen to tech luminaries present their vision of the future. This family event has something for everyone, including kids. Get more information and register today. http://sdm.link/attshape