Building a Utility Library Without Going Overboard

I realized a while ago that I was breaking the "DRY" (Don't repeat yourself) rule pretty severely when looking at my various projects as a whole. I generally focus on not repeating code within an application but I have not been careful enough with this rule when starting new projects. Many times when I need a particular function that I have written before I will just go hunt it down and copy the code into my new project. It has recently become a problem because I now have the same function littered throughout my different programs with various modifications made to each!

It's time for me to build a utility library that will become the main source for commonly used functions in my applications. The main need that I saw for this library was the simple but tedious task of creating an email message and sending it along via a web contact form. Just about every .NET web site I've ever built has needed this functionality and each time I created a new MailMessage and Email class to handle the job. This was the first thing I added to my new Utility Library.

The purpose of this post is to try and get some feedback on which functions you would include in such a library and which you would leave out. The last thing I want to do is create some bloated set of code filled with methods that are rarely used. If anyone is interested in seeing how I am going about creating this library (or would like the actual library) just let me know in the comments and I'll do my best to help out.

Here is the initial structure and the classes I'm starting with:

Utility Library Structure

Each class contains a few functions that I find myself using frequently. Here is the class diagram for the few classes I have so far:

Utility Class Diagram

Again, if anyone wants the actual code or libraries let me know.

Help!

If you were building a utility library, what would you include or exclude? Anyone? Bueller...?

EDIT

I've added the source code for the project to the post for anyone interested. Since the post I've added a couple more functions to the library.

SevenLabs.Utilities.zip (35.55 kb)

kick it on DotNetKicks.com


Related posts

Comments

May 16. 2008 03:14 PM

alewis

Looks good...Would love to see the code behind the idea....

alewis

May 16. 2008 03:39 PM

Matt

No problem, i've added the source code to the post.

Matt

May 21. 2008 07:43 PM

Bill

I think a good edition would adding a download helper to transmit files in chunks etc. Smile

Here is a good example: www.gridviewguy.com/ArticleDetails.aspx

Bill

May 22. 2008 09:35 AM

Zack Jones

How about functions such as creating and returning a connection to the database and Command Objects. I use those all the time and usually copy the "util" class from project to project.

Zack Jones

May 22. 2008 11:16 AM

Matt

@Bill,
You're right, that would be a good and useful addition.

@Zack,
I thought about that as well and you're probably right. I was concerned with adding that type of functionality because I though I would have to be database engine specific, but maybe that isn't such a bad thing. It couldn't hurt to have a SQLServer helper and a SQLite Heleper etc.

Thanks for the input guys!

Matt

May 26. 2008 02:53 PM

Software vulnerabilities

It's always hard to know how to split things up in assemblies etc. Since I regularly do not only asp.net apps, but also winforms and also command line apps I aim not to get a lot of extra unwanted dependencies. So at least I have a separate DB helper dll, a separate string/utilities dll. And trying to do a web helper dll, a winforms helper etc...But it's hard to take the time to structure it and actually DO it, although I know in the end I would gain from it. Too easy resuing code with copy and paste I guess Smile

Software vulnerabilities

May 26. 2008 06:16 PM

Matt

That's a really good tip, I think that makes a lot more sense than trying to build a single giant helper dll. I will go back and restructure the project that way which should help the goal of keeping the bloat out and the libraries concise! Thanks!

Matt

November 25. 2008 09:28 AM

car hifi

I copy the "util" class from project to project...anyways i have added the source code to my page... Smile
<a href="http://www.powernetshop.at/angebote/">car hifi</a>

car hifi

January 1. 2009 11:41 PM

Busby SEO Test

That so helpful, great tips.

Busby SEO Test

January 6. 2009 04:56 PM

surfsista

What about functions for enabling/disabling controls on a web page?

surfsista

January 10. 2009 09:27 PM

Busby SEO Test

Great to know about Building a Utility Library Without Going Overboard

Busby SEO Test

January 21. 2009 08:58 AM

Culprits of the Bad and Dirty tricks in Busby SEO Test Contest

REally was concerned with adding that type of functionality because I though I would have to be database engine specific, but maybe that isn't such a bad thing. this will be nice if it debug.

Culprits of the Bad and Dirty tricks in Busby SEO Test Contest

January 30. 2009 10:16 AM

Busby SEO Test

I aim not to get a lot of extra unwanted dependencies. So at least I have a separate DB helper

Busby SEO Test

February 8. 2009 02:46 AM

Info Lowongan Kerja

Thanks for the tips, thats help me.

Info Lowongan Kerja

February 8. 2009 02:47 AM

Lowongan Kerja

Many thank for that information

Lowongan Kerja

February 17. 2009 04:21 AM

Registry Errors

It's a good post to read with, it's really worthwhile coming on your page keep it up.

Registry Errors

March 6. 2009 10:43 AM

caesarea property

thank u

caesarea property

March 6. 2009 10:45 AM

moving arrangements

I aim not to get a lot of extra unwanted dependencies. So at least I have a separate DB helper

moving arrangements

March 6. 2009 10:46 AM

smart jammer

How about functions such as creating and returning a connection to the database and Command Objects. I use those all the time and usually copy the "util" class from project to project.

smart jammer

March 16. 2009 05:56 AM

Secured Homeowner Loan

nice post... i like this informative information of .... more post please... i enjoy reading this...Thanks dude...

Secured Homeowner Loan

March 18. 2009 06:01 AM

Seven Figure Marketing School

Thanks for sharing the Knowledge pal., its a big help for me.,

Seven Figure Marketing School

March 18. 2009 03:51 PM

Cellular Paralyzer

thank u we love it

Cellular Paralyzer

March 23. 2009 05:00 AM

giving4prosperity

Thanks for sharing this great post.

giving4prosperity

March 27. 2009 02:27 AM

Kampanye Damai Pemilu Indonesia 2009

I will go back and restructure the project that way which should help the goal of keeping the bloat out and the libraries concise!

Kampanye Damai Pemilu Indonesia 2009

March 27. 2009 02:40 PM

Inventory Management Software Open Source

Hi..
thanks for this tutorial..
great work..
nice..

Inventory Management Software Open Source

March 28. 2009 12:31 PM

Utah movers

so fun
hahah
lol

Utah movers

April 17. 2009 04:10 AM

goodpeoplegives

Thanks for sharing this great post.Smile




goodpeoplegives

April 17. 2009 04:21 AM

cash4trends

To be honest you cannot beat the services or the people that I have dealt with. Building a Utility Library Without Going Overboard is awesome! Building a Utility Library Without Going Overboard has really helped our business.

cash4trends

April 17. 2009 04:37 AM

billrainier

Dude, your stuff is the bomb! I am so pleased with this.

billrainier

April 18. 2009 04:51 AM

Leadership

Nice post, always good to see you sharing with the world!

Leadership

April 21. 2009 05:34 PM

Vermont movers

made me smile
thanks

Vermont movers

April 21. 2009 05:35 PM

Vermont movers

made me smile
thanks

Vermont movers

April 21. 2009 05:35 PM

Minnesota movers

love it
thank u
made me smile
made me love

Minnesota movers

April 23. 2009 05:16 AM

tnomeralc web design toys

Thank you for posting.

tnomeralc web design toys

April 26. 2009 07:27 PM

Leadership

What an interesting and informative post, I enjoy hearing your thought leadership on this topic.

Leadership

April 28. 2009 03:20 PM

california defective product attorney

Thanks for the breakdown of this info!

california defective product attorney

May 9. 2009 06:01 PM

Make Money Online

Thanks for the sources code.

Make Money Online

May 17. 2009 05:11 PM

moving

great pos
made my day

moving

May 18. 2009 04:01 PM

tukang nggame

Thanks for the creative info

tukang nggame

May 30. 2009 10:53 PM

belajar SEO para pemula

Great post about Building a Utility Library Without Going Overboard

belajar SEO para pemula

May 31. 2009 06:36 PM

cheap electric guitars

Bulding a utility definitely require a lot of work.

cheap electric guitars

June 5. 2009 08:06 PM

Tukang Nggame

thanks for this useful info.

Tukang Nggame

June 10. 2009 12:19 PM

how to grow taller

That is a great post

how to grow taller

June 10. 2009 12:19 PM

how to grow taller

That is a great post

how to grow taller

June 10. 2009 12:20 PM

how to grow taller

That is a great post

how to grow taller

June 12. 2009 02:19 AM

xbox 360 repair manual

This is really great post...

xbox 360 repair manual

June 18. 2009 02:51 AM

club penguin

I think that makes a lot more sense than trying to build a single giant helper dll. I will go back and restructure the project that way which should help the goal of keeping the bloat out and the libraries concise!

club penguin

June 22. 2009 05:18 PM

Movers

made it fun time

Movers

June 24. 2009 05:09 AM

payday loans

This post is great and really fun, thanks for the great info.

payday loans

June 25. 2009 10:31 PM

my blogging net

I want to have additional information using HTML, Java, CSS for my blog site. And finding what themes are applicable to my blog site and choosing what is the best version of blogengine for my blog site.

my blogging net

June 26. 2009 08:40 AM

University Park Real Estate

Hey, thanks for sharing the source code with us. You're a great help. I've downloaded the source code, I will look into it and will reply back to you soon once I finish the project I am working on.

University Park Real Estate

June 30. 2009 12:35 AM

key biscayne real estate

Wonderful. This script seems great. Thanks for sharing the code.

key biscayne real estate

June 30. 2009 07:52 AM

Life Insurance

In computer science, a library is a collection of subroutines or classes used to develop software. Libraries contain code and data that provide services to independent programs. This allows the sharing and changing of code and data in a modular fashion. Some executables are both standalone programs and libraries, but most libraries are not executables. Executables and libraries make references known as links to each other through the process known as linking, which is typically done by a linker.

Life Insurance

July 1. 2009 10:35 AM

Trailer Insurance

"Life Insurance and Mediclaim are like left and right hand of an individual. Today no one knows what will happen in your life when you are leaving from the home for office or even I say if you are in your home. Today the cost of hospitalisation is so huge that a medium income group person can not afford hospitalisation expenses. So Mediclaim Policy is must for an individual.

Trailer Insurance

July 2. 2009 03:29 AM

r4 sdhc

Hi,

Great post about Building a Utility Library...........Thank you for giving wonderful information....

r4 sdhc

July 2. 2009 04:12 AM

Income protection

Nice stuff.This is my first time i visit here. I found so many interesting in your blog especially its discussion.Keep your blog updating,good luck...

Income protection

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

July 3. 2009 10:49 PM

Search

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2009