Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [hono-dev] Code style - alignment of fields

If there are no strong opinions on this, I would suggest disabling the field alignment setting.


The current Hono code is not consistently having such an aligned formatting and imho the majority of open source projects doesn't use this. At least I have rarely seen it. And having to change the alignment of all fields (in a group) when adding a new field doesn't sound good.




One other thing that I found distracting was the convention to use "final" for method parameters.

As I've come to learn from "Clean code" literature, method parameters are to be treated as implicitly final anyway, and the IDE will give me a warning if I assign a value to it. In that respect, adding "final" just adds unnecessary noise. A similar opinion can be seen in [1].

(Of course I don't mean cases here where omitting the "final" would cause compilation errors.)


What is your take on this? Can we get away from advocating/requiring usage of "final" for all method params?

Carsten


[1] http://www.adam-bien.com/roller/abien/entry/final_method_parameters_should_generate




Von: hono-dev-bounces@xxxxxxxxxxx <hono-dev-bounces@xxxxxxxxxxx> im Auftrag von Kai <sophokles.kh@xxxxxxxxx>
Gesendet: Dienstag, 14. März 2017 07:51
An: hono developer discussions
Betreff: Re: [hono-dev] Code style - alignment of fields
 

Thanks for your input and ideas, guys. So far, we haven't put a lot of effort in enforcing compliance with formatting rules. The most important ones seem to be evident from the code itself and most of the more specific ones I have to admit I personally do not care very much about, e.g. I can live with both indentation styles regarding field declarations.
If the lack of rigidness in this area is making it hard for people to contribute, then IMHO we need to improve on it.
Other opinions?

Kai


Till Markus (INST-CSS/BSV-OS) <Markus.Till@xxxxxxxxxxxx> schrieb am Mo., 13. März 2017, 09:58:

Hi,

to me it always was kind of error prone to depend on IDE settings to get a consistent formatting for a project.

Would it may be an idea to introduce some maven based approach to enforce styling e.g. checkstyle. This also could be used to enforce the eclipse settings. In addition it would address the issue of already nonstandard formatted code in the project and can be later used as build breaker.

 

Just an idea…

 

Greetings!

 

 

Markus Till

 

Bosch Software Innovations GmbH

Schöneberger Ufer 89-91

10785 Berlin

GERMANY

Von: hono-dev-bounces@xxxxxxxxxxx [mailto:hono-dev-bounces@xxxxxxxxxxx] Im Auftrag von Lohmann Carsten (INST/ECS4)
Gesendet: Montag, 13.
März 2017 09:45
An: hono-dev@xxxxxxxxxxx
Betreff: [hono-dev] Code style - alignment of fields

 

Hi,

when formatting the code using the checked-in eclipse code style settings, the alignment of fields looks odd;
e.g. VertxBasedRestProtocolAdapter:

    private HttpServer                                              server;
    private HonoClient                                              hono;
    private HonoConfigProperties                                    config;

    private BiConsumer<String, Handler<AsyncResult<MessageSender>>> eventSenderSupplier;
    private BiConsumer<String, Handler<AsyncResult<MessageSender>>> telemetrySenderSupplier;



With the additional eclipse formatter setting "Blank lines separating independent groups: 1", it would look better:

    private HttpServer           server;
    private HonoClient           hono;
    private HonoConfigProperties config;

    private BiConsumer<String, Handler<AsyncResult<MessageSender>>> eventSenderSupplier;
    private BiConsumer<String, Handler<AsyncResult<MessageSender>>> telemetrySenderSupplier;


Or can the field alignment setting be disabled altogether?
Many classes are currently not formatted according to this setting anyway (also
VertxBasedRestProtocolAdapter).

--
Best regards

Carsten Lohmann

Bosch Software Innovations GmbH
Schöneberger Ufer 89-91
10785 Berlin
GERMANY

_______________________________________________
hono-dev mailing list
hono-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/hono-dev

Back to the top