Elements of Style

What is good programming style? It consists of several key elements, but chief among them — an underlying rule — is to always be consistent.


Or, if you aren't so new to programming, have a look at this comic and then continue below.

Since you are new to programming, you may wish to experiment a bit to find your true style. That's fine. But please maintain consistency within a single program. And once you find your style, you can use it consistently thereafter. *smile*


Beyond that, please follow the below guidelines to the best of your ability. (Don't worry, I'll be there with my magically-colorful marking pens to guide you when you stray. *smile*) (But if you persist in the infractional behavior, I'll be forced to take points off your portfolio score, eventually. *sigh*)

The different elements that make up good style (in any language, really) are:

Spacing Identifiers
Structure/Organization Clarity
Brevity Special


Programmers prefer to keep things brief so that there is less clutter and redundancy to deal with.

Less is more.

This is part of the KIS principle: Keep It Simple.

And, always remember that, "The less I type, the fewer mistakes I can make."


When we can't make something brief, we try to make it as clear as possible. Sometimes we're even willing to forgo a little brevity if we can make something more clear.


Clarity really culminates in the use of clear identifiers. This is a penultimate goal! If you name things well, in fact, you can avoid placing comments in some places — making your code/coding more brief.


Eye strain is a major concern in the computing industry. *sigh* Making the code spaced out helps alleviate this eye strain considerably. (The mind likes a little gap in the view to ease its processing, I suppose... *shrug*) In fact, spacing helps within a program's interface as well — those who use lots of console interfaces have similar problems with eye strain.

In addition to its medical benefits, good spacing can help to enforce structure and organization (detailed below). Likewise, a logical interface is also easier for a user to follow.

Structure and Organization

Organizing the logical structure of a program can greatly enhance its readability, clarity, and even its ability to grow with future needs — its enhance-ability, if you will.

Special Considerations

Every language may also have its own special considerations. (In fact, you'll find that each programming community can develop its own special style guidelines to a point. *shrug*) Here is the principle one I've found for C++.