Code style

View previous topic View next topic Go down

Code style

Post  maximinus on Sun Mar 28, 2010 11:08 pm

This is the current code style for SPQR. I'm not going to defend it here (I think it's good, you may disagree), but feel free to add comments.

Code:
class CClassname(object):
    def __init__(self, some_argument):
        """A very simple function definition,
            Written over more than one line"""
        self.some_variable = some_argument
        # comment - did I mention we use tabs?
        a = 5 + 3
        if some_test:
            doSome(code)

    def someFunction(self, more_data_like_this):
        return what_you_need

Functions are written as verbs doSomethingNow

Variables are written as nouns this_is_my_data

Function docstrings are NOT optional.

It is better, in general, to over-comment rather than under-comment. Comments should tell you WHY, since the code tells you HOW.
However, too much commenting is a sign that something is wrong.

That's all for now folks Cool


Last edited by maximinus on Sat Jan 01, 2011 9:44 pm; edited 1 time in total (Reason for editing : Changed specs 1/1/11)
avatar
maximinus
Admin

Posts : 143
Join date : 2010-03-21
Age : 45
Location : Harbin, China

View user profile http://sourceforge.net/projects/spqr/

Back to top Go down

Re: Code style

Post  maximinus on Sat Apr 10, 2010 10:42 pm

One more thing: we use TABS to indent, not spaces.
avatar
maximinus
Admin

Posts : 143
Join date : 2010-03-21
Age : 45
Location : Harbin, China

View user profile http://sourceforge.net/projects/spqr/

Back to top Go down

Re: Code style

Post  maximinus on Sat Jan 01, 2011 9:47 pm

I have amended this to something a lot closer to PEP-8, as you can see from above. I figured that the code last week was about 9200 lines, now it's back down to about 5500 so now was the best time to get to work and change the style. Most of the main classes are done, but it'll still take a week or so till I'm completely done pale
avatar
maximinus
Admin

Posts : 143
Join date : 2010-03-21
Age : 45
Location : Harbin, China

View user profile http://sourceforge.net/projects/spqr/

Back to top Go down

Re: Code style

Post  maximinus on Sun Jan 02, 2011 8:34 pm

Haha cheers

A few spare hours at work and fast keyboard speeds: the whole codebase is now at this new standard Very Happy
avatar
maximinus
Admin

Posts : 143
Join date : 2010-03-21
Age : 45
Location : Harbin, China

View user profile http://sourceforge.net/projects/spqr/

Back to top Go down

Re: Code style

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum