styleguides icon indicating copy to clipboard operation
styleguides copied to clipboard

Use && for splitting long texts to multiple lines and aliases for interface members

Open shafiq2601 opened this issue 4 years ago • 6 comments

Updated as per comments in the previous pull request.

shafiq2601 avatar May 21 '21 16:05 shafiq2601

Personally, I am not a fan of the ALIASES. I usually recommend the following approach:

For instance: image

The class returns its instance typed as the interface so that the caller doesn't need to call the interface~method.

Ps: singleton is optional.

lucasborin avatar Jun 24 '21 19:06 lucasborin

There are two concepts in this pull request. Ideally, create two pull requests so that they can be reviewed individually.

As for the aliases, like mentioned by @lucasborin, you should use a reference to the interface type instead of the class if possible.

jordao76 avatar Mar 18 '22 12:03 jordao76

I agree with concept 1 to split strings, but I am not in favour of the aliases part (separate PRs are better).

Long names may be inconvenient at times, but for attributes they serve a reminder that you are assigning public API attributes. For methods, a class calling its own API can be a code smell so classes should rarely be calling methods of interfaces they implement.

Aliases have their own problems and make refactoring fragile, see discussion at #176

Personally I rarely see interface qualifiers as a big readability problem, so in my opinion people can do it in private and where it makes sense, but am not in favour of putting it in the style guide as that would suggest creating aliases by default.

pokrakam avatar Mar 30 '22 14:03 pokrakam

We'll try to split this PR.

HrFlorianHoffmann avatar Jul 18 '22 14:07 HrFlorianHoffmann

FYI - I think this is the previous PR: https://github.com/SAP/styleguides/pull/212

sautermi0 avatar Jul 18 '22 14:07 sautermi0

@shafiq2601 Hi Shafiquel! Tried to contact you but couldn't find up-to-date contact information, as you seem to have left SAP Labs in the meantime.

If you are still interested in this topic, could you split this Pull Request into two as advised above by N2oB6n-SAP? We'd like to merge the part with the "&&" concatenation, and splitting would be the easiest way to retain your contribution in GitHub's history. The second topic needs more discussion and we'd like to address it in a separate Pull Request.

If I don't hear from you, I'd go ahead and clone the branch to split this on my own. I am not sure I can retain your name in the history by this, then, however.

HrFlorianHoffmann avatar Jul 22 '22 07:07 HrFlorianHoffmann

  • Couldn't reach the original author
  • We'd like to split this, keeping the "Use && to split long text part",
  • But discarding the alias part as we prefer the way it is without
  • Split this PR by myself, in https://github.com/SAP/styleguides/pull/298
  • Mentioning Shafiquel as co-author in the commit message, as described in https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors
  • Closing this PR

HrFlorianHoffmann avatar Feb 06 '23 13:02 HrFlorianHoffmann