ImageEn

Style Guide


This section is for ImageEn internal usage only!

Casing

Correct case for types like: False, True, Boolean, Integer, Double, Cardinal, Byte, Pointer, LongBool, Single, Double, PByteArray, PWordArray, PByte, DWord, Variant, PChar, PWideChar, etc.
Ensure lower case for: string, nil, try, finally, except, begin, end, if, then, else, var, const, type, out, class, inherited, deprecated, experimental, inline, set, record, array etc.
TitleCase for parameters and method names
camelCase for local vars
Consts must include underscores and Title_Case is preferred
Defines are lowercase: {$ifdef}, {$else}, {$endif}, {$define}, {$undef}, {$include}. Except for {$ifNdef} which uses a capital N
Fields are TitleCase with a lowercase f. Global vars are prefixed with a lowercase g
VCL directives like {$R-} and {$Q-} are uppercase
Other preferred casing: FileName, Result, HResult

Spacing

No spaces before colons when a parameter or var block (ok in case statements, for example).
Always a space after a colon for vars, parameters, etc.
Binary operators: space around :=, =, +, <, >, <=, >=, <>, etc.
Spacing within brackets when a local comparison (everywhere except method parameters), e.g. "if ( x > 0 ) then..."
For any indentation, use double spaces

Line Breaks

There should always be a hard return after a raise exception or exit (unless followed by end or inside an except block)
No hard return after begin, except or finally. Generally no hard return before end (except for readability like with case statements)
begin and else must always be on the next line, not "if x then begin" or "end else"

Other

Methods without parameters (calls and declarations) should include empty brackets();
Float literals: 1.0, not 1
Value parameter for property settings is always named v, e.g. procedure TClass.SetXYZ(const v: string);
Local methods within a method should have _Underscore() prefix
Empty lines between local methods within a method should be {}
begin/end not required for single code lines
Preferred comment style: // or {}
Avoid any magic strings
Boolean variable/property naming: should start with Is, Has, Can
All units must include {$I ie.inc}
Avoid use of "with". Use explaining vars instead
AnsiString methods should have an A suffix, WideString should have W, string should NOT have S

Preferred Names for Local Vars

Class Local Var
PRGB px, pxRGB
TFileStream, TIEWideFileStream fs
THandle h
TIEBitmap, TBitmap bmp
TIEBufferedStream bs
TIECanvas, TCanvas cv
TIEFileFormatInfo fi
TIEMemStream, TMemoryStream ms
TIEMask msk
TIEPixelFormat pf
TIEQuantizer qt
TImageEnIO io
TImageEnMIO mio
TImageEnProc proc
TImageEnView iev
TIOFileType ft
TIOParams iop
TPoint pt
TPointer ptr, p
TProgressRec proc
TRect r
TRGB rgb
 
Purpose Local Var
Count cnt
File extension ex
File name fn
For next i
Index idx
Length len
Simple string s
Size sz
Version ver
Width, Height w, h, ww, hh
X, Y x, y, xx, yy, x1, y1, x2, y2