One could argue that Min_Positive is a somewhat misleading name for the global constant, given that zero isn't a actually a positive number?!?we have got a global constant called "Min_Positive" which is defined as a Real equal to 0.
Code: Select all
if not collection.isEmpty
...
endif;
Code: Select all
if not collection.isEmpty
foreach obj in collection
...
endforeach;
endif;
Eek - two trips to the server to get two locks instead of one (assuming you're not in load state).[Code: Select all
if not collection.isEmpty foreach obj in collection ... endforeach; endif;
Code: Select all
if (allThingies <> null) then
foreach thingy in allThingies do
endforeach;
endif;
... and assuming you're not in lock state (yuck!) and that it's not a stable or frozen collection.Eek - two trips to the server to get two locks instead of one (assuming you're not in load state).
Code: Select all
doValidate() : Boolean;
vars
begin
if something then
globalBool := true;
else
globalBool := false;
endif;
return true;
end;
Code: Select all
doValidate(); //Call doValidate
if globalBool then
// Continue
endif;
end;
There is only Min_Positive in our system. Here is the comment that was made in 1997 why it was implemented:Ok I'll bite,
What value is assigned to Min_Negative ?
Rather than checking the size of the collection, isn't it simpler to just call Collection.isEmpty ? At least that way you never have to worry about someone changing the value of Min_Positive.
Dr Danyo.
Good point! It is good to know I have your support on doing a global search and replace on Min_Positive and getting rid of it once and for all.One could argue that Min_Positive is a somewhat misleading name for the global constant, given that zero isn't a actually a positive number?!?we have got a global constant called "Min_Positive" which is defined as a Real equal to 0.
I'm with Dr D. on this one, using Collection.isEmpty makes the code more readable as well, even if you have to put in a not statement:
... assuming of course the only code within the if statement isn't something like:Code: Select all
if not collection.isEmpty ... endif;
Cheers,Code: Select all
if not collection.isEmpty foreach obj in collection ... endforeach; endif;
BeeJay.
Heh, sounds like blind adherence to a dogma. If you dont like the hard-coded 0 you can always use the null keyword.There is only Min_Positive in our system. Here is the comment that was made in 1997 why it was implemented:
"Added, constant for checking that various pieces of data are greater than or equal to zero when we are maintaining them.This is to prevent the use of actual numbers in code."
I hope sizeOfActive doesn't loop through the collection counting them. You might be better off using conditions to create an active and inactive collection.I always use isEmpty unless we are using a collection that stores active and inactive data, then I will use collection.sizeOfActive > 0
Yeah get rid of it, there is a time and a place for replacing literals (magic numbers) with constants, the key to this, is the literal has to have a specific meaning, e.g DRINKING_AGE, TAX_RATE, make good constants for 18 and 12.5.Good point! It is good to know I have your support on doing a global search and replace on Min_Positive and getting rid of it once and for all.
Code: Select all
doSomething( pSomeCollection : MyCollClass io );
vars
someObject : MyClass ;
begin
someObject := ...;
pSomeCollection.add( someObject );
end;
Code: Select all
doSomething( pSomeCollection : MyCollClass input );
vars
someObject : MyClass ;
begin
someObject := ...;
pSomeCollection.add( someObject );
end;
Return to “General Discussion”
Users browsing this forum: No registered users and 11 guests