by bcoates · 11y ago · 0 comments
if(self.predicate_function())
foo()
else
bar()
and self.predicate_function() is only called once in the program (this is the case several times in the slideshow example), try pulling the if statement into the function (and simplify), making a self.handle_case_something()
function instead. If the predicate is called more than once, consider subclassing. You're already doing OO, may as well do it right.send("#{group.type}_notification") or its python equivalent.
Maybe a hash table with strings as keys and functions as values for a less 'scripty' language.
Perhaps I'm thinking the variable group is of type group, but it also looks like it suffers from poor separation of concerns... eg. Why are groups sending email?
Probably also a good candidate for guards instead of nested ifs