Giter Club home page Giter Club logo

Comments (9)

adrienntindall avatar adrienntindall commented on June 2, 2024

Variant A is better due to how many nested switch statements are in the code. The alternative would be to have the deepest indent in large essential functions be 3-4 indents deeper than they would have been sticking with variant A, which makes the code less readable. Then for consistency we should keep the rest of the code on the same style.

from pokeheartgold.

red031000 avatar red031000 commented on June 2, 2024

I have made several PRs converting style A into style B, which have been approved and merged, and during original style guide discussions, we did decided on style B, so imo style B is better, plus, I prefer it because I personally find it much easier to read

from pokeheartgold.

AsparagusEduardo avatar AsparagusEduardo commented on June 2, 2024

I prefer style B.

from pokeheartgold.

mid-kid avatar mid-kid commented on June 2, 2024

Style A reinforces the fact that the case labels have no scoping significance and have about the same effect as a goto label. It's also wasteful to add an indent level when unnecessary.

from pokeheartgold.

luckytyphlosion avatar luckytyphlosion commented on June 2, 2024

I abstain from this discussion.

from pokeheartgold.

luckytyphlosion avatar luckytyphlosion commented on June 2, 2024

There is actually a third variant C: case labels indented by 1, but case contents not indented.

switch (state) {
    case 0:
    // ...
    case 1:
    // ...
}

I only mention this because this is the default in Notepad++. With that, I want to mention that editors are inconsistent as to which style they automatically indent to:

Editor Default behaviour Toggleable
Notepad++ Variant C Unknown (Discussion 1, Discussion 2)
Eclipse (yes this isn't C I know) Variant A Yes, see image below
Visual Studio Code Variant B Yes? (Issue which proves its existence in vscode-cpptools extension)

For eclispe:
image

from pokeheartgold.

red031000 avatar red031000 commented on June 2, 2024

There is actually a third variant C: case labels indented by 1, but case contents not indented.

switch (state) {
    case 0:
    // ...
    case 1:
    // ...
}

I only mention this because this is the default in Notepad++. With that, I want to mention that editors are inconsistent as to which style they automatically indent to:

Editor Default behaviour Toggleable
Notepad++ Variant C Unknown (Discussion 1, Discussion 2)
Eclipse (yes this isn't C I know) Variant A Yes, see image below
Visual Studio Code Variant B Yes? (Issue which proves its existence in vscode-cpptools extension)
For eclispe: image

objectively bad

from pokeheartgold.

AsparagusEduardo avatar AsparagusEduardo commented on June 2, 2024

There is actually a third variant C: case labels indented by 1, but case contents not indented.

It's like the worst of both worlds

from pokeheartgold.

tgsm avatar tgsm commented on June 2, 2024

I prefer style B.

from pokeheartgold.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.