Blaatz0r
Blaatz0r

Reputation: 1205

In C# what is best practice when setting up a project with dependencies (e.g. class library or separate files)

Lets say I have two projects.

Now I could create a C# class library (.dll) and reference it from my main project. And all the functionality is available.

But what if my main project only needs 25 classes from the total 100 available. For the current situation that is an overhead and in my opinion I would be better of with direct file referencing from the other projects.

What would be the better of those two options (.dll or referencing the source code files in the library) and why?

Upvotes: 4

Views: 1046

Answers (2)

wigs
wigs

Reputation: 239

The class library is fine and I don't believe only utilizing 25/100 of the classes is really any overhead at all. If you are truly using only 25 of all the classes in the library, then you will need to determine if those 25 class are all related and therefore better suited to be encased in their own project/dll. You can still have a single solution for your class libraries, but have different projects based on function of the classes in each.

Upvotes: 3

RFerwerda
RFerwerda

Reputation: 1277

I would say create a library (dll) and reference that. In that way the library can be used by multiple projects and you will have a single code base maintaining the library.

There is always that specific situation where you might end up in referencing the whole library and only using one class out of it.

Upvotes: 4

Related Questions