Re: After some advice for improving coding skills

From: J French (erewhon_at_nowhere.com)
Date: 03/08/04


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.



Relevant Pages

  • Re: After some advice for improving coding skills
    ... >>procedure names should be verbs and function names should be nouns or verbs. ... any idiosyncratic layout of your code. ... not what you think will be fastest (the Delphi optimiser is ...
    (comp.lang.pascal.delphi.misc)
  • Re: Delphi 6 has become flaky and unusable - AV in module coreide60.bpl
    ... >Delphi 6 has been working fine for a number of years. ... Does it load a project on startup? ... Since it is the IDE that is blowing itself into tiny pieces, ...
    (borland.public.delphi.non-technical)
  • Re: Evaluating D2005, help needed.
    ... > quality of Delphi still hasn't crossed below the productivity of Visual ... and had built several database test cases to backup your claims but now it seems ... Delphi for Win32 and VS.NET for .NET and while I'm quite confident that my ...
    (borland.public.delphi.non-technical)
  • Re: Native Delphi IDE
    ... I think their current strategy to have an IDE which hosts both Win32 ... comparison to what us Delphi developers are used to, ... As I read about the world wide BDS 2006 road show, I wonder how it could be ...
    (borland.public.delphi.non-technical)
  • Re: Mix of stuff....
    ... >about linux would fit in a thimble. ... I mainly use Delphi for writing DLLs ... >to get back to making working code. ...
    (comp.lang.pascal.delphi.misc)