Jump to content

Do you follow any coding standards?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
14 replies to this topic

#1
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Just about any library, framework, platform or close relative (and their brother) has created a coding standard. Examples are


There may be multiple for one language or maybe just one that everyone adheres to but the question is simple: Do you follow any coding standards? Is there a right or wrong coding method? Is a self-made standard any different than a standard created with a huge following? Is either right or wrong?

Edited by Jordan, 24 July 2009 - 02:53 PM.


#2
zeroradius

zeroradius

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,406 posts
I use my own standards. every web page I have has two pages to it. the first is located in the root folder for easy navigation, it contains the template code with a session start at the top (even if that page does not use a session) and then it include the content of the page. The code for the content goes in a descriptive folder for instance all forum components would go in a folder called forum, each content doc that uses a DB includes php file wich resides in the root folder and contains all the Db conection information.

at the top of every page is a code block that looks like this:

/* 

+_____________________________________________+

|                                                                         |

| Website Title: The Role Players Guild                        |

| URI:                               |

| Title: index.php                                                    |

| Includes: news.php                                              |

| Purpose: Home page. has  news updates                  |

| Date Created: 7/11/2009 4:05 pm                           |

| Date updated:                                                     |

| Copyright: 2009 ----                         |

+_____________________________________________+

*/


I also use the three spacing system to keep my code formated


<table>

   <tr>

      <td>

         everything has 3 spaces from the last thing

         <br />

          yep

      </td>

   </tr>

</table>



Not verry good standards but it keeps my stuff organised enuph for me to find it quikly

EDIT:
oh and my naming standards are like this

content: ForumInput.php
actual page:forum_input.php
(smae names diffrent way of typing them)
Posted Image

#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
I tend to use UpperCamelCase and lowerCamelCase. I'm pretty fond of the standard in The Elements of C++ Style
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#4
BlaineSch

BlaineSch

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,448 posts
I tab one everytime I am in a child of a {} I never have anything after those 2 characters.

I believe I learned this without really realizing it. Most examples looked like that and I just started doing it.

if() {
	hello();
	hi();
	while() {
		echo();
	}
}
yes();
It looks nice to me. My teacher made me do it different a few times before but I never liked it.

#5
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
Just like Winged I use UpperCamelCase and lowerCamelCase and use tabs wherever there is a loop or an if statement

#6
Guest_Jordan_*

Guest_Jordan_*
  • Guests
That is great for Variable names and functions, but what about constants, static variables, classes, function/method {}, etc?

I guess what I'm saying is that standards constitute a lot more than a naming scheme for variable.

Quote

Function names may only contain alphanumeric characters. Underscores are not permitted. Numbers are permitted in function names but are discouraged in most cases.

Function names must always start with a lowercase letter. When a function name consists of more than one word, the first letter of each new word must be capitalized. This is commonly called "camelCase" formatting.

Verbosity is generally encouraged. Function names should be as verbose as is practical to fully describe their purpose and behavior.


#7
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts

Jordan said:

That is great for Variable names and functions, but what about constants, static variables, classes, function/method {}, etc?

Same as variable names. I don't use underscores though.

#8
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
The Elements of C++ Style has a wide variety of suggestions. Some examples:
96. Avoid the use of Friend Declarations
156. Manage Resources With RAII For Exception Safety
175. Do not put Global-Scope "using" or "using namespace" Declarations in a Header File
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#9
relapse

relapse

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 476 posts
Yes, I've developed my own set of standards. I don't really think it is important which standard you use as long as you consistently use that standard.

#10
BlaineSch

BlaineSch

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,448 posts
There are some standards I have not considered. I figured standards strictly meant how you code which I suppose it still does. Is there a list of some of these somewhere? I do believe I use the same format for everything I do but I have not written them down.

#11
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
There are several for Delphi :) Google will pull them up, but they tend to be somewhat Delphi-specific.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#12
BlaineSch

BlaineSch

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,448 posts
I do not know Delphi, what is it used for?