Note that there are some explanatory texts on larger screens.

plurals
  1. POfacade design pattern
    primarykey
    data
    text
    <p>Lately I've been trying to follow the TDD methodology, and this results in lot of subclasses so that one can easily mock dependencies, etc.</p> <p>For example, I could have say a <code>RecurringProfile</code> which in turn has methods / operations which can be applied to it like <code>MarkAsCancel</code>, <code>RenewProfile</code>, <code>MarkAsExpired</code>, etc.. Due to TDD, these are implemented as 'small' classes, like <code>MarkAsCancelService</code>, etc.</p> <p>Does it make sense to create a 'facade' (singleton) for the various methods/operations which can be performed on say a <code>RecurringProfile</code>, for example having a class <code>RecurringProfileFacade</code>. This would then contain methods, which delegate code to the actual sub-classes, eg.:</p> <pre><code>public class RecurringProfileFacade { public void MarkAsCancelled(IRecurringProfile profile) { MarkAsCancelledService service = new MarkAsCancelledService(); service.MarkAsCancelled(profile); } public void RenewProfile(IRecurringProfile profile) { RenewProfileService service = new RenewProfileService(); service.Renew(profile); } ... } </code></pre> <p>Note that the above code is not actual code, and the actual code would use constructor-injected dependencies. The idea behind this is that the consumer of such code would not need to know the inner details about which classes/sub-classes they need to call, but just access the respective 'Facade'.</p> <p>First of all, is this the 'Facade' pattern, or is it some other form of design pattern?</p> <p>The other question which would follow if the above makes sense is - would you do unit-tests on such methods, considering that they do not have any particular business logic function?</p>
    singulars
    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.
 

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