Currently my architecture is a monolithic block that handles a really specific duty. Now it needs to be generalized.

Right now it handles a request and all processes (1 or many) associated to it. There's a class Request and a class Process and since it serves one specific duty this model was OK.

Right now I need to split both classes to achieve modularity. For instance, the Request class should be split. So I'll still have a Request class, which holds general request information, and many RequestDetailsForServiceOne, RequestDetailsForServiceTwo and so on, that hold detailed information relatively to a specific type of request. Equally for Process.

The question right now is: how to bind together Request class with RequestDetailsForServiceOne (at run time)?

I had thought about Dependency Injection, but RequestDetailsForServiceOne and RequestDetailsForServiceTwo doesn't share any common behaviour, (that classes only store some properties), this way will drive me to code an IRequestDetailsForService completely empty. That sounds as a code-smell to me.

Would be a better idea in this case use, (inside Request/Process class) a Dictionary of properties and completely avoid RequestDetailsForService* classes? I don't really like the loss of type-checking that this way get me back. What would be an ideal solution?

| improve this question | | | | |
  • why Dependency Injection? What you are describing looks like a classical inheritance pattern. RequestDetailsForServiceOne is-a Request and RequestDetailsForServiceTwo is-a Request.. – VP. Apr 9 '14 at 12:03
  • I wouldn't use inheritance. – BAD_SEED Apr 9 '14 at 12:24
  • 1
    @marianoc84: why not? as VP says, this sounds like a the kind of problem inheritance solves. – Andy Hunt Apr 9 '14 at 15:47
  • Because it will be a nightmare when the system will grow. – BAD_SEED Apr 10 '14 at 10:05
  • IMO there is no difference in maintaining code with dependency injection or inheritance. Why you think that DI is better? As you described, you should use inheritance. – VP. Apr 19 '14 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.