467,077 Members | 971 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,077 developers. It's quick & easy.

How to develop class library?

Hi,

What would be the best way to develop a class library?
I am planing to develop a couple of classes, needed in our company
enviroment.
These classe will be later used in several projects.

Are there any "how to" links available on how to do that with visual studio?
Would it be best to have a "Windows" or "Console" application to develop and
test each class and then put it into a library later on or is it possible to
have a Library project that can be included into a test application and
thereby still be debuggable?

Thanks for hint, links and help.

Regards
Rainer Queck
Feb 16 '07 #1
  • viewed: 2323
Share:
16 Replies
Just select the Class Library project type in VS when you start your new
solution.

To test it you'll want to add a Windows.Forms or Console project to your
solution that you can build as a client for your class library. Make it the
startup project for your solution. Whether you use a Windows.Forms project
or a Console project makes absolutely no difference, as long as it exercises
all the methods of all the classes in your library, in accordance with your
test plan. It's only for test purposes. So it's up to you: whatever you
feel happiest with.

You do have a test plan, don't you? :0)

Make sure all your classes in your library are in the same namespace: and
pick your namespace wisely. This is probably more important than having all
the classes in the same assembly. I'd make sure all the assemblies that
make up the library (namespace) were signed, so that they can be deployed to
the GAC. This will help you with versioning.

Of course you could always do things the other way around and start your
solution with the test executable and then include another project for your
library (right click on the solution -Add -new project, and then select
"Class library"). As the Perl guys say, "TMTOWTDI". The end result will be
exactly the same.

HTH
Peter
"Rainer Queck" <Ra****@noemail.noemailwrote in message
news:eA**************@TK2MSFTNGP05.phx.gbl...
Hi,

What would be the best way to develop a class library?
I am planing to develop a couple of classes, needed in our company
enviroment.
These classe will be later used in several projects.

Are there any "how to" links available on how to do that with visual
studio?
Would it be best to have a "Windows" or "Console" application to develop
and test each class and then put it into a library later on or is it
possible to have a Library project that can be included into a test
application and thereby still be debuggable?

Thanks for hint, links and help.

Regards
Rainer Queck

Feb 16 '07 #2
Hi Peter,

thanks for you help and tips.

Rainer

"Peter Bradley" <pb******@uwic.ac.ukschrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP05.phx.gbl...
Just select the Class Library project type in VS when you start your new
solution.

To test it you'll want to add a Windows.Forms or Console project to your
solution that you can build as a client for your class library. Make it
the startup project for your solution. Whether you use a Windows.Forms
project or a Console project makes absolutely no difference, as long as it
exercises all the methods of all the classes in your library, in
accordance with your test plan. It's only for test purposes. So it's up
to you: whatever you feel happiest with.

You do have a test plan, don't you? :0)

Make sure all your classes in your library are in the same namespace: and
pick your namespace wisely. This is probably more important than having
all the classes in the same assembly. I'd make sure all the assemblies
that make up the library (namespace) were signed, so that they can be
deployed to the GAC. This will help you with versioning.

Of course you could always do things the other way around and start your
solution with the test executable and then include another project for
your library (right click on the solution -Add -new project, and then
select "Class library"). As the Perl guys say, "TMTOWTDI". The end
result will be exactly the same.

HTH
Peter
"Rainer Queck" <Ra****@noemail.noemailwrote in message
news:eA**************@TK2MSFTNGP05.phx.gbl...
>Hi,

What would be the best way to develop a class library?
I am planing to develop a couple of classes, needed in our company
enviroment.
These classe will be later used in several projects.

Are there any "how to" links available on how to do that with visual
studio?
Would it be best to have a "Windows" or "Console" application to develop
and test each class and then put it into a library later on or is it
possible to have a Library project that can be included into a test
application and thereby still be debuggable?

Thanks for hint, links and help.

Regards
Rainer Queck


Feb 16 '07 #3
classes are bloatware, they add complexity, verbosity and slow code
execution

I've got a dozen books that state this as fact


On Feb 15, 11:45 pm, "Rainer Queck" <Rai...@noemail.noemailwrote:
Hi,

What would be the best way to develop a class library?
I am planing to develop a couple of classes, needed in our company
enviroment.
These classe will be later used in several projects.

Are there any "how to" links available on how to do that with visual studio?
Would it be best to have a "Windows" or "Console" application to develop and
test each class and then put it into a library later on or is it possible to
have a Library project that can be included into a test application and
thereby still be debuggable?

Thanks for hint, links and help.

Regards
Rainer Queck

Feb 16 '07 #4
On 16 Feb, 08:33, pfc_s...@hotmail.com wrote:
classes are bloatware, they add complexity, verbosity and slow code
execution

I've got a dozen books that state this as fact
It all depends on how they are used.

The purpose of a class library is to aid code reuse.
If code is reused wisely it will reduce bloat over multiple projects.
Obviously, if you include a large library for a small amount of code
this will increase the size (bloat) of a single binary.

Complexity and verbosity are issues resulting from design. In that
almost(?) everything in C# starts from a class library. (How much can
you do with no using statements?) Conceptually, the use of customer
libraries shouldn't add to much confusion.

Code will be slightly slower is using library code, but if it is
noticeable, it will be down to what the code is doing and how it is
being run, rather than it being in a separate library.

The most important reason to use libraries is for code reuse. This
reduces testing and development. It also saves time in support and
maintenance, making changes and bug fixes quicker/easier/cheaper.
Professional software development is a business and if you can do
something quicker, it will also be cheaper. This is a good thing in
business.

Feb 16 '07 #5
<pf******@hotmail.coma écrit dans le message de news:
11*********************@m58g2000cwm.googlegroups.c om...

| classes are bloatware, they add complexity, verbosity and slow code
| execution

So, I take it you don't use the .NET framework, where even the basic types
like int and string are classes ? After all, you wouldn't want to use
classes if they are slow and bloated :-)

| I've got a dozen books that state this as fact

Hmmm, they should come in useful for levelling up your desk :-)

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Feb 16 '07 #6
<pf******@hotmail.coma écrit dans le message de news:
11*********************@m58g2000cwm.googlegroups.c om...

Why did I waste time replying ? What a troll !!!

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Feb 16 '07 #7
Don't waste your time; he's trolling.

The correct response is [Delete], perhaps stopping to add to your
blocked list...

Marc
Feb 16 '07 #8
Very interesting. What are you proposing to use instead of classes?

Peter

<pf******@hotmail.comwrote in message
news:11*********************@m58g2000cwm.googlegro ups.com...
classes are bloatware, they add complexity, verbosity and slow code
execution

I've got a dozen books that state this as fact


On Feb 15, 11:45 pm, "Rainer Queck" <Rai...@noemail.noemailwrote:
>Hi,

What would be the best way to develop a class library?
I am planing to develop a couple of classes, needed in our company
enviroment.
These classe will be later used in several projects.

Are there any "how to" links available on how to do that with visual
studio?
Would it be best to have a "Windows" or "Console" application to develop
and
test each class and then put it into a library later on or is it possible
to
have a Library project that can be included into a test application and
thereby still be debuggable?

Thanks for hint, links and help.

Regards
Rainer Queck


Feb 16 '07 #9
"Peter Bradley" <pb******@uwic.ac.uka écrit dans le message de news:
OR**************@TK2MSFTNGP02.phx.gbl...

| Very interesting. What are you proposing to use instead of classes?

Easy! VBA spaghetti and globals :-)

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Feb 16 '07 #10
Of course! How could I not have seen that!

You should, though, have added that no comments should be included in the
source files - to cut down on bloat. We definitely don't want bloat, do we.

;)
Peter

"Joanna Carter [TeamB]" <jo****@not.for.spamwrote in message
news:ee*************@TK2MSFTNGP04.phx.gbl...
"Peter Bradley" <pb******@uwic.ac.uka écrit dans le message de news:
OR**************@TK2MSFTNGP02.phx.gbl...

| Very interesting. What are you proposing to use instead of classes?

Easy! VBA spaghetti and globals :-)

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer


Feb 16 '07 #11
"Peter Bradley" <pb******@uwic.ac.uka écrit dans le message de news:
eV**************@TK2MSFTNGP06.phx.gbl...

| Of course! How could I not have seen that!

<g>

| You should, though, have added that no comments should be included in the
| source files - to cut down on bloat. We definitely don't want bloat, do
we.

Oh, and remove all excess whitespace and indentations. I have heard tell
that a program can be written as a single (long) line of code <gd&r>

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Feb 16 '07 #12
LOL! You've invented Perl.
Peter

"Joanna Carter [TeamB]" <jo****@not.for.spamwrote in message
news:uL**************@TK2MSFTNGP06.phx.gbl...
"Peter Bradley" <pb******@uwic.ac.uka écrit dans le message de news:
eV**************@TK2MSFTNGP06.phx.gbl...

| Of course! How could I not have seen that!

<g>

| You should, though, have added that no comments should be included in
the
| source files - to cut down on bloat. We definitely don't want bloat, do
we.

Oh, and remove all excess whitespace and indentations. I have heard tell
that a program can be written as a single (long) line of code <gd&r>

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer


Feb 16 '07 #13
Peter Bradley <pb******@uwic.ac.ukwrote:
Just select the Class Library project type in VS when you start your new
solution.

To test it you'll want to add a Windows.Forms or Console project to your
solution that you can build as a client for your class library.
No no no - to test it, you'll want another class library which contains
all the NUnit test cases :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 16 '07 #14
PS

<pf******@hotmail.comwrote in message
news:11*********************@m58g2000cwm.googlegro ups.com...
classes are bloatware, they add complexity, verbosity and slow code
execution

I've got a dozen books that state this as fact
Can we have the books names for reference please?
>

On Feb 15, 11:45 pm, "Rainer Queck" <Rai...@noemail.noemailwrote:
>Hi,

What would be the best way to develop a class library?
I am planing to develop a couple of classes, needed in our company
enviroment.
These classe will be later used in several projects.

Are there any "how to" links available on how to do that with visual
studio?
Would it be best to have a "Windows" or "Console" application to develop
and
test each class and then put it into a library later on or is it possible
to
have a Library project that can be included into a test application and
thereby still be debuggable?

Thanks for hint, links and help.

Regards
Rainer Queck


Feb 16 '07 #15
Create a standard Class Library project type. All your class code should go
in here. Name it something like "Company.Common.MortgageCalculations".

Into your solution add another class library called
"Company.Common.MortgageCalculations.Test". Go download the newest version
of NUnit, look through the docs for 15 minutes or so, and you'll be good to
go.

Once you've written code, and written tests for the code, set your startup
project to the Test project, change the startup exe to be the NUnit-Gui.exe,
and go from there. This gives you repeatable Unit Tests, Easy Debugging, and
a host of other benefits.

This is, I have to say, the best way to do a small project like what you
describe.

--
Chris Mullins, MCSD.NET, MCPD:Enterprise, Microsoft C# MVP
http://www.coversant.com/blogs/cmullins

"Rainer Queck" <Ra****@noemail.noemailwrote in message
news:eA**************@TK2MSFTNGP05.phx.gbl...
Hi,

What would be the best way to develop a class library?
I am planing to develop a couple of classes, needed in our company
enviroment.
These classe will be later used in several projects.

Are there any "how to" links available on how to do that with visual
studio?
Would it be best to have a "Windows" or "Console" application to develop
and test each class and then put it into a library later on or is it
possible to have a Library project that can be included into a test
application and thereby still be debuggable?

Thanks for hint, links and help.

Regards
Rainer Queck

Feb 16 '07 #16
"Marc Gravell" <ma**********@gmail.comwrote in message
news:el*************@TK2MSFTNGP06.phx.gbl...
Don't waste your time; he's trolling.

The correct response is [Delete], perhaps stopping to add to your blocked
list...
Unfortunately, that doesn't help when other people quote him. :)

///ark
Feb 16 '07 #17

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

66 posts views Thread by Prashant | last post: by
2 posts views Thread by [b2:ss] | last post: by
2 posts views Thread by aparnasinha26@yahoo.com | last post: by
reply views Thread by TT (Tom Tempelaere) | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.