Posts [ 7 ]

Topic: A few Programming Standards

Programming is not a school subject you have to pass in order to graduate, but if we treat it as one and learn it the way a high school education system would teach it, we could get better standards for programming. It is good to have standards.

People have different conventions for naming variables or plain structuring code. I am a layman so I try to keep it simple.

An APPLE is a FRUIT. Therefore an apple belongs to the class of FRUIT:

class Fruit()
apple = Fruit()

One way to name a class is as a TYPE of something. An apple is a TYPE of fruit. Apple is the instance. Fruit is the class.

Another way to name a class is as a SUBJECT.

In Math class you learn math.

class Math()
calculus = Math()

But this is incomplete if you don't have a good convention for naming variables and functions so as to distinguish them from class names or one another without checking the camel's back.

Variables are nounsFunctions are verbs.

Functions should be names as ACTIONS. If you want to quit a game:

function QuitGame()

If you want to start a game:

function StartGame()

I also have a standard for booleans. I name booleans as PARTICIPLES and as ADVERBS:

walking = false
if walking then
end
quickly = false
if walking and quickly then
end

For people who name variables with underscores it is best to put NOUNS BEFORE ADJECTIVES as it makes similar variables easier to spot in the code:

Re: A few Programming Standards

Didn't you learn how to do a wiki page yet? These thread of yours better fit the wiki. I see that you have an account there now, so here's how you could put post of this kind in the wiki, just a suggestion. It's very simple.All you have to do is putting the code between "pre" tags:

<pre>
your code
</pre>

instead of "code" tag.Also, new lines are done only if you do "two new lines".So this:

Hello.
I'm Tutorial Doctor.

will output this:

Hello.I'm Tutorial Doctor.

While this:

Hello.
I'm Tutorial Doctor.

will output this:

Hello.
I'm Tutorial Doctor.

That's all, there are no other things to keep in mind. Putting images is a bit more of work but it's not difficult either.

Also, everyone can edit your work and fix formatting, errors, doing a list of your pages with links and everything so even doing incomplete work will be useful anyway.