Skip to content
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

code convention discussion #133

Closed
shiffman opened this issue Jul 11, 2016 · 7 comments
Closed

code convention discussion #133

shiffman opened this issue Jul 11, 2016 · 7 comments

Comments

@shiffman
Copy link
Member

Picking up on comments from @alignedleft in this thread: nature-of-code/The-Nature-of-Code-archive#350 I now have the following in edition 2:

screen shot 2016-07-11 at 2 06 50 pm

Any feedback @alignedleft?

@scotthmurray
Copy link

That is helpful! FWIW:

  • Why is the sidebar on "code formatting" inserted after the first code snippet? This further interrupts the code being explained.
  • Do you use the same gray shading for sidebars as for connecting passages of code and their comments? Since both appear back to back here and they are the same width, they feel related.
  • What does the "(like)" comment mean?

Alternately, you could have an example with dummy code earlier in the chapter/book, just to illustrate the styles used and introduce how you will be interleaving code and text.

@shiffman shiffman transferred this issue from nature-of-code/noc-book Jun 24, 2019
@scotthmurray
Copy link

That's great! Much more clear, at least for me.

I'd suggest instead of "light grey highlighting matches the comments…" consider "light grey highlighting groups the comments…"

One more design idea (may not be feasible): Since there may be many of these interrupted snippets throughout the book, what about signifying the start of a code example with, say, a solid black border on the top edge of the snippet (preceding class Walker {, in this case). The end of a snippet could be indicated with the same border on the bottom edge of the final excerpt.

For that matter, I'd suggest using a different color or gray for code/comment highlighting than the gray used for sidebars and other callouts.

@shiffman shiffman self-assigned this Feb 7, 2022
@shiffman shiffman removed their assignment Jul 28, 2022
@shiffman shiffman transferred this issue from nature-of-code/noc-book-2-archive Oct 28, 2022
@shiffman
Copy link
Member Author

Here I am again three years later! @scotthmurray not that I expect you to follow this but you can see the latest here:

https://nature-of-code-2nd-edition.netlify.app/introduction/#i2-the-random-walker-class

@jasongao97 what do you think about the suggestion of having a horizontal gray line / bar for when a code snippet begins and closing it with another when the snippet ends (see blue lines below). My gut feeling is this is going to be complex to maintain and apply consistently (since a lot of code snippets are stand alone, but I am open to considering it.)

image

@scotthmurray
Copy link

Well, color me impressed! 😁

@jasongao97
Copy link
Contributor

@shiffman Technically speaking, I believe it's not hard to implement. We can just set a new callout block type and drag everything inside. e.g. the following. But I'm wondering if there are any other design choice besides a start/finish line.

  • Maybe adding a vertical line with indent for the whole section.
  • Or add ... notations at the top or bottom of code blocks to infer a continuous block above/below.

image

@shiffman
Copy link
Member Author

Yeah, I don't have a clear idea here, maybe let's put a pin in this one and revisit later. It could be really helpful but doesn't feel as high priority as other things that need to be done for the book. I'm adding @nheidelberger to this thread in case he has any thoughts!

@shiffman shiffman changed the title Introducing code conventions code convention discussion May 11, 2023
@shiffman
Copy link
Member Author

shiffman commented Oct 8, 2023

This discussion can be followed in #447!

@shiffman shiffman closed this as completed Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants