Tag Info

New answers tagged

0

Why don't you create a service holding a collection of all categories? Then you can do validation very easy. An example: class BlogCategoryService { private List<Category> _categories = new List<Category>(); public void AddCategory(string categoryName) { if (_categories.Any(c => c.Name == categoryName)) throw ...


0

Dealing with some "manage project from start to end"-type intranet applications, I believe it can be very valuable to separately-capture what different remote systems or users told my system they thought was true, versus the mix of data my system has currently decided to believe and honor. This leads to systems where you store and act upon things like ...


0

Whether it is with paper or highly validated electronic data gathering, discrepancies can come up between how things are thought to be done by some (management) and how it is really done in the field. You may develop a different set of domain rules depending on how the requirements are gathered. Model based on the form. A supervisor hands you a blank copy ...


1

Now I'd like to address this question from a different angle: Shouldn't objects represent their real world counterparts? Yes. In most businesses there already exists a working system that should be translated to the software. Or to put it another way, decades of business practice has already probably figured out a good way to manage most business ...


1

business logic should be in the model, otherwise you just have property bags What is business logic? Business logic is, that your object knows it's state and could answer questions like order.IsDistributed or order.IsQualityAssuranceDone or the like. It is no business logic, if you ask the question is this order already in the database. That is a ...


0

Q:How do we create objects? A: Using Domain Factories! Since the creation of a category contains complex logic (we need to validate uniqueness), we will utilize a domain factory to create the object for us. Inside that factory I'll use a UniqueCategoryNameValidator service that calls into the data-store (a DB in ur case) and check if the category is ...


2

I would create a domain service responsible for validating the uniqueness of the category. In my solution domain defines the interface of the service, infrastructural part implements it using a database. Please also take a look at http://stackoverflow.com/questions/516615/validation-in-a-domain-driven-design.


1

If your object is "Paper", then to make it fully reusable you are right--it should be able to take any content without bursting into flame (Perhaps with some basic checks that always apply to paper, like the background color can't be black? I mean like null checks that keep the paper object valid.) However it is then refined into a "Form" (Let's call it a ...


1

There is some validation that can only be made with reference to the domain, though whether this is an argument that the validation belongs in the domain is moot. The classification of errors, and hence validation, I am familiar with breaks down into: Input errors, which can be detected by examination of the input - so a date of 2014-02-30 is self ...


2

Is the paper going to crumple itself up or catch on fire if you write something invalid on it? No, but some time in the future, paper may be replaced with some form of electronic paper or pads, and they will complain if you make an error. The point is, there are things that are possible in the virtual world that are not possible in the real world of ...


5

The software doesn't care about representing anything. Everything is ultimately memory being modified and moved around. Representing a piece of paper in software as an object in the OO sense is because it is useful for us humans to understand both what the software will actually do, against what the software is supposed to be doing, and to be able to make ...


0

The domain also has a concept of Domain Services. That's still in the domain but could represent the real-world process that you describe. A mistake that we can make is forgetting that the domain is more than just the Entity objects-- some Services do belong in the domain. One way to get this wrong though is to think that it's wrong to pass a service object ...


1

You have some very good comprehensive answers. I'll just address your specific use case. If you have two or more attributes that depend on each other then don't have individual setters and validators. As your question shows, you can get into all edge cases where one attribute is changed but not the other. Instead, make a value object called ...


2

OOP When in doubt I follow 2 simple rules which help me make the right decision Encapsulation and Information hiding Low coupling and High cohesion So this basically means Data + Behavior which you already know. But it also means that it is the class's responsibility to maintain the state of its instances, that is when you instantiate an object you ...


5

Programming isn't an exact science (at least not yet), so you have a lot of leeway which you should use to apply common sense and do the sensible thing. Every object is responsible for itself There is a concept more fundamental than object-oriented programming, and this is encapsulation. Encapsulation could be paraphrased as “every conceptual unit is ...


0

I am having a bit of an issue with some of these things being called "pattern", but clearly, monads, guards and validators are different beasts one may consider patterns. Particularly interesting about monads is of course, that their available operations mean you can apply other functions transparently within the monad (read: map). Therefore, monads are ...


0

There are no standards for naming conventions by any major working group. The closest you might get would be standards within an organisation or for a particular product so you are effectively free to choose the names that you feel are best. Maybe pick the best of some already great implementations (e.g. ActiveRecord Validations / Flask WTF etc.). You ...



Top 50 recent answers are included