interfacecomponentsumlcomponent-diagram

How to figure out correct interfaces for a component in UML component diagrams?


I have a doubt about UML component diagrams interfaces. I have a search component in my system which is responsible for search some product from the database and return the search result to the user. I have drawn search component in 3 different ways as I understood. I want to know which way is the correct one and best in practice and why others are not correct.

enter image description here

In this case I thought search component provides a Search interface to other components like User and they use that Search interface to search. Also the user passes search parameters through that interface and get the result through that interface as well.

enter image description here

In this case I thought Search component provides Search interface and and User uses that interface to pass search params. And it fetch data from the database. Then User component uses Search result interface to get the search result.

enter image description here

In this scenario, I thought Search component need search params to search something. So, It requires Search params. Therefore, I added Search params required interface. After fetching data Search component provides that result. So, I've added provide interface named search result.

These are the ways I thought about this Search Component. I don't have a Idea which one is the correct one. Please explain which one is the correct one and why others are not correct.

Thanks!!!


Solution

  • Lollipops and sockets do not tell what goes in and out but who provides or needs the interface definitions. So, simply spoken, the first variant would be correct. The Search interface offers some search(...) operations which yield some result. And the data must be provided via the Data interface. The component's task would then be to implement a search on data according to these interfaces.

    It would help you if you would place the «interfaces» near the socket/lollipop and draw dependency/realization accordingly. For example like this:

    enter image description here