Code creation form specification 1.0 (for delphi) shunzimm [original]

zhaozj2021-02-16  86

The purpose of this specification: a unified look, enhanced readability, understandability, and maintainability of this code: Name reflecting the meaning of the structure 1, the unit style 2, various zone 3, Statement Style 4, Naming Rules Reference: Borland Official Object Pascal Style Guide Delphi5 Programmer Guide Code Standard 1, Unit Style {************************************************************************************************************************************************************************************************************************************************** ******************************} {} {project name} {} {copyright (C) 2000, 2001 Company Name } {} {**************************************************** *********} Unit unitname; {******************************************* ******************* project: module: description: version: date: author: update: todo: *************** ************************************************} Interface Uses ----, - -, ----, ----, ----, ----, ----, ----, -, ----, ----, ----, ----, ----; const --------------------; ------------------------------------------; Type ------- --------------------------------------- -----; --------------------------------------- -; --------------------; Var --------------------; ----- ---------------; --------------------; Implementation Uses ----, ----, - ---, ----; {$ r * .res} {$ r * .dfm} --------------------------- -----; ------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----; ------------------------------------------------------------------------------------------------------------------ --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---; ----------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------; End. Return 2, each area 0, annotation and blank use {} no // topic annotation, function processes, statement comment blank line: Copyright block, class, method - (two lines)

Methods Internal block (one line) space: to enhance clarity indent: two spaces 1, constant zone basic: const ----- = ----; ----- = ----; - --- = ----; ----- = ----; extended prefix: less c _---; Many, you can have a prefix const {topic 1} c _--- = ---; {meaning} c _--- = ----; {meaning} c _--- = ----; {meaning} c _--- = ----; {meaning} {topic 2} ----- = ----; ----- = ----; ----- = ----; ----- = ----; resource string, put it RESOUNGESTRING Const S _--- = '----'; s _--- = '----'; S ----- = '----'; example: cm_base = $ b000; cm_activate = Cm_base 0; cm_deactivate = cm_base 1; cm_gotfocus = cm_base 2; cm_lostfocus = cm_base 3; Numpaletteentries = 20; BoxPoints: array [0..5, 0..2] of glfloat = ((-1, 0, 0), (0, 1, 0), (0, 0, 0), (0, 0, 1), (0, 0, -1)); {Variant Type Codes (wtypes.h)} Varempty = 0000; {vt_empty} varnull = $ 0001; {vt_null} varsmallint = $ 0002; {vt_i2} gifversions: array [gv87a..gv89a] of tgifversionRec = ('87a', '89a'); 2, Type Area Data Type - > Data type T ---- = --------- Object Type -> State Type -> State and Provide Service T ---- = Class (----) Private - ------ -------- Protected -------- -------- Public -------------- Published - -------------- END; Sort Private 1 by alphabet 1, all data is placed in the Private area,

With F Head 2, all event attributes correspond to the PRIVATE area, with F Head 3, attribute's GET and SET methods are placed in the Private zone -> Not ready to be inherited 4, the method of responding to the message PROTECTED 1. Methods of the quilt call but cannot be called by the outside, the method of providing a subsidiary overload method Virsual; Virsual; AbstractPublic 1, constructing a destructive method 2 for external calling method 3 for external calling attributes Published 1. An example of an event response used in Object Inspector for design in Object Inspector appears in Object Inspector: Tgifversion = (GVunkNown, GV87A, GV89A); TGifversionRec = array [0..2] of char ; pinterfacetable = ^ tinterfacetable; tinterfacetable = packed record entrycount: integer; entries: array [0..9999] of tinterfaceentry; {forword declairation} tgifimage = class; tgifsubimage = class; {----------- ---------------------------------------} TGIFITEM = Class (TPERSIStent Private fgifiMage: TGIFIMAGE: TGIFIMAGE; ............. End; 3, Variable Area Definition Global Variable Don't have default class object variables, declare in the caller! VAR -----------: -------; -----------: -------; example: gifdelayexp: integer = 10; { DELAY MULTIPLIER IN MS.} gifdelayexp: integer = 12; 4, implementation zone {--------------------------------- ------------------------ Theme ------------------------- --------------------------------} {Method} Procedure ---------- ----------------------------; --------; end; {method's purpose} Function ----- --------------------------------; --------; end; 5, process and functions Name format returns 3, statement style 1, simple statement -------; 2, composite statement begin ----; -----; end; 3, assignment statement -: = ------ -; -: = (- -) * (- / -); 4, local variable var ---: ---; ---: ---; Variable group: var ---, ---, ---: ---; 5, array statement --- = array [*.. *] Of ---; 6, if statement IF (---- ----) THEN -------------;

if (--------) then begin -------------; -------------; --------- ----; End; IF (--------) -------------; Else -------------; IF --------) then begin -------------; -------------; ----------- -; ELSE -------------; if (--------) THEN BEGIN -------------; ---- ---------; -------------; end else begin -------------; --------- ----; -------------; end; if (--------) then ------------- else if (- -------) then -------------; 7, for loop for i: = -------- to -------- do - ------------; for i: = -------- to -------- do begin -------------; -------------; -------------; end; for i: = -------- to ------- - do if (--------) then begin -------------; -------------; ------- ------; End; for i: = -------- To -------- do with ------- The begin -------- -----; -------------------------; End; 8, while loop while ------ Do Begin -------------; -------------; -------------; End; 9, Repeat cycle repeat -------------; -------------; -------------; until ------ ; 10, case statements case -------- of --------: -------------; --------: --- ----------; --------: -------------; else -------------; end ; case -------- of --------: ------------------------------ -----------------------------------; --------: ----- -------------------------------------------------- ----------; --------: ------------------------------ -----------------------------------; else ------------- -------------------------------------------------- -;

Case -------- Of --------: Begin --------------------------; --- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ; END; --------: Begin -------------------------------------- ------------------------------------------; End; ----: Begin ------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------; ELSE BEGIN ---------- ---; -------------; -------------; end; end; 11, with statement with -------- do -------------; with -----------------------; ----------- -; -------------; End; 12, try statement try -------------; ------------ -; ----------- -; Finally -------------; -----------; End; Try Try -------------; -------------; -------------; Except ------- -------------------; End; Finally --------------; -------------------------------------------------; -; -------------; End; 13, other operations: There must be space W1 before and after the operator [N]: = ((i 1) * v0 [n] j * v1 [N] (k - 1) * v2 [n]) / depth; - = - -> = - - <= - -> - - <- - <> - -: = -; Assignment -: ----; Type The same type and mean the logically uncomposed variable 20 characters long variable name private -------------- -; -------: -------;

-------: -------; -------: -------; -------: -------; var - ------: -------; -------: -------; -------: -------; ----: -------; -------: -------; Function ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (----; -: ----; -: ----; Variables such as ERROR0, ERROR1, ERROR2; R, G, b private -------, -------, -------, -------------: ------ - Var -------, -------, -------------, -------: ------- Function -------------------- (-, -: ----; var -, -, -: : ----; t ------- = Class (-------) Private F -------: -------; f ----- -: -------; F -------: -------; function ---- ----------: -------; Procedure --------------; protected function ------------- -: - -------; Procedure --------------; Function ---------------------; Virtual; abstract; -------: -------); OVERRIDE; {if Need to do something atten; {ion; {iNEd to do something; Function --------------: -------; Procedure --------------; Property -------: - ------ Read F -------; Published end; 14, the form reflects the configuration example: TetIndex: array [0..3] of tinteger3v = ((0, 1, 3), (2, 1, 0), (3, 2, 0), (1, 2, 3));

Cursors: array [0..4] of tidentmapentry = ((value: crdefault; name: 'crdefault'), (value: Crarrow; Name: 'CRarrow'), (Value: crcross; Name: 'crcross'), value: cribeam; name: 'cribeam')); if (dwflags and pfd_draw_to_window) = 0) or ((dwflags and pfd_support_opengl) = 0) or ((dwflags and pfd_doublebuffer) = 0) or (ipixeltype <> pfd_type_rgba) or ( CColorBits <16))) The Raise Exception.create ('INAppropriate Pixel Format Chosen.'); glbegin (shadetype); Glnormal3FV (@ n0); GlvertEX3FV (@dodec [a, 0]); GlvertEX3FV (@dodec [b, 0]); GLVERTEX3FV (@dodec [c, 0]); GLVERTEX3FV (@dodec [d, 0]); glvertex3fv (@dodec [e, 0]); glend (); dodec [0, 0]: = - Alpha; DODEC [0, 1]: = 0; DODEC [0, 2]: = Beta; DODEC [1, 0]: = alpha; dodec [1, 1]: = 0; DODEC [1, 2]: = Beta; DODEC [2, 0]: = -1; DODEC [2, 1]: = -1; DODEC [2, 2]: = -1; Procedure GlutwireTorus (in Nerradius: gldouble; // --------- Outerradius: gldouble; // --------- nsides: glint; // --------- rings: GLINT); // --------- Case Frundirection of Rdrighttoleft: Begin Sty: = CNY; Stx: ​​= Width - Currentstep; End; RDLEFTTORHT: BEGIN STY: = CNY; STX: = - CURRENTSTEP; END;

转载请注明原文地址:https://www.9cbs.com/read-11908.html

New Post(0)