Solved

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

Posted on 2009-04-14
6
181 Views
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?
0
Comment
Question by:TSFLLC
  • 4
6 Comments
 
LVL 39

Accepted Solution

by:
abel earned 400 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).
0
 
LVL 25

Assisted Solution

by:Luis Pérez
Luis Pérez earned 100 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.
0
 

Author Comment

by:TSFLLC
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
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 39

Assisted Solution

by:abel
abel earned 400 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.
0
 
LVL 39

Expert Comment

by:abel
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.
0
 
LVL 39

Assisted Solution

by:abel
abel earned 400 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.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now