Skip to content

Adjusted code examples according to "The auto Keyword" section, did a minor fix in the section#163

Merged
thewtex merged 2 commits intoInsightSoftwareConsortium:masterfrom
N-Dekker:small-auto-improvements
Oct 21, 2021
Merged

Adjusted code examples according to "The auto Keyword" section, did a minor fix in the section#163
thewtex merged 2 commits intoInsightSoftwareConsortium:masterfrom
N-Dekker:small-auto-improvements

Conversation

@N-Dekker
Copy link
Contributor

No description provided.

Just a nitpick... in C++ (even before using `auto`), the following is
an initialization, not an assignment:

    ImageType::Pointer image = ImageType::New();
In accordance with the ITK Coding Style, section The auto Keyword:

> The `auto` keyword should be used to specify a type in the following cases:
> -  The type is duplicated on the left side of an initialization when
>    it is mandated on the right side, e.g. when there is an explicit
>    cast or initializing with `new` or ITK's `::New()`.
...

Suggested by Jon Haitz Legarreta Gorroño as part of the review of
pull request InsightSoftwareConsortium/ITK#2826
"STYLE: Use `auto` for declaration of variables initialized by `New()`"
@N-Dekker N-Dekker force-pushed the small-auto-improvements branch from 7e22e17 to 49c2bf0 Compare October 20, 2021 16:31
@jhlegarreta
Copy link
Member

Thanks for doing this @N-Dekker 💯. Having a clear set of guidelines and examples is essential !

Have not gone through all LaTeX sources. Wondering whether this set of changes is exhaustive.

@jhlegarreta jhlegarreta requested a review from thewtex October 20, 2021 18:49
@N-Dekker
Copy link
Contributor Author

@jhlegarreta You're welcome! Do you think it would be worth to also apply this adjustment (using auto for variables initialized by New()) to the C++ source files at https://github.com/InsightSoftwareConsortium/ITKSoftwareGuide/tree/master/SoftwareGuide/Cover/Source ? There hasn't been any maintenance on those files for almost 2 years!

@jhlegarreta
Copy link
Member

Do you think it would be worth to also apply this adjustment (using auto for variables initialized by New()) to the C++ source files at https://github.com/InsightSoftwareConsortium/ITKSoftwareGuide/tree/master/SoftwareGuide/Cover/Source ?

Although these seem to be only used to generate the cover illustration, being consistent is a good value I think. I assume doing this is a simultaneous replacement done automatically in your editor, so 👍 for doing it.

There hasn't been any maintenance on those files for almost 2 years!

Keeping the ITK SW Guide up-to-date takes time, but it is worthwhile. Sharing the effort makes it easier and more enjoyable.

Thanks.

@N-Dekker
Copy link
Contributor Author

N-Dekker commented Oct 21, 2021

@jhlegarreta

Do you think it would be worth to also apply this adjustment (using auto for variables initialized by New()) to the C++ source files at https://github.com/InsightSoftwareConsortium/ITKSoftwareGuide/tree/master/SoftwareGuide/Cover/Source ?

Although these seem to be only used to generate the cover illustration, being consistent is a good value I think. I assume doing this is a simultaneous replacement done automatically in your editor, so 👍 for doing it.

Thanks Jon. Personally I would first like to see this pull request being merged, while it is still a small and obvious improvement, that can be reviewed easily. Then later, we can always further extend the auto section, and do more code adjustments. OK?

@thewtex thewtex merged commit 2f8e7e8 into InsightSoftwareConsortium:master Oct 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants