tags:

views:

173

answers:

1

Hi guys,

I am an ASP.NET C# web developer.
The architecture followed is 3 layer
The layers used are
1. UI
2. BLL (Sometimes Communicating with BLL is done using WebServices)
3. DAL
Pretty basic stuff.

What I would really like to have is a BLL.Common class in the BusinessLogics.
Here I would like to use some useful extensions and helper functions that we use in almost all applications.

An example will IsNullOrEmpty extension.

Which are the helper functions most commonly used by developers?
It would be better if I could get a list.

Regards,
Naveen

+3  A: 

There are sooo many. Lets see (some (very few) from one of my reusable libs):

Generic Utils:

  • public static bool AreEqual(object val1, object val2)
  • public static bool IsNumber(string val, bool integerOnly, bool positiveOnly)

Reflection Utils:

  • public static object Activate(string typeName)
  • public static PropertyInfo Property(Type t, string prop)
  • public static void SetValueSafe(string path, object target, object val) // Converts type to appropriate. Great for auto generated UIs
  • public static object ConvertType(Type expectedType, object val)
  • public static object GetValue(object target, string fullPath) // Allow dot expression

Logger Utils:

  • Easy to use wrapper for log4net is a great help

File Utils: // Note all of these have to use streams safely (dispose them)

  • public static void WriteFileContents(string filename, Stream contentStream)
  • public static byte[] GetStreamContents(Stream stream)
  • public static string GetTextFileContents(string file)
  • public static void WriteFileContents(string filename, byte[] contents)
  • public static void AssertDirIsReadWrite(string fileOrDir, bool attemptCreate)
  • public static string GetZipFileTextContents(string file)
  • public static void ZipFile(string file, string zipFile)
  • public static void ZipFiles(string directory, string filter, string zipFile)
  • public static string FindFileInDirectory(string file, string baseDirectory)
  • public static void CopyDirectory(DirectoryInfo from, DirectoryInfo target)
  • public static void ClearDirectory(DirectoryInfo dir)
  • public static IEnumerable GetDirectories(string baseDir)
  • public static IEnumerable GetFiles(string baseDir, string ext) // Recursive

Colleciton Utils:

  • Add support for Linq like methods in non generic IEnumerable
  • public static void ForEach(IEnumerable e, Action action) // This one is great!
  • AreEqual
  • ToString
  • Cast
  • IsNullOrEmptySort
gatapia
thanks a lot pal. can you give the implementations of the helper functions also? btw i prefer elmah over log4net... which is better?
naveen
Implement them urself, they are all simple, they will all teach u a bit about their targets (linq, collections, streams, etc). As for logging, I don't think Elmah is logging lib, isnt it a error reporting lib? 2 different things and if you have a good logging library then you can do your own error reporting. However one logging lib is as good as another so don't get stuck on implementations.
gatapia