Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 228
  • Last Modified:

Use of a Class library....common practice in VB.NET ?

I have taught myself VB.NET over the 2+ years with an extreme amount of help from EE postings.   Wouldn't be where I am today were it not for EE.

I have 4-5 marketable apps that I am in the process of setting up a custom error trapping routine with and in my investigation regarding such, I found that one of the demos I downloaded has a class library included in it.

Is it a common practice to have a class library included in a solution that encompasses all of the classes you would incorporate in most, if not all, of your applications on release?

And are there any performance issues I should be concerned with in doing so?
0
TSFLLC
Asked:
TSFLLC
  • 4
4 Solutions
 
abelCommented:
Building a class library is a very good thing. It saves loads of development time and it is easy to do. There is no impact whatsoever (ok, a tiny bit perhaps in load times, but unless you are working on a life-saving hospital heart-security application, you shouldn't be concerned).

Depending on whether it is only for your own applications or also for others to use, you should think about the naming conventions you want to use and the documentation you want to write (use doc tag comments).

Whenever I start a new project, I usually start out with including my own, time-tested (doh) utility class that contains many of the (mostly static) methods that make programming easier for me. Whenever I start something in a new language, I usually find myself setting up a new class library in no-time, because I simply need it.

In terms of information hiding, flexibility, source control and stability there's actually nothing you can use against class libs. The opposite, however, not using them, is much harder to defend, because you will quickly find yourself copying code with all the disastrous effects that will show over time (a nice read is the Pragmatic Programmer and Joel On Software with good tips in these directions).
0
 
Luis PérezSoftware Architect in .NetCommented:
Of course, class libraries are a good point to start. They provide a very useful way of making a unique set of coding routines and share it with many projects. Imagine that you take over 2 or 3 weeks in programming your error trapping routine(s), and when you're satisfied with it, you implement that code in your 4-5 marketable apps (and do it one-by-one, copying/pasting code or entire classes from one project to another). But, what if once that all the work is done, you must do some changes to the classes of your error trapping routine? Your work then multiplies because you must do the changes in so many projects instead in only one.

Definitively class libraries are so good. They're the best way to make reusable code available for a large number of applications. Think that in .NET all is acomplished by Assemblies (that are no other thing than class libraries -or components).

Hope that helps.
0
 
TSFLLCAuthor Commented:
Abel & Roland,

Thank you very much.  I think my virgin eyes are being opened a little brighter.  Please indulge me because I think as you both are stating that this can be crucial/critical to problem resolution in one place, time-savings dah-dah-dah.  You guys may be saving me a monsterative (?sp) amount of grief.

Can I include a Resource file like icons that are used in almost every form I design?

Also I have designed a set of accounting forms which are inter-useable within (4) of my marketable applications.  I'm assuming those can be included just the same?

And lastly what would be improper to include in a class library...if anything?

Well, actually one more.  If I need to ask these on separate new postings I will be more than happy to and split or give the points accordingly.  I am using Visual Studio 2005 Professional.  Am I crazy in thinking that when I add something like a form say from another folder that it actually creates a copy of that form and now I have it in two places?  Is this why if I simply "include" a project it is not making a copy of that project or files and you are updating code in ONE place?

Let me know what I've got to do this these questions....start new or wait for your responses.
Wish I could give you both 1000+.

Thanks, Phil
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
abelCommented:
Be careful in how you plan this. Don't overuse reusability. Make several libraries, one for the most common ones, which you will include almost everywhere, including in the other libraries. Others for the less common ones, but that you can still reuse and put a tag on that sais "very generic, could be reused in projects I cannot yet think of". Finally (third layer) you make a library of classes / methods that can be used only by a few of your projects or clearly have a less generic appliance (like the forms you mention).

About resources: yes, of course you can. But do that in a library on its own, and make sure you only use it for resources (strings, icons, images, files). Don't make the mistake to put settings inside the resources libs. Resources should be meant to be very static (little action code) and most of it should be build automatically.

> And lastly what would be improper to include in a class library...if anything?

see above. Many things are not proper to include. Separate them by usability and reusability and don't overdo it. Remember also that you cannot create cyclic references in .NET languages, which means that a library that must be used by all projects and all other libraries cannot itself reference another (home-made) library.

Be prepared to have to move your functions around every now and then, because the place where to put a method is not always clear up-front.
0
 
abelCommented:
On using resources in a DLL, I've put some notes in this thread a short while ago about using ResXFileCodeGenerator for automatically creating string-resource classes: http:Q.24270306.html, which makes the process of creating a library for your strings (incl. parameterized strings) easier.
0
 
abelCommented:
try again:

On using resources in a DLL, I've put some notes in this thread a short while ago about using ResXFileCodeGenerator for automatically creating string-resource classes: http:Q.24270306.html , which makes the process of creating a library for your strings (incl. parameterized strings) easier.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now