Explore BrainMass

Coding rules explanation and use of Sequential file access

1. Discuss why naming conventions are important and why programmers should consistently follow them. Include in this discussion problems that could arise in naming variables if one convention is not followed.

2. Why is it important to consistently follow coding rules and techniques? What are the pitfalls of not doing so?

3. Explain what a sequential access file is. What are the advantages and disadvantages of using sequential access data files?

Any addition references will be greatly appreciated.

Solution Preview

It is always good practice to use suggestive variable names that will assist in the documentation of a program. A good convention for variable names can often assist someone in better understanding the operation of a program module or script. For example, a good variable name should indicate its use, like "ErrorMessage" or "InputBuffer". Also, if the variable has several different uses, it can be split up into several different variables.

To illustrate the point of the problems that could arise for not following some convention take a look at the following code snippets
Bad Examples:

a) l = l + 1;

b) This = That + O;

c) const int TWENTY_EIGHT = 28;

d) #define FALSE TRUE
Another worse example would be the use of lower-case L or uppercase o as variable names, especially in combination.
e) int a = l;
if ( O = l )
a = O1;
l = 0;

Look for a comprehensive guide to C++ naming conventions

Variable naming and code layout/style in general, can result in some never-ending discussions. In the end, it doesn't really matter what style/standard you use, as long as you stick to it. If you're comfortable with a style, use it. Just don't get religious about it. When you start developing professionally, chances are you'll end up in a place where the coding-standard says something ...

Solution Summary

Elaborate discussion on various topics including:
Variable Naming Conventions
Coding rules and techniques.
Advantages and Disadvantages of Sequential file access