0

I guess doing this functionally would not harm, but I wanted to understand if it causes ambiguity in understanding the code.

I would like to explain using a simple example where I have a ProcessFactory which creates Process instances internally but returns a ProcessManager instead of Process instance.

And, ProcessManager is a class which adapts some of the Process functionality and adds more functions related to management of process.

The reason for doing this is that the client is not required to deal with the complex functionality which a Process provides but only needs to manage some aspects of it thru ProcessManager, while manager also adds some extra functionality on its own.

cpz
  • 1,002
  • 2
  • 12
  • 27
  • 1
    I don't see how returning a ProcessManager rather than a Process would be any harder to understand. As a user of your API, I'll read the javadoc of your factory, see that it returns a ProcessManager, look at its javadoc, and use it. I would do the exact same thing if it returned a Process. That said, if your ProcessFactory returns ProcessManager instances, I would name it ProcessManagerFactory. – JB Nizet Jul 10 '14 at 06:08
  • So It should be okay to do so. About calling the factory class as ProcessManagerFactory, I want to mention that we want the API user to understand that a `Process` is being created by using the Factory method, which has a associated manager which will be returned to API user. So now I can explain in api doc that ProcessFactory will create Processes which you can manage by ProcessManager. – cpz Jul 10 '14 at 07:06

0 Answers0