So what about the fact that a concretion has polluted an abstraction?
Task now has CanClose which only makes sense for a derived type.
What other options are there for representing that behaviour? Could do nothing, but that might violate the expectation that a task has status closed after closing.
Ben
--
The only way to go fast is to go well.
---
You received this message because you are subscribed to the Google Groups "Clean Code Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clean-code-discu...@googlegroups.com.
To post to this group, send email to clean-code...@googlegroups.com.
Visit this group at http://groups.google.com/group/clean-code-discussion.
Using a callback like can_close? would be much better here.
You received this message because you are subscribed to a topic in the Google Groups "Clean Code Discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clean-code-discussion/_GC5TwQUY84/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clean-code-discu...@googlegroups.com.
Suggest you have a collection of tasks, some of them are ProjectTasks, some are others.When you tell the collection to saveAll() you may receive the exception at a point where you deal with the collection and not a single task.So, which tasks in the collection are now saved and which aren't?
Next step will be to catch the exception within the loop in saveAll() […]
[…] while writing this code, this scaring question will come up, "where else will I have to do the same?"
public class Task {
public Status Status { get; private set; }
protected virtual bool CanClose() {
return true;
}
public void Close() {
if (CanClose() == false)
throw new Exception(reason);
Status = Status.Closed;
}
}