Re: Software specifications



> I'm not sure if it is better to organize functions and procedures alphabetically
> or in some other order.

I sort my header declarations (in the type clause) alphabetically
within each visibility sub-section. Then in the implementation clause I
order approximately functionally, so that methods associated in a
program function appear together, with general procedures & functions
first, then methods. And within the methods, constructors first, then
property accessors, menu event handlers, then the rest (in functionally
associated groups), with form close handlers at the end and finally
destructors (if I have any).

> I have some large units that probably should be broken into smaller functional chunks

I don't think it helps to break units down into too small elements.
Class separation will lead the way there. I break code within a unit
down into a separate method/procedure if I use short lengths of code
three or more times, longer lengths of code two or more times. for
multiple code use within one method I use a local sub-procedure.

I have a what may be a slightly ideosyncratic approach to code
arrangement. I believe that the nodes of conditional statements are the
keys to understanding program flow. So "begin(s)" are always in-line
with the conditional, "end(s)" are always commented with the
conditional code (not its description). Long single-statement
conditionals which do not require an "end", have one in a comment.

eg (this should be viewded in fixed pitch font or preferably in Delphi
formatting) ...

if (Users.AllSecList.Count = 0) then begin
{check if secretaries in system}
Msg := 'There are no secretarial services allocated to you' + #13 +
#13 +
'Contact your system administrator to' + #13 +
'add your secretaries before running this program';
Application.MessageBox(PChar(Msg), 'Lexacom Talk', MB_OK or
MB_ICONHAND);
Application.Terminate;
Exit;
end
else
with SecCmbBox do begin
Items.Assign(Users.CurrentUser.SecList);
ValidateSecServices; // check that secservices are valid
{now add e-mail & save-to-disk at bottom}
Items.AddObject('< e-Mail >', TObject(EMailDWdFlag));
Items.AddObject('[ disk ]', TObject(DiskDWdFlag));
ItemIndex := 0; // default secretary is first in list
SecCmbBoxChange(nil); // set SecId, SendBtn.Tag and other items
end; {with SecCmbBox}
{end; if Users.AllSecList.Count = 0 else}

(* I will not participate in a religious war regarding my code style
<g> *)

Alan Lloyd

.