Code Gamers Development: Essentials: A 9-Week Beginnerâs Guide to Start Your Game-Development Career by Colonna A.E
Author:Colonna, A.E [Colonna, A.E]
Language: eng
Format: epub
Published: 2022-09-24T00:00:00+00:00
Style Conventions
Style conventions relate to how screen space is utilized and how code is displayed. It also relates to how code is structured within that space. Blocks can become convoluted and are easier to make sense of when structured appropriately. You will notice this in the code examples.
We can break code down into a hierarchy of sorts. Everything on the same level is displayed on the same vertical line. Whenever a new block opens within another block, it is indented to form a new level in the hierarchy. This way, you can easily tell what level something is on by where it sits on the screen.
A good rule of thumb is to use blank space for clarity. Computers and compilers automatically ignore the blank spaces between lines and instead rely on syntax to determine the beginning and end of blocks and statements. Add blank lines on either side of a method. You can group block members by function and use a blank line to distinguish them from other statements. For example, group all variable declarations together at the top of a block and add a line to separate them from the rest of the block. This makes it easier to keep track of all the variables in one block.
Keep curly brackets on their own lines, especially the closing brackets. Some IDEs automatically place brackets in new lines when you open them and hit enter in between. The brackets are usually in line with the declaring statement of the block and everything inside them is indented. The opening brackets can be on a separate line or in line with the block declaration for the sake of maintaining vertical space. Having each bracket on its own line makes it easy to keep track of them and see if brackets are closed properly.
For example, they can be displayed like this:
static void Main ( )
{
//code
}
Or like this:
static void Main ( ) {
//code
}
On the topic of brackets, it is preferable to use brackets even when you do not technically need to. If a method only has one statement, you do not technically need brackets. However, it is recommended to use brackets anyway. This makes it easier to add to the method later and keeps things neat.
If you are ever in a situation where one line becomes too long, you can wrap the text to begin on a new line. In that scenario, indent the code to show that it is a continuation and not a new statement. C# allocates 180 spaces per line, but it is good to have your code fit the screen. Make it so that you do not have to use the horizontal scroll bar to read your lines. In the case of parameters crossing multiple lines, indent them to start in line with the brackets.
To illustrate, it is easier to read this:
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
What's Done in Darkness by Kayla Perrin(26802)
The Ultimate Python Exercise Book: 700 Practical Exercises for Beginners with Quiz Questions by Copy(20666)
De Souza H. Master the Age of Artificial Intelligences. The Basic Guide...2024 by Unknown(20443)
D:\Jan\FTP\HOL\Work\Alien Breed - Tower Assault CD32 Alien Breed II - The Horror Continues Manual 1.jpg by PDFCreator(20440)
The Fifty Shades Trilogy & Grey by E L James(19302)
Shot Through the Heart: DI Grace Fisher 2 by Isabelle Grey(19258)
Shot Through the Heart by Mercy Celeste(19126)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 10 by Isuna Hasekura and Jyuu Ayakura(17292)
Python GUI Applications using PyQt5 : The hands-on guide to build apps with Python by Verdugo Leire(17225)
Peren F. Statistics for Business and Economics...Essential Formulas 3ed 2025 by Unknown(17072)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 03 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16996)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 01 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16612)
The Subtle Art of Not Giving a F*ck by Mark Manson(14612)
The 3rd Cycle of the Betrayed Series Collection: Extremely Controversial Historical Thrillers (Betrayed Series Boxed set) by McCray Carolyn(14306)
Stepbrother Stories 2 - 21 Taboo Story Collection (Brother Sister Stepbrother Stepsister Taboo Pseudo Incest Family Virgin Creampie Pregnant Forced Pregnancy Breeding) by Roxi Harding(13966)
Scorched Earth by Nick Kyme(12963)
Drei Generationen auf dem Jakobsweg by Stein Pia(11144)
Suna by Ziefle Pia(11066)
Scythe by Neal Shusterman(10555)