Menu

#96 Primitive Obsession

open
nobody
None
5
2013-02-16
2010-11-18
Chris Mair
No

From Venkat's "Improving Your Groovy Code Quality" presentation at Spring 2GX (http://agiledeveloper.com/downloads.html) - slide #23

e.g.
def isSpellingCorrect(word) {
File file = new File("...")
def found = false
file.eachLine {
if (it == word) found = true
}
found
}

found is a flag and its a smell
Do you really have to loop through here?

Discussion


Log in to post a comment.