How Can I Create a Wrapper for a Dependency Class in C#?

0
7
Asked By GameDevNinja42 On

I'm building a game engine in C# and want to hide the Silk.NET libraries from the end user to keep things tidy. Is there a way for users to import just my library, which would internally link to the dependencies? I'd prefer it if they could use something like this:
```csharp
using GameEngine.Core;
using GameEngine.Input;
using GameEngine.Graphics;
using GameEngine.Maths;
using GameEngine.External.ImGui;
```
Instead of directly referencing the Silk.NET components. I've considered creating a wrapper or rewriting dependency classes myself. What are the best practices for achieving this?

1 Answer

Answered By CodeCrafter88 On

It's usually not a great idea to do this unless your library significantly enhances the existing ones. If users can easily access the original libraries, it might just make your work feel redundant. Focus instead on designing your engine so that users won’t need to directly touch the Silk classes. Check out design patterns that could help with this.

DevPundit2023 -

A stable API from your end would mean if Silk changes, you can adapt it for users without them having to change their code.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.