Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When is it the right time to use C# class library (.dll)?

I'm a programmer who has never really used .dll files. Of cause, when I need 3rd party software, such as a graphics library, a library to help me create graphs etc. I do add the references/ddl files to my program and use them in my code.

Also, it seems like you can use .dll for a lot of different things, so I'd like the topic to concentrate on C#.

Right now I am working on a sanitizing library(?) (I think that is the correct term), which will be full of relevant methods that can sanitize variables in all sorts of different ways.

What I want to know is:

would there be any advantage to:

1) Write the methods to class library -> compile/build it -> add the library as a reference to the program - which would need to sanitize some variables ?

Or would it be exactly the same if I where to:

2) Create a new SanitizeClass in the program -> add all the sanitize methods -> call the methods from the SanitizeClass in the different classes in the program that needs to sanitize variables

In general, I also want to know when it is an advantage to use compiled class libraries. I'm thinking of speed, security, all of it.

Could anyone enlightenment me? :)

like image 684
CasperT Avatar asked Apr 02 '09 14:04

CasperT


People also ask

Should vitamin C be applied at night or morning?

Experts typically recommend using vitamin C products in the morning and retinoids at night. This route often ends up working out best since retinol products can increase the skin's sensitivity to UV rays, which is why it's better to save them for p.m. use.

Can I use vitamin C at night?

Many people wonder when the best time is to use their Vitamin C products. While some associate Vitamin C with daytime, others believe nights and evenings are best to use their Vitamin C-infused products. The truth is, Vitamin C can work effectively in the days or evenings.

Should I take vitamins morning or night?

“Digestion slows down during sleep, so taking your nutrient supplement late at night would not be associated with an efficient absorption.” Neil Levin, a clinical nutritionist at NOW Foods, agrees that morning is best for multivitamins and any B vitamins.

Should I take Vit C before bed?

What many do not know is that vitamin C plays a significant role in boosting sleep health. Studies have shown that individuals with greater concentrations of vitamin C have better sleep than those with reduced concentrations.


2 Answers

The key question is: does it make sense for more than one application to use the type? If so, it should be in a class library. If not, you may still want to put it in a class library just for the sake of separation (e.g. have one assembly per tier in an n-tier solution), but you could just put it in your application.

If your sanitization is general-purpose, then putting it in a class library would definitely be the right move.

I know of people who write almost no code in executable applications, and put almost everything in class libraries - so the application basically just wraps the class libraries. I don't tend to go quite that far myself...

like image 111
Jon Skeet Avatar answered Sep 24 '22 08:09

Jon Skeet


The first thought that comes to mind is re usability. Will this sanitize library be used ever outside of the application you're currently working on? If you are, then you don't want to have to reference an exe in the future, for that you want to build a DLL file (possibly even strong name it and GAC it) and then just reference that in the future.

like image 21
BFree Avatar answered Sep 26 '22 08:09

BFree