12 ms·
I'd prefer: if post.editable? to everything I've seen. There's a concept behind the if statement that should go in the model. I realize this is sort of of
by mattgreenrocks 13y ago
I'd prefer:
if post.editable?
to everything I've seen. There's a concept behind the if statement that should go in the model. I realize this is sort of off-topic, but it kind of negates the whole discussion since you can wrap up the cute/ugly and test it alone. :)
- Camillo 13y agoA capital idea, my friend! But I'll do you one better: why not just wrap up the entire program inside a function called "main"? Clearly that would make all syntax discussions moot, now and forever.
- klodolph 13y agoAnd what would the definition of `editable?` look like? fn editable(&self) -> bool { self.created_at < 5.minutes().ago() } Yes, it's wrong. No amount of unit testing or isolation is going to change the fact that whenever you read code like that, your brain will come up with two conflicting meanings, because these cutesy methods make it look too much like English, and English has different rules. English parse tree is: ((less than (five minutes)) ago), whereas code parse tree is (less than ((five minutes) ago)).