You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by Daan Hoogland <DH...@schubergphilis.com> on 2013/07/16 10:59:51 UTC

[DISCUSS] coding convention for method - and class length

LS,

I am looking at a method 200 lines long. I've seen more of those.

I would propose a maximum length of 80 lines per method and
A maximum of 10 methods per class, not including getters and setters of course.

I think this would help with the readability of the source base and thus the growth of the community.

Regards,
Daan Hoogland


RE: [DISCUSS] coding convention for method - and class length

Posted by Donal Lafferty <do...@citrix.com>.
What is the method?

DL

> -----Original Message-----
> From: Daan Hoogland [mailto:DHoogland@schubergphilis.com]
> Sent: 16 July 2013 10:00 AM
> To: dev@cloudstack.apache.org
> Subject: [DISCUSS] coding convention for method - and class length
> 
> LS,
> 
> I am looking at a method 200 lines long. I've seen more of those.
> 
> I would propose a maximum length of 80 lines per method and A maximum
> of 10 methods per class, not including getters and setters of course.
> 
> I think this would help with the readability of the source base and thus the
> growth of the community.
> 
> Regards,
> Daan Hoogland


Re: [DISCUSS] coding convention for method - and class length

Posted by Daan Hoogland <da...@gmail.com>.
John, Chip,

I don't mean to impose laws on people. A convention is by definition a
shared rule of thumb, in my understanding. If I am not correct in my
understanding of the English language and the connotations of the term
convention, I retract my proposal to add these two 'rules' to the coding
conventions.

regards,
Daan


On Fri, Jul 19, 2013 at 10:33 PM, John Burwell <jb...@basho.com> wrote:

> All,
>
> I agree with Chip's sentiments.  Personally, I strive for the "one screen
> full" rule of thumb.  However, I think a hard and fast rule is a bit
> restrictive.
>
> Thanks,
> -John
>
> On Jul 18, 2013, at 5:21 PM, Mike Tutkowski <mi...@solidfire.com>
> wrote:
>
> > Like eight or so years ago, I sent a method I had to modify to the
> printer
> > (so I could study it on regular paper) and it came out on 14 pages.
> >
> >
> > On Thu, Jul 18, 2013 at 3:04 PM, Donal Lafferty
> > <do...@citrix.com>wrote:
> >
> >>> -----Original Message-----
> >>> From: Chip Childers [mailto:chip.childers@sungard.com]
> >>> Sent: 18 July 2013 9:43 PM
> >>> To: dev@cloudstack.apache.org
> >>> Subject: Re: [DISCUSS] coding convention for method - and class length
> >>>
> >>> On Thu, Jul 18, 2013 at 02:34:36PM -0600, Mike Tutkowski wrote:
> >>>> I'm not sure how I feel about an arbitrary number of lines per method
> >>>> (although 200 is obviously quite high and I would recommend
> >>>> modularizing such a method), but I'm not in favor of limiting the
> >>>> number of methods per class (especially not to just 10). Some types of
> >>>> objects simply need many discrete operations and 10 is too limiting.
> >>>
> >>> +1 to both thoughts.
> >>>
> >>> Smaller methods is good, but a specific number of lines as policy vs. a
> >> rule of
> >>> thumb are two different things.
> >>>
> >>> I completely agree with Daan's underlying concern though...  some of
> >> these
> >>> class files are horrible to try and comprehend.
> >>>
> >>> My favorite example:
> >>>
> >>> https://git-wip-
> >>>
> >>
> us.apache.org/repos/asf/cloudstack/?p=cloudstack.git;a=blob_plain;f=plugin
> >>> s/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceB
> >>> ase.java;hb=master
> >>>
> >> [Donal Lafferty]
> >> StyleCheck sets a default limit of 150 lines.
> >>
> >> Meanwhile, have you heard of the function 'best kick' in a certain
> >> company's soccer video game?  IIRC, it's several 1000 lines.
> >>
> >>
> >
> >
> > --
> > *Mike Tutkowski*
> > *Senior CloudStack Developer, SolidFire Inc.*
> > e: mike.tutkowski@solidfire.com
> > o: 303.746.7302
> > Advancing the way the world uses the
> > cloud<http://solidfire.com/solution/overview/?video=play>
> > *™*
>
>

Re: [DISCUSS] coding convention for method - and class length

Posted by John Burwell <jb...@basho.com>.
All,

I agree with Chip's sentiments.  Personally, I strive for the "one screen full" rule of thumb.  However, I think a hard and fast rule is a bit restrictive.

Thanks,
-John

On Jul 18, 2013, at 5:21 PM, Mike Tutkowski <mi...@solidfire.com> wrote:

> Like eight or so years ago, I sent a method I had to modify to the printer
> (so I could study it on regular paper) and it came out on 14 pages.
> 
> 
> On Thu, Jul 18, 2013 at 3:04 PM, Donal Lafferty
> <do...@citrix.com>wrote:
> 
>>> -----Original Message-----
>>> From: Chip Childers [mailto:chip.childers@sungard.com]
>>> Sent: 18 July 2013 9:43 PM
>>> To: dev@cloudstack.apache.org
>>> Subject: Re: [DISCUSS] coding convention for method - and class length
>>> 
>>> On Thu, Jul 18, 2013 at 02:34:36PM -0600, Mike Tutkowski wrote:
>>>> I'm not sure how I feel about an arbitrary number of lines per method
>>>> (although 200 is obviously quite high and I would recommend
>>>> modularizing such a method), but I'm not in favor of limiting the
>>>> number of methods per class (especially not to just 10). Some types of
>>>> objects simply need many discrete operations and 10 is too limiting.
>>> 
>>> +1 to both thoughts.
>>> 
>>> Smaller methods is good, but a specific number of lines as policy vs. a
>> rule of
>>> thumb are two different things.
>>> 
>>> I completely agree with Daan's underlying concern though...  some of
>> these
>>> class files are horrible to try and comprehend.
>>> 
>>> My favorite example:
>>> 
>>> https://git-wip-
>>> 
>> us.apache.org/repos/asf/cloudstack/?p=cloudstack.git;a=blob_plain;f=plugin
>>> s/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceB
>>> ase.java;hb=master
>>> 
>> [Donal Lafferty]
>> StyleCheck sets a default limit of 150 lines.
>> 
>> Meanwhile, have you heard of the function 'best kick' in a certain
>> company's soccer video game?  IIRC, it's several 1000 lines.
>> 
>> 
> 
> 
> -- 
> *Mike Tutkowski*
> *Senior CloudStack Developer, SolidFire Inc.*
> e: mike.tutkowski@solidfire.com
> o: 303.746.7302
> Advancing the way the world uses the
> cloud<http://solidfire.com/solution/overview/?video=play>
> *™*


Re: [DISCUSS] coding convention for method - and class length

Posted by Mike Tutkowski <mi...@solidfire.com>.
Like eight or so years ago, I sent a method I had to modify to the printer
(so I could study it on regular paper) and it came out on 14 pages.


On Thu, Jul 18, 2013 at 3:04 PM, Donal Lafferty
<do...@citrix.com>wrote:

> > -----Original Message-----
> > From: Chip Childers [mailto:chip.childers@sungard.com]
> > Sent: 18 July 2013 9:43 PM
> > To: dev@cloudstack.apache.org
> > Subject: Re: [DISCUSS] coding convention for method - and class length
> >
> > On Thu, Jul 18, 2013 at 02:34:36PM -0600, Mike Tutkowski wrote:
> > > I'm not sure how I feel about an arbitrary number of lines per method
> > > (although 200 is obviously quite high and I would recommend
> > > modularizing such a method), but I'm not in favor of limiting the
> > > number of methods per class (especially not to just 10). Some types of
> > > objects simply need many discrete operations and 10 is too limiting.
> >
> > +1 to both thoughts.
> >
> > Smaller methods is good, but a specific number of lines as policy vs. a
> rule of
> > thumb are two different things.
> >
> > I completely agree with Daan's underlying concern though...  some of
> these
> > class files are horrible to try and comprehend.
> >
> > My favorite example:
> >
> > https://git-wip-
> >
> us.apache.org/repos/asf/cloudstack/?p=cloudstack.git;a=blob_plain;f=plugin
> > s/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceB
> > ase.java;hb=master
> >
> [Donal Lafferty]
> StyleCheck sets a default limit of 150 lines.
>
> Meanwhile, have you heard of the function 'best kick' in a certain
> company's soccer video game?  IIRC, it's several 1000 lines.
>
>


-- 
*Mike Tutkowski*
*Senior CloudStack Developer, SolidFire Inc.*
e: mike.tutkowski@solidfire.com
o: 303.746.7302
Advancing the way the world uses the
cloud<http://solidfire.com/solution/overview/?video=play>
*™*

RE: [DISCUSS] coding convention for method - and class length

Posted by Donal Lafferty <do...@citrix.com>.
> -----Original Message-----
> From: Chip Childers [mailto:chip.childers@sungard.com]
> Sent: 18 July 2013 9:43 PM
> To: dev@cloudstack.apache.org
> Subject: Re: [DISCUSS] coding convention for method - and class length
> 
> On Thu, Jul 18, 2013 at 02:34:36PM -0600, Mike Tutkowski wrote:
> > I'm not sure how I feel about an arbitrary number of lines per method
> > (although 200 is obviously quite high and I would recommend
> > modularizing such a method), but I'm not in favor of limiting the
> > number of methods per class (especially not to just 10). Some types of
> > objects simply need many discrete operations and 10 is too limiting.
> 
> +1 to both thoughts.
> 
> Smaller methods is good, but a specific number of lines as policy vs. a rule of
> thumb are two different things.
> 
> I completely agree with Daan's underlying concern though...  some of these
> class files are horrible to try and comprehend.
> 
> My favorite example:
> 
> https://git-wip-
> us.apache.org/repos/asf/cloudstack/?p=cloudstack.git;a=blob_plain;f=plugin
> s/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceB
> ase.java;hb=master
> 
[Donal Lafferty] 
StyleCheck sets a default limit of 150 lines.

Meanwhile, have you heard of the function 'best kick' in a certain company's soccer video game?  IIRC, it's several 1000 lines.


Re: [DISCUSS] coding convention for method - and class length

Posted by Chip Childers <ch...@sungard.com>.
On Thu, Jul 18, 2013 at 02:34:36PM -0600, Mike Tutkowski wrote:
> I'm not sure how I feel about an arbitrary number of lines per method
> (although 200 is obviously quite high and I would recommend modularizing
> such a method), but I'm not in favor of limiting the number of methods per
> class (especially not to just 10). Some types of objects simply need many
> discrete operations and 10 is too limiting.

+1 to both thoughts.

Smaller methods is good, but a specific number of lines as policy vs. a rule 
of thumb are two different things.

I completely agree with Daan's underlying concern though...  some of
these class files are horrible to try and comprehend.

My favorite example:

https://git-wip-us.apache.org/repos/asf/cloudstack/?p=cloudstack.git;a=blob_plain;f=plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java;hb=master



> 
> 
> On Tue, Jul 16, 2013 at 6:14 AM, Daan Hoogland <da...@gmail.com>wrote:
> 
> > I am all for re-oping discussions on the ten commandments, but let's stick
> > to method and class level for now.
> >
> >
> >
> >
> > On Tue, Jul 16, 2013 at 12:19 PM, Donal Lafferty
> > <do...@citrix.com>wrote:
> >
> > > Hmm.  The original comment was "maximum length of 80 lines per method".
> > >
> > > Did you want to start a new thread covering max characters per line?
> > >
> > > > -----Original Message-----
> > > > From: Isaac Chiang [mailto:isaacchiang@gmail.com]
> > > > Sent: 16 July 2013 11:12 AM
> > > > To: dev@cloudstack.apache.org
> > > > Subject: Re: [DISCUSS] coding convention for method - and class length
> > > >
> > > > +1 for the maximum length per line
> > > >
> > > > I also agree with Wido that around 120 characters will be more fit
> > > current
> > > > needs.
> > > >
> > > >
> > > > Regards
> > > >
> > > > Isaac
> > >
> >
> 
> 
> 
> -- 
> *Mike Tutkowski*
> *Senior CloudStack Developer, SolidFire Inc.*
> e: mike.tutkowski@solidfire.com
> o: 303.746.7302
> Advancing the way the world uses the
> cloud<http://solidfire.com/solution/overview/?video=play>
> *™*

Re: [DISCUSS] coding convention for method - and class length

Posted by Mike Tutkowski <mi...@solidfire.com>.
I'm not sure how I feel about an arbitrary number of lines per method
(although 200 is obviously quite high and I would recommend modularizing
such a method), but I'm not in favor of limiting the number of methods per
class (especially not to just 10). Some types of objects simply need many
discrete operations and 10 is too limiting.


On Tue, Jul 16, 2013 at 6:14 AM, Daan Hoogland <da...@gmail.com>wrote:

> I am all for re-oping discussions on the ten commandments, but let's stick
> to method and class level for now.
>
>
>
>
> On Tue, Jul 16, 2013 at 12:19 PM, Donal Lafferty
> <do...@citrix.com>wrote:
>
> > Hmm.  The original comment was "maximum length of 80 lines per method".
> >
> > Did you want to start a new thread covering max characters per line?
> >
> > > -----Original Message-----
> > > From: Isaac Chiang [mailto:isaacchiang@gmail.com]
> > > Sent: 16 July 2013 11:12 AM
> > > To: dev@cloudstack.apache.org
> > > Subject: Re: [DISCUSS] coding convention for method - and class length
> > >
> > > +1 for the maximum length per line
> > >
> > > I also agree with Wido that around 120 characters will be more fit
> > current
> > > needs.
> > >
> > >
> > > Regards
> > >
> > > Isaac
> >
>



-- 
*Mike Tutkowski*
*Senior CloudStack Developer, SolidFire Inc.*
e: mike.tutkowski@solidfire.com
o: 303.746.7302
Advancing the way the world uses the
cloud<http://solidfire.com/solution/overview/?video=play>
*™*

Re: [DISCUSS] coding convention for method - and class length

Posted by Daan Hoogland <da...@gmail.com>.
I am all for re-oping discussions on the ten commandments, but let's stick
to method and class level for now.




On Tue, Jul 16, 2013 at 12:19 PM, Donal Lafferty
<do...@citrix.com>wrote:

> Hmm.  The original comment was "maximum length of 80 lines per method".
>
> Did you want to start a new thread covering max characters per line?
>
> > -----Original Message-----
> > From: Isaac Chiang [mailto:isaacchiang@gmail.com]
> > Sent: 16 July 2013 11:12 AM
> > To: dev@cloudstack.apache.org
> > Subject: Re: [DISCUSS] coding convention for method - and class length
> >
> > +1 for the maximum length per line
> >
> > I also agree with Wido that around 120 characters will be more fit
> current
> > needs.
> >
> >
> > Regards
> >
> > Isaac
>

RE: [DISCUSS] coding convention for method - and class length

Posted by Donal Lafferty <do...@citrix.com>.
Hmm.  The original comment was "maximum length of 80 lines per method".

Did you want to start a new thread covering max characters per line?

> -----Original Message-----
> From: Isaac Chiang [mailto:isaacchiang@gmail.com]
> Sent: 16 July 2013 11:12 AM
> To: dev@cloudstack.apache.org
> Subject: Re: [DISCUSS] coding convention for method - and class length
> 
> +1 for the maximum length per line
> 
> I also agree with Wido that around 120 characters will be more fit current
> needs.
> 
> 
> Regards
> 
> Isaac

Re: [DISCUSS] coding convention for method - and class length

Posted by Isaac Chiang <is...@gmail.com>.
+1 for the maximum length per line

I also agree with Wido that around 120 characters will be more fit current
needs.


Regards

Isaac

Re: [DISCUSS] coding convention for method - and class length

Posted by Wido den Hollander <wi...@widodh.nl>.
Hi,

On 07/16/2013 10:59 AM, Daan Hoogland wrote:
> LS,
>
> I am looking at a method 200 lines long. I've seen more of those.
>

Yes, that is pretty long.

> I would propose a maximum length of 80 lines per method and

There was a recent discussion about this, but I wasn't able to find it 
that quickly.

I'm against the 80 characters per line since we are no longer working on 
such small screens.

Something like ~120 would be fine imho.

Wido

> A maximum of 10 methods per class, not including getters and setters of course.
>
> I think this would help with the readability of the source base and thus the growth of the community.
>
> Regards,
> Daan Hoogland
>
>