200 karma · joined Mar 12, 2012 (14y ago) · 115 submissions
comment 10y ago · link · parent
Also, a close family friend was given 6 months to 3 years to live when her cancer spread through her body. It's been 10 years. She is getting sicker and sicker and on chemo the whole time, but she is still managing to attend the odd family function when she is feeling up to it.
This shit isn't a game, these are peoples lives and we need to make sure they can live it even if it means a few less unicorn start ups.
comment 10y ago · link · parent
The domain's job is to represent and encapsulate valid transformations in the domain. If it's not valid within the domain then it doesn't belong in it. If you get a well-formed XML file that has -7 as a social security number, that is not something that your domain has to deal with. It should be caught by the corruption layer. It's not a valid value for your domain. Where I work we regularily build an import domain that allows users to see all the invalid data and manually correct it before allowing it into the rest of the system. Once I have an instance of a Person object I should be able to trust that it is sane.
> The third, from the experience I have, is a big flashy "no no".
It depends; I'd say it's on a case-by-case. Doing a read can be much more acceptable than a write. It's all about trade-offs at that point, but the benefit of knowing "if I have an instance I know that it is sane" means you don't need to litter your code with guards and that pays dividends in maintenance and bugs and agility and testability and, yes, even performance. A big factor is the cost of load. I usually work on low-load (~14 concurrent users) high-importance systems (eg global pricing management) where correctness is at a premium and we usually have system resources to spare. YMMV. As I said: it depends.
comment 10y ago · link · parent
These are two different concepts I feel you are mixing up. An object may be valid, but that doesn't mean it's valid for all operations. For example there is basic validation that a file object is valid if it exists, but if you only have read access to it .append("foo") will fail on it. But it's still a valid file. Your constructor should be checking for the first kind of validity, and your methods for the second.
> What if you receive, from a webservice or something, a valid object format-wise but invalid from the business rule perspective?
That is what you need an [anti-corruption layer](http://www.markhneedham.com/blog/2009/07/07/domain-driven-de...) for. The object makes sense within that other services domain but not within yours. That domain may be closely related to yours, but it isn't you. You need a separate object for that (a simple struct ought to suffice usually). Then you act as a gatekeeper only allowing conforming objects into your system. Basically filter out the shit, and make sure if it makes it past your gate it is clean. Otherwise you might want to use the [state pattern](https://en.wikipedia.org/wiki/State_pattern) to allow for different validation rules of the same object (eg legacy accounts might not have an email address but all new ones must).
> What if there's some info in the database that would allow or not you to construct the object the way you need? You would go to the database and check the info in your constructor?
This is touchy. Sometimes, if it's important enough then yes. Sometimes you can code around it (eg having case numbers auto-generated at time of persistence). Other times you bite the bullet. Other times you rearchitect the data (storing it in memory to do the check quickly). Or as a last resort, except it as a compromise and start coding up some roll-back functionality. Aim for the ideal, and know when to step backwards towards the practical: that is the art of software development.
comment 10y ago · link · parent
Uhm for Navicat you need to buy a different license for each database and operating system you use. Where I work we use both SQL Server and MySQL and I use three different computers with different operating systems. JetBrains terms are much friendlier.
comment 11y ago · link · parent
I find this _deliciously_ ironic since that is the position most students have towards mathematics in general (replace "calculations" with "anything relevant in their lives").
comment 11y ago · link · parent
comment 11y ago · link · parent
comment 12y ago · link · parent
comment 12y ago · link · parent
I'm of the opinion that this is a reason to discourage the growth of small businesses. They are too small to absorb shocks like pregnancy or family emergency that contribute to the well-being of a society.
comment 12y ago · link · parent
I believe this has been solved in intuitionistic logic (http://en.wikipedia.org/wiki/Intuitionistic_logic). If you don't except the law of the excluded middle and require constructive proofs you avoid many of these shenanigans.
comment 13y ago · link · parent