design patterns - Is using one-to-one interfaces with domain entities a good or bad practice? Why? -
One thing I work on some DDD Enterprise app, which is the use of the interses that are similar to domain entities, Actually, a domain object is always used through its one-to-one interface, with one-to-one mapping of properties and actions, and all domain units have one-to-one interface in this style. For example:
Domain Item Account:
Public category account: IAccount {public string name {get; Set;} // More fields that are in the IAccount public decimal balance {get; Set;}} and this is the mailing interface
public interface IAccount {string name {get} set;} // ... account balance left All fields in {Get; Set;}} But recently I am quickly convinced that this is actually an anti-pattern.
I took part in this open source community by some architects, and they say that this design is based on mistakes or flaws, somewhere above the range of designs.
So I tell my colleagues that they should stop creating the interface for domain objects. Because there is no purpose for them, and whenever you update domain entities you need to update the interface.
The first claim was that these interfaces provide 'decoding', but I oppose this because the interface has a one-to-one relationship with the Domain Entity, which in fact provides any decoupling Do not, a change interface means the domain unit changes and vice versa.
The next claim is that for the purpose of testing we need the interface. My counter is that rhino-mock provides for concrete sections for fun and rascal. But they claim that rhino-socks are troubled with concrete classes. I do not know if I buy it, even if the gango-socks have trouble in concrete sections, it does not mean that we should use the interface for domain organizations.
So I'm curious:
Why not?
Why is this a good or bad practice?
Why would there be one-to-one interface for your domain organizations? >
Thanks for reading!
Edit : I should keep in mind that I use the interface all the time, and I believe that if it is called, then I use an interface Will drop a hat but I specifically refer to domain organizations with one-to-one interface.
This is a bad practice as described, but ...
There is no specific reason why your interface should be different from your domain units; Sometimes this is actually the correct mapping but it is doubtful that this is always the case. The topic of concern is whether or not the interfaces are actually designed or not, or they were thrown into place due to lack of time / laziness.
To use your example, the IAccount Interface describes that the exits and setters on the set object; It seems a bit awkward and impossible that everything that uses an account will need to set the balance in the account, and it will specify the specified permission at that level of that interface. Is there no room in your system, where you only want to check, but do not set up the account balance?
Comments
Post a Comment