Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First I think it is bad to for <code>SellingContract</code> to provide all the condition checking methods. The class should only be concerned with holding the data and providing access to the data.</p> <p>As for your two approaches:</p> <ol> <li>I don't think the Visitor Pattern is useful here. For its proper application the visitor should be able to visit different types of objects; in your case this would be differnt types of <code>SellingContract</code> or maybe <code>Contract</code>. Also to be really useful there should be a need for different types of Visitors. But besides the <code>ConditionChecker</code> what would that be. So to sum it up: I don't think the Visitor Pattern is useful here.</li> <li>This approach seems sensible. I don't think it is a problem that the utility classes know about the <code>SellingContract</code> structure; they actually only need to know its public interface. But they can't reasonably check a condition on that object without knowing anything about it, so I don't see a problem here. Also your requirements imply a step-by-step procedure anyway so its not a big problem if your approach is a litte procedural. <strong>I recommend this approach.</strong></li> </ol> <p>For your conditions you could write one <code>ConditionChecker</code> per condition and then write a class that does a step-by-step application of those conditions. This will also make the code easier to debug and read since you can easily do things like step through the code in your favorite IDE and see the intermediate results.</p> <p>In the project I am currently working on we had a similar problem: Operate on student-data and check if they meet the all conditions for a degree and providing information about which conditions are met and not met to the user. We used the second approach and it works well. Also our software architect agrees that it is a good solution.</p> <p>Optionally you could implement a domain-specifc language for specifying the conditions and rules. This would allow you to have the business write the conditions themselves. But this takes cosiderably more effort to implement.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload