Standards in Programming
White Space: White space is the open space between the boundary of your program and where your code starts. White space doesn't really matter to the computer at all it doesn't register the space , only the start and end of your code. White space is used by a lot of programmers to make the code look more presentable and easier to read, however there are those that don't use it and while it doesn't effect their personal code, when working for an employer it can be less desirable to them.Naming Conventions: This is basically how different pieces of the code like: variables, functions or characters are named and identified. Naming conventions tend to differ depending on a couple of different conditions. One of these conditions is whether you are working independently or whether your working in a team of some kind.
If your working independently then it's understandable that you would be able to remember and figure out the different names of your variables or functions for example if you was to put a line of code that included a variable like: ' if (emailAddress == true);'
You should know where the variable can be declared again. For example whether they are a 'Global' or 'Local' variable or even the type of variable they're (Data type) such as 'char' or 'float'
If however you happen to be working in a team, declaring a set of standard to how you will structure these names will help you reduce the work time as well as the amount of errors. For example of the way in which you all might agree to create name standards is:
'if( g_stremailAddress == true);'
As you can see from the example is differs from the first, in this example 'g_s' has been added onto the variable name. The 'g_' represents the fact that this type of variable is Global and can be declared at any point in the program. the 'str' represents the fact that this variable is a string meaning that it will hold both numbers and characters. Doing something as simple as this will allow the rest of your team to identify these variables quicker and use them for themselves in there own work.
Hungarian notation: These are the base standards for how you should attach a prefix to a variable, function, etc. While most companies have there on twist or flavour of the Hungarian notation if you will they all stem from these base prefixes. An example is for how to state that the variable is a C++ string this being 'str'.
Position of brackets: The position of brackets again is not something that necessarily makes much of a difference as long as they're included and apparent. Most programmers have their own options on how to separate and set the brackets in code, sometimes these ways stem from habits of previous different programming languages that these programmers have used or maybe it's just a personal preference that includes how these brackets should look. It's important again, when your working in a team, that you either come up with an agreeable standard for how your team will set these out or either just simply stating it to them or making a comment at the start of the code.
Comments: Comments can be left in your own code to either help you figure out where certain parts are of simply split them up into separate segments. Comments can also be used to reduce the risk of members of your team if there are any getting lost in your code or not being able to find a certain part of in. Leaving comments is a very useful feature that will save you a lot of time if used properly.
Positional notation:
Composite Word Scheme:
No comments:
Post a Comment