Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 124
Developer: Coding guidelines
primalmotion edited this page Aug 19, 2011
·
1 revision
This page describes the way we code for Archipel. In order to avoid to make code weird sometimes, please follow the these guidelines.
The client is written in Cappuccino. We mainly follow the Cappuccino Coding Guidelines. So you must read it.
We only differ on the following points:
- We use underscored instance variables names, even if we are not working on the Cappuccino Framework itself.
- We sort alphabetically the instance variables according to differents groups (see below)
- We do not use underscored variables names for outlets.
- We use explicit variables names (same as in Cappuccino, but so important)!
- We DO NOT use tabs. Use 4 spaces indentation
- We align values when declaring several variables (see below)
- We alphabetically sort imports and we first import
<Frameworks/Stuff.j>then"ourstuff.j" - All your code must successfully pass the capp_lint tests
- Only one class per file
@import <AppKit/Appkit.j>
@import <StropheCappuccino/StropheCappuccino.j>
@import"mystuff.j"@implementationMyAwesomeAwesomenessController : CPObject
{
@outlet CPTextField textFieldName;
@outlet CPView viewAwesomeStuff;
CPArray _arrayOfThings @accessors(getter=arrayOfThings);
CPString _name @accessors(property=name);
CPNumber _numberOfThings;
CPString _bar;
CPString _foo;
}
- (void)performAwesomeness:(CPString)aParameter
{
var spam = @"spam",
egg = @"egg";
// do stuffreturn something;
}
@end@import <StropheCappuccino/StropheCappuccino.j>
@import"mystuff.j"
@import <AppKit/Appkit.j>
@implementationmy_awesome_awesomeness_controller:CPObject {
@outlet CPTextField textfieldname;
CPString b;
CPString f;
@outlet CPView viewAwesomeStuff;
CPArray arrayOfThings @accessors();
CPString name @accessors();
CPNumber nums;
}
- (void)perform_awesomeness:(CPString)p {
var spam = @"spam";
var egg = @"egg";
var i, j, k;
// do stuffreturn s
}We are more flexible with the coding style of archipel agent and modules. The golden rule is you must pass pyflakes test.
- We follow PEP8
- We use explicit variables names
- We align values when declaring multiple variables (not conform to PEP8, you can ignore these warnings)
- We remove all trailing spaces (TextMate users make sure you have Uber Glory installed)
- We sort alphabetically imports in following order:
- pure python packages
- archipelcore
- local packages
- We DO NOT use
from package import *
You can use the PEP8 bundle for TextMate to parse your code
importmd5importosimportsysfromarchipelcore.pubsubimportTNArchipelPubSubfromarchipelcore.utilsimportlog, build_iq_error, build_message_errorimportmylocalpackageAWESOME_SUPER_GLOBAL=1ANOTHER_AWESOME_SUPER_GLOBAL=2classMyClass (object):
"""description of the class"""def__init__(self, parameter1, parameter2):
""" initialize MyClass @type parameter1: object @param parameter1: the first parameter @type parameter2: object @param parameter2: the second parameter """self.spam="spam"self.egg="egg"ifparameter1:
self.foo=parameter1ifparameter2: self.bar=parameter2self.do_something()importmylocalpackageimportmd5fromarchipelcore.pubsubimportTNArchipelPubSubfromarchipelcore.utilsimportlog, build_iq_error, build_message_errorimportsysimportosawesomesuperglobalA=1another_awesome_super_globalA=1classMyClass( object ):
"""description of the class"""def__init__( self,parameter1,parameter2 ) :
self.s="spam"self.e="egg"ifparameter1 :self.foo=parameter1ifparameter2 : self.b=parameter2self.doSomething ()