Skip to content
This repository was archived by the owner on Feb 24, 2021. It is now read-only.
This repository was archived by the owner on Feb 24, 2021. It is now read-only.

Operator usage style guideline #509

Description

@ykuijs

In SharePointDsc we have a discussion on how to use comparison operators in the most readable way. Unfortunately the current coding style guidelines do not say anything about this.

Which is better, option 1:

if (($urlAam.PublicUrl -eq $aamForUrl.PublicUrl) `
    -and ($urlAam.Zone -eq $aamForUrl.Zone))
{}

Better readability on the used operator.

or option 2:

if (($urlAam.PublicUrl -eq $aamForUrl.PublicUrl) -and `
    ($urlAam.Zone -eq $aamForUrl.Zone))
{}

Better readability on the used conditions, because they are aligned at the beginning of the line. Especially when these contain multiple, longer conditions. I personally prefer this option.

I think we should decide on a method and document that in the DSC style guideline.

Activity

  1. andikrueger commented on Jun 6, 2019

    @andikrueger

    I find both options valid.

    With option 1 I like the fact that I can see more quickly which operands apply to the following condition.
    With option 2 it's easier to see what's the condition.

    I would go for option 1 as knowing operand and condition seems more adequate.

  2. ykuijs commented on Jun 12, 2019

    @ykuijs
    Author
  3. PlagueHO commented on Jun 13, 2019

    @PlagueHO
    Contributor

    I'm fine with both, but I actually personally prefer Option 2 because it keeps the operator on the left which is good for longer expressions. But I'm happy enough with either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions