Skip to content

Instantly share code, notes, and snippets.

@ChrisMissal
Created June 12, 2012 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisMissal/2917597 to your computer and use it in GitHub Desktop.
Save ChrisMissal/2917597 to your computer and use it in GitHub Desktop.
Anti-Patterns and Worst Practices – Utils Class
public static class Utils
{
public static string CreateShippingMessage(DayOfWeek dayOfWeek, TimeSpan currentTime)
{
var message = "Your package will be delivered ";
if (dayOfWeek >= DayOfWeek.Monday && dayOfWeek <= DayOfWeek.Thursday)
message += currentTime < new TimeSpan(0, 17, 45, 0) ? "today" : "tomorrow";
else
message += "soon";
return message;
}
}
public static class Utils
{
private const string _filePath = "logfile.txt";
public static void LogMessage(string message)
{
using(TextWriter writer = File.AppendText(_filePath))
{
writer.WriteLine(message);
}
}
public static void LogException(Exception ex)
{
using (TextWriter writer = File.AppendText(_filePath))
{
writer.WriteLine(ex.Message);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment