I seen here that static class & static functions are bad because they take a lot of memory.
I use it for many things like that need interact with the database etc..
This example of part of the Static Localization class, the GetResources
public static class SFLocalization
{
public static string GetResources(string key)
{
string CurrentLanguage = System.Threading.Thread.CurrentThread.CurrentUICulture.ToString();
if (MemoryCache.Default["Resources_" + key] == null)
{
string x
using (Db _db = new Db())
{
MemoryCache.Default["Resources_" + key] = _db.Languages.First(l => l.Key == key && l.LanguageCode == CurrentThread).Value;
}
}
return MemoryCache.Default["Resources_" + key];
}
}
And then In the view, Controllers etc.. I write just this to get the translated value
@SFLocalization.GetResources("NewsletterBoxTitle")
1.) Is static class in those situations really so bad?
2.) What is the alternative ? maybe the dependency injection (ninject etc..)?? (I seen it in the book Apress - Pro Asp.net Mvc 4