Coding standards

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Coding standards

Ron Wheeler
https://github.com/adaptlearning/documentation/blob/master/01_cross_workstream/style_guide.md
is a guide for coding of Adapt - Open Source course delivery tool .

I am not sure that I agree with all of the rules.
Some are much better than the ones that I would choose but perhaps I am
just too lazy to do the extra work to make my code easier to read.

They seem to think that computers have more time to parse code than
people do to ponder obscurity and seem to feel that the addition of
extra lines of code to make the code clearer is worth the extra 1/1000
of a nanosecond that it costs.
"Use descriptive conditions" is an example of a frivolous waste of
valuable computer time just to save people having to think.
"Meaningful aliases" is another example of adding a line of code just to
make the code easier for humans.

If you are not offended by the waste of computer resources at compile
time, you might consider adapting some of these rules to OFBiz java.

I am not sure that they their "Don't use setters" instructions will help
the DI  or IoC crowd but they are JavaScript devotees who apparently do
not follow the Spring model.

Ron

--
Ron Wheeler
President
Artifact Software Inc
email: [hidden email]
skype: ronaldmwheeler
phone: 866-970-2435, ext 102

Reply | Threaded
Open this post in threaded view
|

Re: Coding standards

Jacques Le Roux
Administrator
I guess you know we already have https://cwiki.apache.org/confluence/display/OFBADMIN/Coding+Conventions

"Use descriptive conditions" and "Meaningful aliases" are interesting and we could indeed add 2 lines about that in the page above (just after the
link to the old Sun conventions)

I don't agree with their "Use multi-line ternary operator" rule but I don't want to engage in a discussion about this nor all other cases.

Setters existed long ago Spring went to life ;)

Jacques

Le 08/07/2015 05:34, Ron Wheeler a écrit :

> https://github.com/adaptlearning/documentation/blob/master/01_cross_workstream/style_guide.md
> is a guide for coding of Adapt - Open Source course delivery tool .
>
> I am not sure that I agree with all of the rules.
> Some are much better than the ones that I would choose but perhaps I am just too lazy to do the extra work to make my code easier to read.
>
> They seem to think that computers have more time to parse code than people do to ponder obscurity and seem to feel that the addition of extra lines
> of code to make the code clearer is worth the extra 1/1000 of a nanosecond that it costs.
> "Use descriptive conditions" is an example of a frivolous waste of valuable computer time just to save people having to think.
> "Meaningful aliases" is another example of adding a line of code just to make the code easier for humans.
>
> If you are not offended by the waste of computer resources at compile time, you might consider adapting some of these rules to OFBiz java.
>
> I am not sure that they their "Don't use setters" instructions will help the DI  or IoC crowd but they are JavaScript devotees who apparently do not
> follow the Spring model.
>
> Ron
>
Reply | Threaded
Open this post in threaded view
|

Re: Coding standards

taher
Hi Ron and Jacques,

Interesting read on the conventions Ron, thank you for sharing. If I may throw in my 2 cents, I think both getters and setters are one of the worst things to happen in the Java world and people seem to be completely brainwashed by it. We should probably limit their use to frameworks that force us to have them, not more.

Here are some references as to why we should avoid getters and setters:

http://www.martinfowler.com/bliki/AnemicDomainModel.html 
https://en.wikipedia.org/wiki/Anemic_domain_model 
http://www.javaworld.com/article/2072302/core-java/more-on-getters-and-setters.html 
http://www.javaworld.com/article/2073723/core-java/why-getter-and-setter-methods-are-evil.html 

Taher Alkhateeb


----- Original Message -----

From: "Jacques Le Roux" <[hidden email]>
To: [hidden email]
Sent: Wednesday, 8 July, 2015 10:22:48 AM
Subject: Re: Coding standards

I guess you know we already have https://cwiki.apache.org/confluence/display/OFBADMIN/Coding+Conventions 

"Use descriptive conditions" and "Meaningful aliases" are interesting and we could indeed add 2 lines about that in the page above (just after the
link to the old Sun conventions)

I don't agree with their "Use multi-line ternary operator" rule but I don't want to engage in a discussion about this nor all other cases.

Setters existed long ago Spring went to life ;)

Jacques

Le 08/07/2015 05:34, Ron Wheeler a écrit :

> https://github.com/adaptlearning/documentation/blob/master/01_cross_workstream/style_guide.md 
> is a guide for coding of Adapt - Open Source course delivery tool .
>
> I am not sure that I agree with all of the rules.
> Some are much better than the ones that I would choose but perhaps I am just too lazy to do the extra work to make my code easier to read.
>
> They seem to think that computers have more time to parse code than people do to ponder obscurity and seem to feel that the addition of extra lines
> of code to make the code clearer is worth the extra 1/1000 of a nanosecond that it costs.
> "Use descriptive conditions" is an example of a frivolous waste of valuable computer time just to save people having to think.
> "Meaningful aliases" is another example of adding a line of code just to make the code easier for humans.
>
> If you are not offended by the waste of computer resources at compile time, you might consider adapting some of these rules to OFBiz java.
>
> I am not sure that they their "Don't use setters" instructions will help the DI or IoC crowd but they are JavaScript devotees who apparently do not
> follow the Spring model.
>
> Ron
>