重构复杂的boolean函数

 here’s what my first (virtual) solution was:

1
2
3
4
5
6
function Refactored(const someInputParameters : integer): boolean;
const
  returnValue : array [0..1] of boolean = (false, true);
begin
  result := returnValue[GetTickCount MOD 2];
end;

From the first look, the above implementation of a boolean function is as good as any. After all, it would return either true or false, there’s no 3rd option with booleans :)

 

tf

 

Fun: Refactoring a Complex Delphi Boolean Function

http://zarko-gajic.iz.hr/fun-refactoring-a-complex-delphi-boolean-function/

posted @ 2015-02-25 23:37  fanbbs  阅读(183)  评论(0编辑  收藏  举报