Blog Archives

Making sure all IWorker implementers call CanHandle from Handle without a mocking framework

lego-568039_1280

You have an interface that allows you to treat all worker classes – classes that handle a specific type of work – as just one type: IWorker;

You want your worker classes to be able to do their work without having to check their backs every step of the way.

Read more ›




Designing your way out of the CanHandle-Handle conundrum

CanHandle – Handle pattern conundrum

When you have multiple classes implementing an IWorker interface with a CanHandle and Handle method, such as

you find yourself in a conundrum: should you call CanHandle again from Handle?

If you don’t, someone could pass in work that a worker isn’t designed to handle and that can lead to a multitude of different exceptions or subtle,

Read more ›




Act like a pessimist and call CanHandle from Handle (again)?

You have multiple Worker classes that can each handle a one or more types of command. Your IWorker interface offers two methods: CanHandle and Handle.

Perfect.

Anyone with work to be done can now find a worker that says “yay, I can handle this” and then pass off the work to that worker.

Read more ›




Show Buttons
Hide Buttons