-
Notifications
You must be signed in to change notification settings - Fork 8
03. Formatting of code on the platform
A single line of code or pseudocode should be written inline inside a content block using the triple backticks to start and end the statement e.g.
PRINT("Hello pseudocode")
Generally, you should avoid using inline code because it will appear only in a single language and there will be no syntax highlighting.
Code segments are lines of code that would form part of a subroutine. Code segments are generally used only in the programming concepts topic where a specific structure (such as selection) is discussed.
- The code must be inside a tabbed code block where the tab title is the name of the language e.g. Pseudocode
- You should only include statements (lines of code) that are needed to illustrate the learning objective (no extra inputs or outputs).
- Variables may be set with test data to illustrate a concept e.g. age = 18
The Github link must reference a version of the code that can be downloaded and run. This means that extra code must be provided to make the program viable (see GitHub section below).
A subroutine should contain all of the statements (lines of code) needed for the subroutine to make sense.
- Subroutines must be inside a tabbed code block, where the tab block title is the name of the language.
- In pseudocode, the keywords PROCEDURE or FUNCTION should be used (not SUBROUTINE)
- The subroutine must have a meaningful name (generally one that starts with a verb) or it should be named
main
. - You do not need to show the subroutine being called unless this is necessary to meet a learning objective. However, the explanation should make it clear that the subroutine would need to be called.
- If there is more than one subroutine,
main
should appear first in pseudocode, C#, Visual Basic and Java. In Python,main()
should be the last function.
The code on GitHub should always be a complete program that can be downloaded and run. This means that code may look different to the code on the platform, for example:
- All of the code will appear in named subroutines or, at the very least, in a
main
subroutine - Input or output commands may have been added to make the program more useable
- Test data may be provided that allows the user to run the program e.g. an array of data to use in a binary search
Generally, we use only pseudocode in questions and quick questions.
Code must be inside a tabbed code block so that the "Pseudocode" heading is displayed.