# Decoupling c++ modules (plugins) but both depend on an interface

**URL:** <https://forums.unrealengine.com/t/decoupling-c-modules-plugins-but-both-depend-on-an-interface/739600>\
**Category:** C++\
**Tags:** dependencies, Optimization, unreal-engine, CPP, question\
**Created:** [December 31, 2022, 10:22pm UTC](https://forums.unrealengine.com/t/decoupling-c-modules-plugins-but-both-depend-on-an-interface/739600 "2022-12-31T22:22:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [December 31, 2022, 10:22pm UTC](https://forums.unrealengine.com/t/decoupling-c-modules-plugins-but-both-depend-on-an-interface/739600/1 "2022-12-31T22:22:34Z")

</div>

I am currently optimizing a few plugins and reducing their dependencies. I have the following situation:

A UI Plugin: Interacts with anything deriving from Interface X.  
A Subsystem plugin: Which happens to implement Interface X.

The only thing that binds these two modules together is a shared interface, so I’d rather not merge them into a single module. What is the best way to decouple these modules entirely?

My goal is to make these plugins fully “standalone” from eachother and let a user connect systems from various plugins through matching interfaces.

---

<div class="post-metadata">

**Author:** ![jwatte](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jwatte/32/744941_2.png) [@jwatte](https://forums.unrealengine.com/u/jwatte)\
**Post date:** [December 31, 2022, 10:43pm UTC](https://forums.unrealengine.com/t/decoupling-c-modules-plugins-but-both-depend-on-an-interface/739600/2 "2022-12-31T22:43:39Z")

</div>

Typically, you’d make the UI plugin depend on the Subsystem plugin.  
That way, you can ship Subsystem only, or Subsystem+UI.  
If you necessarily need to be able to ship UI only, then you need a third module, which defines the shared interface.  
Then you can ship Subsystem+Interface, or UI+Interface, or Subsystem+UI+Interface.

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [December 31, 2022, 11:02pm UTC](https://forums.unrealengine.com/t/decoupling-c-modules-plugins-but-both-depend-on-an-interface/739600/3 "2022-12-31T23:02:00Z")

</div>

I thought of that, making a third “Core” module to put things in that are reused, but the bigger the project gets the more I want it to break apart into standalone modules, so that you don’t get a huge “core” module dependency for every small plugin. I think you are right, that there is no other way.
