Put this code in a Class?

  • Thread starter Thread starter EManning
  • Start date Start date
E

EManning

I'm very new to VB.Net and am struggling with the concept of classes and when
to use them. I have found some coding to email exceptions to myself that
might occur in this project I'm developing. I would like to make this coding
available to other projects that I will be developing in the future. Should
this coding go into a class? Actually I've done this already and it seems to
work pretty slick. I linked the class to my project and I assume I can link
it to other projects (but I haven't tried that yet).

Is a class the best place for this kind of code? If not, what is?

Thanks for any help or advice.
 
I'm very new to VB.Net and am struggling with the concept of classes and when
to use them. I have found some coding to email exceptions to myself that
might occur in this project I'm developing. I would like to make this coding
available to other projects that I will be developing in the future. Should
this coding go into a class? Actually I've done this already and it seems to
work pretty slick. I linked the class to my project and I assume I can link
it to other projects (but I haven't tried that yet).

Is a class the best place for this kind of code? If not, what is?

Thanks for any help or advice.

If you want to use it in multiple projects, then I would suggest making
it a public class in a class library project... Then you just have to
reference the dll, in any project you want to use it from, and it's
available to you.
 
This might be a dumb question but a "class library project" would be a
project that contains several classes, all of which could be accessed by
other projects. Correct?

Thanks for your help, Tom.
 
This might be a dumb question but a "class library project" would be a
project that contains several classes, all of which could be accessed by
other projects. Correct?

Thanks for your help, Tom.

Yep. You've got it.
 
EManning said:
I'm very new to VB.Net and am struggling with the concept of classes and
when
to use them. I have found some coding to email exceptions to myself that
might occur in this project I'm developing. I would like to make this
coding
available to other projects that I will be developing in the future.
Should
this coding go into a class? Actually I've done this already and it seems
to
work pretty slick. I linked the class to my project and I assume I can
link
it to other projects (but I haven't tried that yet).

Is a class the best place for this kind of code? If not, what is?

Thanks for any help or advice.
Classes are one of the three essential building blocks of a project. If you
think in terms of a user interface, a business logic (or worklow) layer and
a data access layer with the last two being classes.

Classes generally encapsulate an entity (eg customer) or contain business
rules.

The user interface is generally only used for display of data, which it gets
from various classes.

Lets say you are dealing with customers. A customer class would ordinarily
contain all of the properties of a customer (name, adress etc) and methods
for fetching the customer data, saving data, deleting data and possibly
listing customers (this is often referred to as CRUD)

If you were selling products you would have a class for product items and a
class for customer orders of these products etc.

Each of these classes would get or save their data by calling on a
specialised class called a data access layer (DAL)

That is, in essence, what classes are about. The subject would easily fill a
number of large books when going into all the possibilities.

Cheers
 
Thanks everyone for your replies. I have trouble understanding the
difference between classes and functions and where to use them. Maybe I'll
understand better after I've used classes for a while.

Thanks again.
 
Back
Top