6

When should I use multiple class libraries in .NET. I have a situation where I need to use the functionalities of Microsoft Office Object Model to check certain attributes of Microsoft Office files. Should I use different class libraries to process different file types.

eg:- 1 library for word files, 
     1 library for ppt, 
     so on.

Or should I stuff everything into a single class library.

What are the question that i should to self before going to build multiple class libraries.

jcolebrand
  • 15,889
  • 12
  • 75
  • 121
logeeks
  • 4,849
  • 15
  • 62
  • 93
  • unless you need to separate them, dont. – StingyJack Mar 17 '11 at 18:12
  • Really this question is "When should I separate my logic into multiple classes and when should I keep the logic in my classes related, when writing code in a .NET style?" And since these are all related "helper functions" working with objects then I say put them all in one class. – jcolebrand Mar 17 '11 at 18:14

4 Answers4

6

Think about your consumers: If somebody might want to use the library for word files without the extra overhead of having all the other libraries, then separate them. If not, don't.

That said, keep in mind that separate assemblies is not necessarily the same as separate projects. You may want to use separate projects for each of these, even if you end up combining them into one big assembly in the end (see Single assembly from multiple projects). I've found it to be easier to manage version control on smaller projects.

Community
  • 1
  • 1
StriplingWarrior
  • 151,543
  • 27
  • 246
  • 315
2

It depends a bit on how and where you plan to use this functionality.

If you're going to be using portions of the functionality from multiple applications, and each application will only need to handle one of the files (or at least not all of them), then it makes sense to separate out libraries by file types.

However, if all of your applications will typically handle every type of file, keeping them together will reduce the maintenance overhead of your solution.

Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
2

Keep It Simple. If you have no technial reason to seperate, don't do it.

The answer to this is mostly personal opinions. There are many times technical reasons or "best practices" patterns and dictate how you should separate code.

TheSean
  • 4,516
  • 7
  • 40
  • 50
1

1) what (possible) other programs will reuse the same classes, and will they be deployed at the same location?

2)I have a small group of classes that have little or no dependency on the rest of the system; would it make logical sense to group them together in a class library?

louisgab
  • 2,414
  • 1
  • 15
  • 9