-
-
Notifications
You must be signed in to change notification settings - Fork 360
Adding Example Code to Sorting Algorithms #240
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
Adding Example Code to Sorting Algorithms #240
Conversation
To be honest, I don't think we're even sure when to show the main function and when not to. Some chapters intentionally only show the algorithm in question, others show full code examples with a main function. We should probably agree on something or come up with a rule. Let me summon @leios, @julianschacher, @Gathros, @jiegillet and @Gustorn real quick. They probably have opinions on this. |
It's true that we don't have a With the |
We have a few chapters in which only the algorithms themselves are imported. Maybe we should always add one code block at the very bottom that contains a working, compilable/runnable example. |
@Butt4cak3 yeah, that was what I was thinking of and I support that |
I totally agree with both of you that there should be one section just showing the algorithm and then one example code section which has a working example. I just added in an example code section for Bubble sort and Bogo sort |
@CDsigma Hey, I found a little problem with the C# imports of the |
The restructuring of the chapters seems good now; so from my side everything is ok :) |
By the way, why do we even still have the language specific headlines for the full example codes ( |
Ah, I guess you are right. I had them in initially because we didn't have the theme api. There's no harm in removing them now since we can indicate what language you are reading with the theme-api. |
Just removed the language headlines and changed 'Example Code' to using |
You also kinda just copied the full code imports so that we now have the same, full code twice for some languages like C++. I think now that we're already working on it, we should do it right. I think the first code block should show only the |
I agree with @Butt4cak3 there, that makes the most sense for these chapters. For functions like |
I agree it makes sense to only show the bubble sort and bogo sort functions for the first part and then in the 'Example Code' section to show all the code. I adjusted the .mds accordingly. |
Sorry it has taken me so long to get to this PR. I agree. The intent was to have the full code in the |
|
||
{% method %} | ||
{% sample lang="jl" %} | ||
[import:1-14, lang:"julia"](code/julia/bogo.jl) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do some of the languages have line numbers to import and others don't? Shouldn't the example code section just import an entirely working code sample?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should. I guess that needs a change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. That's pretty much what I tried to say in my most recent comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that, I accidentally messed up on the Julia code for both Bubble Sort and Bogo Sort in the Example Code section. I just made a commit to fix this.
The rest of the line numbers given are to hide unnecessary comments at the beginning of the programs saying who created them. It seems unnecessary to show these comments since it doesn't provide useful information to the reader. Additionally, there is already the contributors.md file so the programmers are receiving credit elsewhere. I think there are three options for what can be done here:
- Keep it as is (meaning hide those lines by modifying the .md file)
- Modify the code to remove the unnecessary comments
- Show the comments and then sort out what should be done if anything in a different PR
Or, another option I may have missed.
Give me your thoughts on what you think should be done 👍
You excluded the comments in some instances, when you imported the whole code at the bottom. These comments often show the contributor and I think they shouldn't be excluded. |
I disagree that we should be showing those comments but I also don't think that this is a key issue for the project. I just made a commit to show all comments in the 'Example Code' section. This should help to simplify this pull request. In the future I may make an issue to help further the discussion around these comments, which show the contributor at the top of the program, since I think they add unnecessary clutter. |
Thank you :) It's the way it's handled until now and for the sake of holding to standards it's good to include it here as well. Aside from that: I think showing the contributors and giving them credit is a nice gesture, we should keep up. |
But opening an issue might not be a bad thing. The credit works good for code files, that got contributed in only one PR, but as soon as they get revised, reworked and improved, that whole thing is getting complicated. |
- Added example code sections showing all code - Changed code segments shown to only show bubble sort functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR has been open for a while and I think it's time to finally merge it, so let's try to finish it up.
The partial code import for C BubbleSort is off by one line. Can you change the range from 11-21
to 10-20
?
That's all. Fix that up real quick and I'll merge this.
Just fixed the code import for C |
Good work! |
My current understanding is that code in the AAA is supposed to show a main() function which runs the algorithm. So I updated the java sorting algorithms to reflect this.