Re: Literate style, making code more readable or going overboard?
Jeff Foster <[email protected]> Wed, 10 Feb 2010 09:22:10 +0000
| Newsgroups | gmane.comp.programming.refactoring |
|---|---|
| Message-ID | <[email protected]> |
I can think of two reasons - IsEmpty expresses the intent more clearly (I'm not checking the size of the list, I'm checking whether it is empty) - isEmpty is often O(1) implementation whereas size() can be an O(N) operation. On 10 February 2010 08:12, Markus Knittig <[email protected]> wrote: > > > George Dinwiddie wrote: > > if (!adminUsers.isEmpty()) { > > ... > > } > > Not exactly topic related but are there any specific reason why you > prefer this instead of: > if (adminUsers.size() > 0) { > ... > } > ? > Cause I learned that you should avoid negotiating conditions. > > Best regards, > Markus > > [Non-text portions of this message have been removed] ------------------------------------ Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/refactoring/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/refactoring/join (Yahoo! ID required) <*> To change settings via email: [email protected] [email protected] <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/