On Sun, 14 Dec 2008 06:48:58 -0800 (PST) Samuel Herzog <[email protected]> wrote:
> Hi folks, > I had some minutes of sparetime and went through control.inc. > > Two things I d' like to ask: > > 1.) sometimes "parent"/"FParent" are checked for nil, before the > method access it, and sometime not. Is this by purpose or are this > potential Access-Violation candidates. For example? > 2.) In my programming-style I often check the conditions of input > parameters at the begin of the method and leave with "exit"-statement > if the conditions do not match the current needs. > > As for example like here: > procedure TControl.ParentFontChanged; > begin > if csLoading in ComponentState then exit; > > Such things make the code much better readable. > > I also use this in situations like this: > > procedure TControl.SetColor(value : TColor); > begin > if FColor <> Value then > begin > FColor := Value; > FParentColor := False; > Invalidate; > end; > end; > There is no need for begin/end-statement. > if FColor=Value then exit; > > Are there any rules for lazarus in this case or can everyone handle > this as he likes ? Some people consider 'exit', break' and 'continue' as harder to read. IMO it is a matter of taste and both are equally readable, so both should be allowed. see http://wiki.lazarus.freepascal.org/DesignGuidelines Mattias _______________________________________________ Lazarus mailing list [email protected] http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
