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 nouns
Functions 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:

apple_red =
apple_green =

boy_mexican =
boy_african_american =
boy_caucasian =
boy_indian =
boy_chinese =

If I want to find a "boy" I can find it easier this way.

Underscores also make things easier to read for me (I used to not understand why people did it).

Anyhow, having standards like these will make code flow better, and keep variable names or class names or function names from getting mixed up.

One more thing, It is good to be SPECIFIC yet BRIEF in your naming. For example if you have a person class:

class Person()

And you create an instance:

joey = Person()

Then you make joey do "Person" stuff:

joey:Speak()
joey:Walk(quickly)

This is already specific to JOEY since it uses classes, so your wording shouldn't get mixed up.

However, if it were just a function outside of a class:

Walk()

Then it leaves the questions:

Who or what is walking?
Walk where?
Walking how?

You could do this instead:

WalkFast()
WalkSlow()
WalkLikeYouBrokeYourLeg()

Functions should start with a captical letter and camel-case for each new word
variables start with a lower case letter and camel-case for each new word.

Whether you use underscores or not is up to you. But the two standards above are general for every programming language (at least how schools would teach you).

Writers can write however they want in their journals, but when it comes to writing a research paper, there are standards. Hopefully this helps.

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.

Re: A few Programming Standards

I have an account now? Cool! I will move these posts there. I was waiting on a response. Thanks 255

Re: A few Programming Standards

Tutorial Doctor wrote:

I have an account now?

Yep, you should check your email, it contains your password for the log in.

Re: A few Programming Standards

Thanks. I got it. Going to try to redo this one on the wiki.

Re: A few Programming Standards

I tried to add the OOP tutorial to the wiki. A table of contents didn't show up however. Could you check it out to see if I did it correctly? Here is the link:

http://wiki.maratis3d.org/index.php?tit … in_Maratis

Re: A few Programming Standards

The table of contents is generated only when more than three section headings are used.