You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
- 1Can't argue with 22.8K rep... My issue was that first we are told to decouple, decouple, decouple, and separate validation logic from data model and then you see this kind of code from people with years of experience doing the opposite and you just get so confusediAteABug_And_iLiked_it– iAteABug_And_iLiked_it2013-08-29 13:22:01 +00:00Commented Aug 29, 2013 at 13:22
- 16@iAteABug_And_iLiked_it - No, by all means you should argue with me if you think I'm wrong. And in general, you should go nuts with decoupling - but there's always some line where you need to stop or else you end up with classes that have only one variable making your code completely unusable. That line is a trade off, and one you'll be able to guess more accurately with experience. If you're light on experience, err towards more decoupling.Telastyn– Telastyn2013-08-29 13:30:30 +00:00Commented Aug 29, 2013 at 13:30
- 2While I agree that this is pretty standard and possibly good enough (in the "we've got bigger problems elsewhere" kind of way), it's still not particularly pretty. It's not DRY (e.g. one or two classes down the line I'd get irritated that child object's validations have to be manually merged in, with the same code each time), encourages monolithic methods (with high cyclomatic complexity), has a low signal to noise ratio, etc. To be fair, the book might later on refactor some of it into a more generic form.Daniel B– Daniel B2013-08-29 13:52:32 +00:00Commented Aug 29, 2013 at 13:52
- 2@iAteABug_And_iLiked_it you can always argue with rep. Simply accepting an argument because of rep is the "Argument from authority" logical fallacy (en.wikipedia.org/wiki/Argument_from_authority). Aristotle had (and still has) huge rep but that doesn't mean that vultures are impregnated by the wind. Not saying Aristotle was a rep-whore, of course ;)itsbruce– itsbruce2013-08-29 14:34:05 +00:00Commented Aug 29, 2013 at 14:34
- 1I'm not that bright; I missed that this was a model with validation, I read the code snippet as an operational method that validated it's arguments. +1 this is the right approach.Jimmy Hoffa– Jimmy Hoffa2013-08-29 14:40:29 +00:00Commented Aug 29, 2013 at 14:40
| Show 7 more comments
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
- create code fences with backticks ` or tildes ~ ```
like so
``` - add language identifier to highlight code ```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible) <https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. design-patterns), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you
default