proposed change to style(9): require yoda style if

Ryszard W. Czekaj rychoo at freeshell.net
Sat May 15 04:48:03 UTC 2010


 > The convincing one applies to Java and C++:
 > if (constant.equals(object))
 > instead of
 > if (object != null && object.equals(constant))
 > actually looks easier to read.
 > 
 > Though you are right about constants being pretty rare.
 > 
>  > Your .sig is strangely appropriate...
 > 
 > Not my invention, this is a pretty common one, used by many people
 > on the net. I actually have no idea where it comes from.

I think that this second is safer because using of null object caught/trow exception in any language, so you are checking at first if object exist and if you are using by calling object.equals..

---
+48 882 723907
http://Czekaj.net.pl/
Version: 3.12
GIT d- s: a+ C++ UB+++ P+ L- E--- W+++ N+ o-- K++ w++ O M++ V- PS+++ PE- Y+ PGP+ t 5 X+ R* tv+ b+ DI D++ G e+++ h! r% y+
---
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SQDJ4F2KX3LYG
BZ WBK S.A. 1 Oddz. Wodzisław Śląski
SWIFT BiC: WBKPPLPP PLN PL 66 1090 1766 0000 0001 1209 3433
EUR PL 74 1090 1766 0000 0001 1209 3433 GBP PL 62 1090 1766 0000 0001 1004 4671




More information about the freebsd-hackers mailing list