Skip to content

Simplify some examples #3997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Simplify some examples #3997

wants to merge 1 commit into from

Conversation

ComputerNerd
Copy link

I noticed that some of the examples could have been written in a more concise way. This made them easier to read and shorter.

The general trend that I noticed was this:

if(variable==HIGH)
    digitalWrite(pin,HIGH);
else
   digitalWrite(pin,LOW);

Why not just do this instead:

digitalWrite(pin,variable);

@Avamander
Copy link
Contributor

I think the ^= and ! should be explained then. Maybe even add the old one as a comment and tell that those two pieces of code are the same.

@agdl
Copy link
Member

agdl commented Oct 20, 2015

@Avamander the examples are intended for people who want to understand programming and are written in the easiest as possible for this reason, so I'm sorry but this PR won't be merged..

@Avamander
Copy link
Contributor

FYI: Not my pull request.

@cmaglie
Copy link
Member

cmaglie commented Oct 20, 2015

These examples are for absolute beginners and the "compact" version adds complexity (even more using ^= that introduce two new concepts in a row: the XOR and the compound assignment).

@tigoe @SimonePDA @shfitz
should we clarify this is in a FAQ? This is the 3rd PR this month that tries to improve the examples, maybe we should think about a reorganization of the base examples and add a "contribution guidelines".

@cmaglie cmaglie closed this Oct 20, 2015
@cmaglie cmaglie added the Component: Documentation Related to Arduino's documentation content label Oct 20, 2015
@cmaglie cmaglie self-assigned this Oct 20, 2015
@agdl
Copy link
Member

agdl commented Oct 20, 2015

@Avamander sorry wrong tag, it was for @ComputerNerd

@per1234
Copy link
Collaborator

per1234 commented Oct 20, 2015

add a "contribution guidelines".

See #3368

@tigoe
Copy link
Member

tigoe commented Oct 20, 2015

@cmaglie, yes I agree, a FAQ would be good. We have this: https://www.arduino.cc/en/Reference/StyleGuide Which you could add do and/or make more prominent.

@ComputerNerd
Copy link
Author

@cmaglie Is it just the XOR compound assignment that you object to? It could also be written as

ledState = !ledState;

If you like the other changes I could rebase my commit to not use the XOR compound assignment and use either the above alternative or bring back the if statements.

@tigoe
Copy link
Member

tigoe commented Oct 21, 2015

Me personally, I'd leave all the logical operators out of this example and introduce them later. For someone who's seeing their first if() statement, that's enough to deal with. Conciseness is less a priority for these examples than illustrating one clear concept per example.

If you want to write some examples that illustrate and explain the logical operators, though, I think that'd be great.

@ffissore ffissore modified the milestone: Release 1.6.6 Oct 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Documentation Related to Arduino's documentation content
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants