Self validating model
What we want is something with a validation mechanism that’s set once in a generic way so we can reuse it.We also want to store our validation rules separately, somewhere where it makes more sense, and in a way that’s easily editable.It doesn’t work yet, but this is what we’d want our validator to deal with in the end.Instead of assigning values directly to a variable, we decide every property is an object with at least two sub-properties: its actual value, and an array of its validation rules.
And in fact, there’s much more than one problem to this code structure: If we want to build a clear, solid and scalable program, this is everything we want to avoid.
Breast cancer is becoming a leading cause of death among women in the world.
However, it is confirmed that early detection and accurate diagnosis of this disease can ensure a long survival of the patients.
Using services is a great way to keep a clean codebase by breaking down responsibilities.
A validator service will allow us to avoid having to explicitly validate data ourselves in our methods.



I start with what I want my final code to be and I backward build to make it work.