Re: After some advice for improving coding skills
From: J French (erewhon_at_nowhere.com)
Date: 03/08/04
- Next message: J French: "Re: Memory lost tool"
- Previous message: J French: "Re: Writing to a disk file compressed"
- In reply to: AlanGLLoyd: "Re: After some advice for improving coding skills"
- Next in thread: reynoldscraigr_at_hotmail.com: "Re: After some advice for improving coding skills"
- Reply: reynoldscraigr_at_hotmail.com: "Re: After some advice for improving coding skills"
- Reply: Nicolai Hansen: "Re: After some advice for improving coding skills"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 8 Mar 2004 14:43:04 +0000 (UTC)
On 08 Mar 2004 13:47:55 GMT, alanglloyd@aol.com (AlanGLLoyd) wrote:
>In article <64cc8ef871321ea67683dad0d90cd0c1@news.teranews.com>,
>reynoldscraigr@hotmail.com writes:
>
>>I find I'm making more mistakes coding that I like of late, so have
>>deciding I need to do something about it, so any pointers regards the
>>above mentioned are welcome.
>>
>
<snip>
>
>Name variables, procedures and function with meaningful names. In general
>procedure names should be verbs and function names should be nouns or verbs.
>You should be able to have comments which are minimal and high-level if you
>name appropriately.
And give things that only have 'life' for a few lines obviously
innocuous names:
eg: S is a string that is just used for a quick manipulation
L9, L8, L7 are loop variables
>
>Comply with conventions - type naming, camel-case names, additional spaces
>around assignment and operator symbols.
>
>Indent conditionals, and comment your "end;"s. Think hard about, and have real
>justification for, any idiosyncratic layout of your code. Be consistent in your
>coding.
And have a look at: http://delphi.about.com/cs/standards/
>Code for clarity not apparent speed, rarely write "tight code". Concentrate on
>good algorithms, not what you think will be fastest (the Delphi optimiser is
>quite good). Use the "six-month rule" - "Will this be clear to anyone when i
>come back to it in 6 month's time".
Or when I am pissed/knackered/desperate - could I read it ?
>
>Minimise the scope of your units in "uses" clauses.
(ie: Trim your Uses clauses viciously)
>
>Respond _always_ to Delphi's hints and warnings.
Never ignore a warning, never cheat
>When you've written your code and it works - then go back and "polish" it -
>make sure that it _is_ the quality you want to publisn.
We call it 'Combing'
- just keep going over things until they look obvious
(ie: untangle the knots)
>
>And possibly idiosyncratic ...
<snip>
>Use "with" carefully - don't encompass more than one line of statements.
'With' is lethal - creating a temporary (anodyne) variable is cheap
<snip>
I would add to that ( sound advice )
1) Write Delphi as Delphi is meant to be written
( it took me some years to realize that )
2) When you /have/ to have Global or Common variables
- put them in a Record so it is:
glb.DataPath
cmn.DisableClonesFlag
3) Name non-object procedures and functions with regard to scope
LS_TweakThis( Var .... )
LF_GetSomething(
( Local stuff should look local - ie: Unit specific
... that stuff came from before PCs )
Don't be ashamed of writing: Windows.GetParent( ...
4) Turn all debugging on, and leave it on
(also do not be ashamed of error messages
- the more meaningful the better)
And mercilessly break all rules that you or others have set, if it
makes code /clearer/ - not faster.
- Next message: J French: "Re: Memory lost tool"
- Previous message: J French: "Re: Writing to a disk file compressed"
- In reply to: AlanGLLoyd: "Re: After some advice for improving coding skills"
- Next in thread: reynoldscraigr_at_hotmail.com: "Re: After some advice for improving coding skills"
- Reply: reynoldscraigr_at_hotmail.com: "Re: After some advice for improving coding skills"
- Reply: Nicolai Hansen: "Re: After some advice for improving coding skills"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|