Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Development

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

Reply
 
Thread Tools Display Modes
  #1  
Old 02-27-2013, 04:47 PM
addingice
Sarnak
 
Join Date: Jan 2013
Location: United States
Posts: 33
Default Coding Style Guidelines?

Does the code have a coding style guidelines?

I've got a couple of weeks of relaxation time coming up and I wanted to read through the EQEmu code base to get to understand it, I was wondering if we had a code style guideline since I could slowly reformat into the code style anything I find as I go.
Reply With Quote
  #2  
Old 02-27-2013, 08:27 PM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

Interesting you should ask! I've been writing some on and off for some time. Though some of the rules I want to implement are... contentious: (moving to spaces over tabs for instance) which sort of keeps me from fully committing to actually getting them out. In fact many of the stupid changes I've been making have sort of been a prelude to getting the entire source more organized and easier to work with.

So I guess the answer is technically "no but I'd really really like to soon".
Reply With Quote
  #3  
Old 02-27-2013, 11:15 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

i approve of this thread.
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
Reply With Quote
  #4  
Old 02-28-2013, 01:08 AM
Drajor's Avatar
Drajor
Developer
 
Join Date: Nov 2012
Location: Halas
Posts: 355
Default

This would improve my quality of life.
__________________
Drajor regards you indifferently -- what would you like your tombstone to say?
Reply With Quote
  #5  
Old 02-28-2013, 02:24 AM
addingice
Sarnak
 
Join Date: Jan 2013
Location: United States
Posts: 33
Default

VHS was a pretty shitty standard, BETA Max was definitely better. but, and this is key, VHS was a standard!

Any standard, any standard at all, is better than no standard.

the space vs tab thing can be automated with tools so it's not important, any decision there at least can be fixed.

post what you have and we can squabble like children over them! hehe
Reply With Quote
  #6  
Old 02-28-2013, 03:07 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Quote:
Originally Posted by KLS View Post
(moving to spaces over tabs for instance)
I disagree with spaces over tabs. I think it would be fine to use spaces over tabs in cases such as structs or comments, just to standardize them, but for everything else (like tabbing out functions), I think spaces would suck.

Spaces are much harder to tell if you have the correct number of them for the current line you are writing. Of course, most editors will set you at the correct place automatically, but accidentally deleting an extra space will throw off the whole block you are working on if you keep working from that line on.

All decent editors allow you to tab out blocks of code by selecting the code and hitting tab X number of times. If you try that with space, it deletes your code and replaces it with a space. Even manually cleaning up formatting with this technique is much easier than doing it line by line with spaces.

If you are writing a new line of code and at the beginning of the line, you can hit tab a few times to put your code's start at the right position, but spaces would be a lot more. That is assuming you mean using multiple spaces in place of each tab. If planning to use a single space in place of each tab, that would just make it that much harder to read the format IMO.

Tabbing allows for easier movement around the source. I am sure there are alternatives to get around quickly, but tabs keep it nice and simple.

The only advantage I am aware of that spaces give over tabs is that all editors will display them the same so everything will line up no matter what you are using to view/edit the source. This is nice, but I think the benefits of tabs far outweighs a few comments (or whatever) not lining up. Maybe I am missing something?

I should have mentioned this in IRC when it was discussed a while back, but by the time I saw it the conversation had moved on and I forgot to get back to it.

Of course, it isn't my call and I am sure everyone can get by with whichever path is chosen. I just prefer stuff being easier/faster vs. lining up 100% of the time in every possible view. It will be great to have set standards for the project though. Many people are used to different styles and there is quite a mix in the source. At least with standards, some real formatting cleanup can be done throughout the source and not have people cleaning it up in their own way
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #7  
Old 02-28-2013, 03:26 AM
demonstar55
Demi-God
 
Join Date: Apr 2008
Location: MA
Posts: 1,165
Default

Yeah, but all editors can be set up to have the tab key insert spaces. (all as in all but maybe notepad ...)
Reply With Quote
  #8  
Old 02-28-2013, 03:44 AM
Drajor's Avatar
Drajor
Developer
 
Join Date: Nov 2012
Location: Halas
Posts: 355
Default

IMHO one person should decide on the standard. Maybe this person can consult the other core devs about the decision privately. Allowing 'discussion' openly on this will just cause religious-like debate and waste time.

Any (commercial) software developers here that have joined an established company will most likely all have a similar story. They are handed the coding standard and expected to write code which conforms to it. End of story.
__________________
Drajor regards you indifferently -- what would you like your tombstone to say?
Reply With Quote
  #9  
Old 02-28-2013, 03:59 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Quote:
Originally Posted by demonstar55 View Post
Yeah, but all editors can be set up to have the tab key insert spaces. (all as in all but maybe notepad ...)
That would help with some of the inconvenience of using spaces over tabs, but can you also configure them to backspace to delete a tab worth of spaces in a single button press? My carpal tunnel is bad enough that I try to keep things as minimal as possible when I can.

Pretty simple change to switch tabs to use space for Notepad++ here:
http://stackoverflow.com/questions/4...tabs-to-spaces

Either way, I like it when stuff works out of the box without requiring configuring stuff like editors to simplify things. No doubt people will be coding without awareness of that setting and it would be harder on them. Even if it is a simple configuration change, I think no change required is still best.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #10  
Old 02-28-2013, 09:35 AM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

Decrease indent by a tab worth of spaces on any Windows editor worth something: shift+tab.

Pretty sure Vim has a way to decrease indent too but I don't use it enough to know how offhand.
Reply With Quote
  #11  
Old 02-28-2013, 08:56 PM
Kayen
Developer
 
Join Date: Mar 2009
Location: -
Posts: 228
Default

Quote:
Any (commercial) software developers here that have joined an established company will most likely all have a similar story. They are handed the coding standard and expected to write code which conforms to it. End of story.
This not a company though, it is a handful of people developing the source in their limited spare time. Making the process more burdensome may raise the level entry for new contributors and discourage others.
Reply With Quote
  #12  
Old 02-28-2013, 09:34 PM
demonstar55
Demi-God
 
Join Date: Apr 2008
Location: MA
Posts: 1,165
Default

Quote:
Originally Posted by Kayen View Post
This not a company though, it is a handful of people developing the source in their limited spare time. Making the process more burdensome may raise the level entry for new contributors and discourage others.
But standardizing things can help with maintenance by the other devs
Reply With Quote
  #13  
Old 02-28-2013, 09:49 PM
lerxst2112
Demi-God
 
Join Date: Aug 2010
Posts: 1,743
Default

Changing from tabs to spaces or the reverse can be a lot of fun with merges if your preferred diff program doesn't properly ignore whitespace/line endings.

http://www.hanselman.com/blog/YoureJ...InTheWall.aspx


The best standards are simple and lightweight, otherwise people just won't follow them, even at a professional job. Most of the ones I've written are 10 or fewer bullet points and all of the formatting issues are things that you can easily do with astyle or another formatting utility so that even if people prefer to work a different way they can easily make their code conformant before they check it in.

My personal preference has always been to use 4 spaces for an indent, but I'm fine with tabs too. In fact, tabs might be better for those mildly insane individuals that like 2 character indents, or the ones that were dropped on their heads repeatedly as children that use proportional fonts.
Reply With Quote
  #14  
Old 02-28-2013, 10:45 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

hah. i just got through trying the 2 character indentation after looking at google's style guide. i had to take a shower afterwards.
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
Reply With Quote
  #15  
Old 02-28-2013, 10:55 PM
wolfwalkereci
Discordant
 
Join Date: Dec 2005
Posts: 435
Default

Quote:
Originally Posted by c0ncrete View Post
hah. i just got through trying the 2 character indentation after looking at google's style guide. i had to take a shower afterwards.
Lol man that cracked me up.
I support the idea of any standard the senior dev's put out.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 01:10 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3