dolibarr-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Dolibarr-dev] Start using booleans instead of integers acting like


From: Laurent Destailleur (eldy)
Subject: Re: [Dolibarr-dev] Start using booleans instead of integers acting like booleans
Date: Mon, 06 Aug 2012 01:44:00 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0

Le 06/08/2012 01:17, Marcos García a écrit :
Hello,

I've checked Dolibarr's code and I've seen that many functions are using integers 1 and 0 as booleans, which actually shouldn't be used because:
1. When checking for True or False, it could be a conflict between 0 and False

This should not happen because when a variable int is used as a boolean, we want 0 to be false and 1 to be true. And this is the defautl behaviour of PHP:
0=false
1=true

We simply should never use boolean but we prefer using integer with rule (0=false, 1 or other = true). When we need a third value (2), we can replace test if ($var) with if ($var==1) or if ($var ==2) according to what we want to do.

That's why we must only use integer.
Boolean is a type very useless and we often need to modify to support a third value, so let's start from scratch with directly int. Even if at the beginning, we need only 2 values.
2. It's not a good practice.

I think this should not be changed immediately but start migrating into it.

Regards,
 
Marcos García
address@hidden



_______________________________________________
Dolibarr-dev mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/dolibarr-dev


-- 
Eldy (Laurent Destailleur).
---------------------------------------------------------------
EMail: address@hidden
Web: http://www.destailleur.fr

Dolibarr (Project leader): http://www.dolibarr.org
To make a donation for Dolibarr project via Paypal: address@hidden
AWStats (Author) : http://awstats.sourceforge.net
To make a donation for AWStats project via Paypal: address@hidden
AWBot (Author) : http://awbot.sourceforge.net
CVSChangeLogBuilder (Author) : http://cvschangelogb.sourceforge.net

reply via email to

[Prev in Thread] Current Thread [Next in Thread]