yau
yau

Reputation: 555

Given an abstract interface. Only clue for the need to provide an own implementation lies in NOT finding a factory function?

Admittedly a quite theoretical question.

And I would like to ask it more from the perspective of a library designer, than a library user. Although the goal is to provide the easiest possible design for the user.

Is there any gideline / best practice of how to communicate that a given interface is supposed to be implemented by the user all the time? Or that somewhere there are factory functions provided, creating reasonable objects implementing that interface?

Of course in almost all cases this should be clear from the context. Another library function expecting such an interface as parameter could be self-explanatory of where to get that from. Because it will just be a link in some chain. But I hope some of you can imagine a rather evolved system or library that is not that easily understood anymore.

How can you prevent the understanding of interfaces from getting more and more difficult, regarding the basic question of whether there are some factory functions somewhere or whether the user always needs to provide its own implementation?

Does the answer lie in comments, documentation or code?

I would just guess that factory functions should always be declared in the very vicinity of the interface. And if not, there is none. But I don't know if this is too soft a guideline or perhaps cannot be realized all the time anyhow.

Upvotes: 1

Views: 24

Answers (0)

Related Questions