Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


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

Posted on 2009-04-14
Medium Priority
Last Modified: 2012-05-06
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?
Question by:TSFLLC
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
LVL 39

Accepted Solution

abel earned 1600 total points
ID: 24138656
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).
LVL 25

Assisted Solution

by:Luis Pérez
Luis Pérez earned 400 total points
ID: 24138662
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.

Author Comment

ID: 24139927
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

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

LVL 39

Assisted Solution

abel earned 1600 total points
ID: 24140102
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.
LVL 39

Expert Comment

ID: 24140148
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.
LVL 39

Assisted Solution

abel earned 1600 total points
ID: 24140151
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.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question