You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@solr.apache.org by Houston Putman <ho...@apache.org> on 2023/01/03 16:38:50 UTC

Re: Naming builder methods?

I vote for the "with" option. Seems to be the most common builder pattern.

- Houston

On Thu, Dec 29, 2022 at 7:41 AM Eric Pugh <ep...@opensourceconnections.com>
wrote:

> Hi all,
>
> I wanted to drop a note and ask if there were any standards/patterns that
> we use in Solr (or want to use!) for naming methods for builders?
>
> I put some notes on some of the flavours of names we use on
> https://issues.apache.org/jira/browse/SOLR-16590 and would love some
> feedback.
>
> Eric
>
> _______________________
> Eric Pugh | Founder & CEO | OpenSource Connections, LLC | 434.466.1467 |
> http://www.opensourceconnections.com <
> http://www.opensourceconnections.com/> | My Free/Busy <
> http://tinyurl.com/eric-cal>
> Co-Author: Apache Solr Enterprise Search Server, 3rd Ed <
> https://www.packtpub.com/big-data-and-business-intelligence/apache-solr-enterprise-search-server-third-edition-raw>
>
> This e-mail and all contents, including attachments, is considered to be
> Company Confidential unless explicitly stated otherwise, regardless of
> whether attachments are marked as such.
>
>

Re: Naming builder methods?

Posted by David Smiley <ds...@apache.org>.
True; I have no strong preference.  Sometimes we only need one side of the
boolean.

~ David Smiley
Apache Lucene/Solr Search Developer
http://www.linkedin.com/in/davidwsmiley


On Wed, Jan 4, 2023 at 1:26 PM Jason Gerlowski <ge...@gmail.com>
wrote:

> +1 to "with" over "set" where it makes sense.
>
> > Arguably, a pair of methods "sendUpdatesInParallel()" and
> "sendUpdatesSerially()" would read more naturally.
>
> It definitely "reads" more naturally.  Though it's worth pointing out the
> (potential) downside of this approach for boolean options: using two
> methods makes the mutual-exclusivity less explicit if the names aren't
> crystal-clear.  (Not that I'm against the twin-method approach.  It just
> has to be used very carefully IMO.)
>
> On Wed, Jan 4, 2023 at 12:42 AM David Smiley <ds...@apache.org> wrote:
>
> > Right; it should aim to read naturally as if in English, that's the idea.
> > We can *prefer* the "with" prefix but some parameters might be expressed
> > more clearly in some other way, especially if boolean.  In
> > CloudHttp2SolrClient, I see one "sendDirectUpdatesToShardLeadersOnly()"
> > which I think is clear.  There is a "withParallelUpdates(boolean)" right
> > next to that.  Arguably, a pair of methods "sendUpdatesInParallel()" and
> > "sendUpdatesSerially()" would read more naturally.
> >
> > ~ David Smiley
> > Apache Lucene/Solr Search Developer
> > http://www.linkedin.com/in/davidwsmiley
> >
> >
> > On Tue, Jan 3, 2023 at 11:39 AM Houston Putman <ho...@apache.org>
> wrote:
> >
> > > I vote for the "with" option. Seems to be the most common builder
> > pattern.
> > >
> > > - Houston
> > >
> > > On Thu, Dec 29, 2022 at 7:41 AM Eric Pugh <
> > epugh@opensourceconnections.com
> > > >
> > > wrote:
> > >
> > > > Hi all,
> > > >
> > > > I wanted to drop a note and ask if there were any standards/patterns
> > that
> > > > we use in Solr (or want to use!) for naming methods for builders?
> > > >
> > > > I put some notes on some of the flavours of names we use on
> > > > https://issues.apache.org/jira/browse/SOLR-16590 and would love some
> > > > feedback.
> > > >
> > > > Eric
> > > >
> > > > _______________________
> > > > Eric Pugh | Founder & CEO | OpenSource Connections, LLC |
> 434.466.1467
> > |
> > > > http://www.opensourceconnections.com <
> > > > http://www.opensourceconnections.com/> | My Free/Busy <
> > > > http://tinyurl.com/eric-cal>
> > > > Co-Author: Apache Solr Enterprise Search Server, 3rd Ed <
> > > >
> > >
> >
> https://www.packtpub.com/big-data-and-business-intelligence/apache-solr-enterprise-search-server-third-edition-raw
> > > >
> > > >
> > > > This e-mail and all contents, including attachments, is considered to
> > be
> > > > Company Confidential unless explicitly stated otherwise, regardless
> of
> > > > whether attachments are marked as such.
> > > >
> > > >
> > >
> >
>

Re: Naming builder methods?

Posted by Jason Gerlowski <ge...@gmail.com>.
+1 to "with" over "set" where it makes sense.

> Arguably, a pair of methods "sendUpdatesInParallel()" and
"sendUpdatesSerially()" would read more naturally.

It definitely "reads" more naturally.  Though it's worth pointing out the
(potential) downside of this approach for boolean options: using two
methods makes the mutual-exclusivity less explicit if the names aren't
crystal-clear.  (Not that I'm against the twin-method approach.  It just
has to be used very carefully IMO.)

On Wed, Jan 4, 2023 at 12:42 AM David Smiley <ds...@apache.org> wrote:

> Right; it should aim to read naturally as if in English, that's the idea.
> We can *prefer* the "with" prefix but some parameters might be expressed
> more clearly in some other way, especially if boolean.  In
> CloudHttp2SolrClient, I see one "sendDirectUpdatesToShardLeadersOnly()"
> which I think is clear.  There is a "withParallelUpdates(boolean)" right
> next to that.  Arguably, a pair of methods "sendUpdatesInParallel()" and
> "sendUpdatesSerially()" would read more naturally.
>
> ~ David Smiley
> Apache Lucene/Solr Search Developer
> http://www.linkedin.com/in/davidwsmiley
>
>
> On Tue, Jan 3, 2023 at 11:39 AM Houston Putman <ho...@apache.org> wrote:
>
> > I vote for the "with" option. Seems to be the most common builder
> pattern.
> >
> > - Houston
> >
> > On Thu, Dec 29, 2022 at 7:41 AM Eric Pugh <
> epugh@opensourceconnections.com
> > >
> > wrote:
> >
> > > Hi all,
> > >
> > > I wanted to drop a note and ask if there were any standards/patterns
> that
> > > we use in Solr (or want to use!) for naming methods for builders?
> > >
> > > I put some notes on some of the flavours of names we use on
> > > https://issues.apache.org/jira/browse/SOLR-16590 and would love some
> > > feedback.
> > >
> > > Eric
> > >
> > > _______________________
> > > Eric Pugh | Founder & CEO | OpenSource Connections, LLC | 434.466.1467
> |
> > > http://www.opensourceconnections.com <
> > > http://www.opensourceconnections.com/> | My Free/Busy <
> > > http://tinyurl.com/eric-cal>
> > > Co-Author: Apache Solr Enterprise Search Server, 3rd Ed <
> > >
> >
> https://www.packtpub.com/big-data-and-business-intelligence/apache-solr-enterprise-search-server-third-edition-raw
> > >
> > >
> > > This e-mail and all contents, including attachments, is considered to
> be
> > > Company Confidential unless explicitly stated otherwise, regardless of
> > > whether attachments are marked as such.
> > >
> > >
> >
>

Re: Naming builder methods?

Posted by David Smiley <ds...@apache.org>.
Right; it should aim to read naturally as if in English, that's the idea.
We can *prefer* the "with" prefix but some parameters might be expressed
more clearly in some other way, especially if boolean.  In
CloudHttp2SolrClient, I see one "sendDirectUpdatesToShardLeadersOnly()"
which I think is clear.  There is a "withParallelUpdates(boolean)" right
next to that.  Arguably, a pair of methods "sendUpdatesInParallel()" and
"sendUpdatesSerially()" would read more naturally.

~ David Smiley
Apache Lucene/Solr Search Developer
http://www.linkedin.com/in/davidwsmiley


On Tue, Jan 3, 2023 at 11:39 AM Houston Putman <ho...@apache.org> wrote:

> I vote for the "with" option. Seems to be the most common builder pattern.
>
> - Houston
>
> On Thu, Dec 29, 2022 at 7:41 AM Eric Pugh <epugh@opensourceconnections.com
> >
> wrote:
>
> > Hi all,
> >
> > I wanted to drop a note and ask if there were any standards/patterns that
> > we use in Solr (or want to use!) for naming methods for builders?
> >
> > I put some notes on some of the flavours of names we use on
> > https://issues.apache.org/jira/browse/SOLR-16590 and would love some
> > feedback.
> >
> > Eric
> >
> > _______________________
> > Eric Pugh | Founder & CEO | OpenSource Connections, LLC | 434.466.1467 |
> > http://www.opensourceconnections.com <
> > http://www.opensourceconnections.com/> | My Free/Busy <
> > http://tinyurl.com/eric-cal>
> > Co-Author: Apache Solr Enterprise Search Server, 3rd Ed <
> >
> https://www.packtpub.com/big-data-and-business-intelligence/apache-solr-enterprise-search-server-third-edition-raw
> >
> >
> > This e-mail and all contents, including attachments, is considered to be
> > Company Confidential unless explicitly stated otherwise, regardless of
> > whether attachments are marked as such.
> >
> >
>