Keeping it short…

by Mikael Henriksson 12. April 2009 20:31

I am not sure this is liked by many (if any) but I hate having to write too much. Back to being lazy and I love to take shortcuts. One thing I really like doing is to shorten like follows:

public ActionResult Index()
{
    return View(new Repository().GetAll<News>());
}

Personally I feel this is almost as readable as the alternative but saves my keyboard a few years in the long run:

public ActionResult Index()
{
	var repository = new Repository();
	var list = repository.GetAll<News>();
    return View(list);
}

 

Tags:

MVC

blog comments powered by Disqus

About the author

Life architect specialized in programming