Tutorial :What reusable code should every developer have in their toolbox? [closed]


I'm trying to build up a library of reusable code to use from project to project. As I write code snippets and components, I'm trying to decide which libraries I will get the most use out of long term VS will I really use this again?

What code or components do you reuse that should every developer have?

I'm primarily interested in .net web and winforms.


Regular Expressions for verifying

  • Valid Date
  • Valid Number
  • Between two Dates
  • Zip
  • Postal
  • Age
  • Number Range

Depending on the language as some have these features already


A *nix operating system (Unix, Solaris, Linux, MacOS, Cygwin) and it's "classic" set of command line utilities.

The ways to merge, mix, bake, shred, and abuse these fundamental concepts are immeasurable.


Personally I think a good framework should provide these tools, not you. If not the language's default library (Java is a good example).


It depends on what kind of applications you write. So I don't think there is a real toolbox for any problem. (Or it should be the framework).

We have several applications and a cross application library. That contains a lot of code:

  • Printing functions.
  • Shape processing (we do a lot with shapes and polygons)
  • dB calculations
  • general application behaviour (housestyle).

Each time we have something in an application that is possibly useful for other applications, it is moved to the library.


  • Database Pooling code
  • Logging
  • String and collection manipulation
  • IoC maintenance (annotations or XML)
  • File and directory handling

Some of these may be supplied with a VM or standard libraries but you will always need something extra.


I've been working on creating a set of re-usable code for c#, for a little while now. By adding 1 component at a time and more importantly, using the framework for a real application, I've finally made the framework faily simple, well documented, and with various "modules" that tend to be used again and again.

Check it out at CommonLibrary.NET on CodePlex

It's a bit simpler and more lightweight than SpringFramework and MS App Blocks.

It includes things like : 1. Argument/Options parsing 2. ActiveRecord/Domain Model classes 3. Collections 4. Validation and a lot more..


I easily think of:

  • Linked list templates
  • Red-Black tree templates
  • Database initialization mini-api (for your favorite database or persistency layer)


I think that this will greatly differ depending on the language and what the framework you may be using has to offer. Much of the needed reusable code would be in a modern framework.


The answer depends on your goal -- often making something "reusable" takes more effort at the onset but of course, pays out later when reused -- provided of course, that it's truly reusable. Sometimes this ability is overrated ... IMO ...

The true answer to this will be answered as you write code -- when you find yourself saying, gee, I just wrote something like this last week.

My "toolbox" consists of string, math, network, database, file, logging, and a host of other "library" routines (assemblies, etc) that I can quickly include as a references. Of course, the key to making this a living library is to keep the code of these library items truly separate from the app/code being developed.

hope it helps ...


great question

  1. business object level caching
  2. my own custom authentication toolkit
  3. jquery selectors
  4. css for forms, tabs and ui elements
  5. encryption and hashing for passwords etc

altho I'm starting to replace my stuff with enterprise library - http://msdn.microsoft.com/en-us/library/cc467894.aspx - it at least gets improved up on over time and has way more eyes on it than my implementations


In .Net:

  • Extension methods that are not in .Net Framework (ForEach, AddRange, RemoveWhere, etc)
  • Switch.Type statement (for visitors)
  • Basic argument validation (Argument.EnsureNotNull)

That's almost all, various free libraries cover up the rest.


PKI authentication


My two:

  • Dependency injection code, so you can make it more testable; and not rely on a single implementation of a singleton.

  • Modular/Plugins functionality. It is also a great idea to make this mockable, so your client code can be tested without invoking a full-blown plugin system.

There are several implementations of both, though sometimes you can't avoid writing your own. :(


Parsing classes

Date manipulation classes

messaging classes

validation classes


As a weary and disgruntled code maintainer, I would look at this questions differently: what code should the project require be used, to avoid seven* developers creating seven different solutions, which require seven modifications when something changes (after discovering that there are seven different solutions).

I guess most people look at reuse as an efficiency tool in initial development, and forget that it is also the key to efficient maintenance.

*I think there are only seven, but I am still in testing.


A Money class that can handle currency, distribution, arithmetic operations, and formatting.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »