Solved

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

Posted on 2009-04-14
6
190 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

809 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