ArcEmu: ArcEmu Coding standard - ArcEmu

Jump to content

Toggle shoutbox Lastest Announcements

dfighter  : (07 December 2014 - 12:06 PM) Arcemu is in hibernation mode, please read http://arcemu.org/fo...showtopic=26903
dfighter  : (01 January 2013 - 05:56 PM) Arcemu wishes you all a happy new year!
Hasbro  : (12 September 2012 - 10:01 AM) Please excuse our outage from the web! Our web host had a major malfunction!
dfighter  : (01 September 2012 - 04:05 PM) Since the spam bots just don't want to stop, I've enabled admin verification when registering.
dfighter  : (23 January 2012 - 09:56 PM) Please note that from now on you will need to confirm your email on the wiki in order to edit it!
Hasbro  : (31 December 2011 - 12:50 PM) Happy New Years all!
Navid  : (26 December 2011 - 04:09 AM) Merry Christmas !!!!!! Happy holidays all :)
WAmadeus  : (24 December 2011 - 03:54 PM) Merry Christmas to all!
dfighter  : (24 December 2011 - 11:05 AM) The Arcemu team wishes y'all a Merry Christmukkah!
Hasbro  : (05 October 2011 - 12:53 PM) Looking for web designers for upcoming web related project. If you're interested in designing user interfaces contact me
dfighter  : (02 September 2011 - 03:47 PM) So who here wants vehicles in Arcemu? :P http://arcemu.org/fo...showtopic=25440
Hasbro  : (14 August 2011 - 03:25 PM) Join us on irc, grab an irc client and connect to irc.freenode.net join channel #arcemu /server irc.freenode.net:6667 /join #arcemu
jackpoz  : (03 August 2011 - 05:33 AM) to all Lua Engine (old one) users: please check http://arcemu.org/fo...showtopic=25274
Hasbro  : (20 May 2011 - 05:27 PM) Looking for people experienced with CMake configuration and setup! Contact me asap
Hasbro  : (15 May 2011 - 05:03 PM) ArcEmu is recruiting C++ programmers, contact Hasbro if interested.
paroxysm  : (03 May 2011 - 06:26 PM) Updated luabridge gossip example to describe the whole gossip creation process rather than just how to create menu. Gossip tutorial
paroxysm  : (23 April 2011 - 11:35 AM) Lua writers can refer to the Luabridge Tutorials section in the Wiki to learn how to write gossip code correctly.
Hasbro  : (20 April 2011 - 05:22 PM) Thank you for your continuous contribution of bug reports, we are working on them.
Hasbro  : (17 April 2011 - 03:20 AM) Please consider donating to support our bills. Donations can be sent using PayPal to donations@arcemu.org - Thank you for your support.
paroxysm  : (10 April 2011 - 12:43 AM) Refer to the Luabridge Tutorials section in the Wiki to learn the new syntax of luabridge.
Resize Shouts Area

Developing

Interesting in developing with us? Join us on IRC: irc.emulationnetwork.com:6667 #arcemu
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

ArcEmu Coding standard A developer's guide to clean and proper code

#1 User is offline   Hasbro 

  • Project Manager
  • PipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 2,526
  • Joined: 07-June 08
  • Gender:Male
  • Location:New York
  • Server OS:Windows

Posted 28 February 2009 - 07:18 PM

Hi everyone, after long review and discussion we've released the following

<a href="http://www.arcemu.org/standards/" target="_blank">http://www.arcemu.org/standards/</a>

If anyone has any ideas they'd like to share on the standards we'll be using, please reply to this thread.
Thank you.

Sincerely, the dev team.
0

#2 User is offline   Clain 

  • Enthusiast
  • PipPipPip
  • Group: Members
  • Posts: 196
  • Joined: 07-June 08
  • Gender:Male
  • Location:USA

Posted 28 February 2009 - 09:28 PM

EDIT: Understand it now
0

#3 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 01 March 2009 - 07:21 AM

Quote

3. When in platform independant code (code common to all platforms) use WMemSet(), WMemCopy(), WMemMove() functions in place of platform versions.
Right:

/// Common code across all platforms
WMemSet(pAddress, 0, sizeof(object));

Wrong:

/// Common code across all platforms
xmemset(pAddress, 0, sizeof(object));

4. In platform Dependant code (code specific to one platforms) use memset, memcopy, memmove functions designed for that specific platform.
Right:

/// DirectX Win32
memset(pAddress, 0, sizeof(object));

Wrong:

/// DirectX Win32
WMemSet(pAddress, 0, sizeof(object));

I lol'd.
WMemSet is a windows function. memset is a standard one.
I don't know who wrote this, but he/she was either drunk or has no idea wtf he/she is talking about :)
"The demand for free goods is infinite."
0

#4 User is offline   Kenjiro 

  • Enthusiast
  • PipPipPip
  • Group: Members
  • Posts: 311
  • Joined: 12-June 08
  • Location:Poland

Posted 01 March 2009 - 08:45 AM

The most confusing! All paragraphs for variable types are simply wrong. They do not work for many systems and different architectures (eg. x86 and x64). Examples:
int variable; //is 32 bit for 32 bit systems and could be 64 bit for 64 bit - there is no defined behaviour!
float variable; //the same as above - could be float = double for many systems, eg. 32 bit gcc in many cases could compile float as double!

If ArcEmu will be used on different systems and architectures you HAVE TO DEFINE YOURSELF what are you want. When you want multi-system/arch code you HAVE TO AVOID system dependant behaviour, which you are proposing.
Please fix this to avoid further confusion.

Also i'm against:

Quote

# Use spaces, not tabs. Tabs should only appear in files that require them for semantic meaning, like Make files.
# The indent size is 3 spaces.

It is basically wrong for few reasons:
1. Current code use tabs with size of 4 chars.
2. Tabs are not 'static' - you could define it for your liking, and tabs are meant exactly for uses like coding.
3. 3 spaces is VS default only, other systems is free to set my way.

I'm also against:

Quote

Do not place spaces between a function and its parentheses, or between a parenthesis and its content.

For me it is not readable especially in simple statements like:
f(i)

Function name and arguments should be separated by at least one space for better readability in one of ways:
f (i)
f( i )
f ( i )

I think, differentiation between function and conditions (without space with function and with space with conditions (if, while, ...)) is not necessary. Conditions are easily spotted by next line - { or indent for effect of condition, which is not the case of function execution.

Next one:

Quote

Tests for true/false and zero/non-zero should all be done without equality comparisons.

It should be done this way ONLY for bool variables, in other cases it should be exactly know from statement what value you are comparing with. It could be the same:
if (variable != 0)
if (variable != NULL)
if (variable)

but every case shows exactly which variable is integer, pointer or bool.

Also, dfighter spot the same, it's clear - the guide is Windows centric and wrong in mentioned cases.
0

#5 User is offline   Ramor 

  • Interested
  • PipPipPipPip
  • Group: Members
  • Posts: 420
  • Joined: 11-June 08
  • Location:NC, USA

Posted 01 March 2009 - 11:00 AM

I agree with Kenjiro about the spaces thing, I always use tab when writing code, no matter what type of file it is.

Other than that, well done, this must have taken a while.

0

#6 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 01 March 2009 - 11:20 AM

View PostKenjiro, on Mar 1 2009, 02:45 PM, said:

Also, dfighter spot the same, it's clear - the guide is Windows centric and wrong in mentioned cases.

I disagree, it's not windows focused, it's plain nonsense :o
"The demand for free goods is infinite."
0

#7 User is offline   Hasbro 

  • Project Manager
  • PipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 2,526
  • Joined: 07-June 08
  • Gender:Male
  • Location:New York
  • Server OS:Windows

Posted 01 March 2009 - 03:04 PM

Pasted from my conversation with Debug, the author of this standard.

Some general information which any C++ programmer should know off the bat, m_ just means member and it's short hand.
It was made as a platform independent style guideline
the rule is if there is a choice it has a rule this convention was formed from votes of an entire coding staff of a game studio
we REMOVED the comfort issue
ie. people like it begin XYZ because it makes them comfortable cus thats how they learned it
our standard said you all code the same no matter how you learned
so that YOU can look at other peoples code and use it efficiently.

Quote

The most confusing! All paragraphs for variable types are simply wrong. They do not work for many systems and different architectures (eg. x86 and x64). Example


For your information, this standard compiled on Windows, Linux, Unix, PS2, PS3, Xbox, Xbox360, Wii, NDS, PSP, Ngage, NGI and J@ME

However, if there are typos or maybe some parts are too vague we can make minor alterations.
This coding convention was written by Debug and voted on by the staff he worked with.
Please only constructive posts from this point on, thank you.
0

#8 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 01 March 2009 - 03:35 PM

Well you cannot make up a standard, only a convention :D
However even for a convention this one is not good enough unfortunately, we pointed out the problems, you may take it or leave it. :)
"The demand for free goods is infinite."
0

#9 User is offline   Hasbro 

  • Project Manager
  • PipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 2,526
  • Joined: 07-June 08
  • Gender:Male
  • Location:New York
  • Server OS:Windows

Posted 03 March 2009 - 01:03 PM

Please don't double post.
0

#10 User is offline   Kenjiro 

  • Enthusiast
  • PipPipPip
  • Group: Members
  • Posts: 311
  • Joined: 12-June 08
  • Location:Poland

Posted 06 March 2009 - 05:12 PM

Constructive (taken from head, could not compile):
main ()
{
int a;
printf ( "%d", sizeof ( a ) );
}

Please compile under Windows (VS probably will use 4 bytes), Unix, Linux (dependant on compiler and version) and other systems or different architectures. Use different compilers and YOU WILL GET different results. You cannot rely on hardware/software dependant settings when you want to output very specific binary stream (size specific). This is written in MOST (if not EVERY) C book or manual.

You could use what you want and where you want, but in binary streams with specific sizes and MULTI ARCHITECTURES you HAVE TO use correct and defined size of variables to avoid errors and problems. There is no standard for multiple compilers, then you HAVE TO define it yourself.

P.S. I agree with naming convention with 'm_name' variables or so, but proposing unknown size types for constant sizes streams is ridiculous. This is not minor, but major - if you change it, you will break it! Voting do not change the way C is designed.
0

#11 User is offline   Maroot 

  • Member
  • Pip
  • Group: Members
  • Posts: 73
  • Joined: 07-June 08

Posted 06 March 2009 - 09:04 PM

I disagree on the spaces junk. All the programmers I've gotten plastered with over the last 20 years all use tabs, and get pretty pissy when they have to work on some doods code who's gone ahead and used spaces. In fact, they swear a lot about it. One of them even mumbled something about "3bytes as apposed to 1byte. Why in the flying fook sticks would you add 3 extra bytes for every 1byte of a tab, sure the compiler ignores them but your gawdamn system doesn't, nor does the poor bastage on dialup updating source code". Every book I've flipped through all seem to mention using tabs, and frown upon the use of spaces...
I can't stand working on code that uses spaces for indentation, it pisses me off and makes me grumpy. lol
0

#12 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 01 May 2009 - 04:15 PM

View PostKenjiro, on Mar 7 2009, 12:12 AM, said:

main ()
{
int a;
printf ( "%d", sizeof ( a ) );
}

main() must return an int in both C and C++.
"The demand for free goods is infinite."
0

#13 User is offline   kazx 

  • Member
  • Pip
  • Group: Members
  • Posts: 61
  • Joined: 08-February 09

Posted 15 September 2009 - 04:50 PM

please update the link its not working
0

#14 User is offline   Hasbro 

  • Project Manager
  • PipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 2,526
  • Joined: 07-June 08
  • Gender:Male
  • Location:New York
  • Server OS:Windows

Posted 15 September 2009 - 05:07 PM

Updated
0

#15 User is offline   Navid 

  • Persian Prance of ArcEmu
  • Group: Super Moderator
  • Posts: 718
  • Joined: 30-June 09
  • IRC:Lurker-
  • Gender:Male
  • Location:Iran
  • Interests:PHP,C++,ArcEmu and exactly our lovely community and specially money xD
  • Server OS:Windows

Posted 15 September 2009 - 06:29 PM

I like it,Hasbro : fix <a href="http://www.arcemu.org/standards/" target="_blank">http://www.arcemu.org/standards/</a> please on first post :)
I'm here to check,lurk and kill you so behave or you will be lurked

Posted Image
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users