T4 Templates Meet ReSharper

One of the hardest things to get my head around is writing code that writes code. Just putting that sentence together was hard enough. Try writing code that reverse engineers from a database and writes ORM code. Now it gets even harder.

Microsoft introduced template driven code generation that has become popular to use with Entity Framework. T4 templates, in particular, are extremely useful in customizing the way you wish to generate your code.

Don’t let me mislead you by the fact that T4 templates work nicely with Entity Framework. They work nicely when you need to write code that is based on a repeatable pattern. It contains text and directives that when running your templates against something configurable, it produces real executable code.

This was what Code Smith was all about. In fact, they had a complete set of .Net templates called Net Tiers that generated data access code implementing the repository pattern, along with NUnit tests.

I modified the Net Tiers templates once because I wanted everything generated to also add auditing code for every Insert, Update, or Delete statement executed. It was awesome; the best part was once the template was modified, it generated code for hundreds of tables in a couple of minutes, all accurate. That’s a value that is hard to beat, and one of the key reasons template driven code writers exist today. It isn't always the most optimum code. But with the hardware capacity available today I can use hardware to solve performance requirements and reduce the time it takes to write good, solid code.

T4 templates have the same power, working in Visual Studio. But modifying the templates is a bit of a brain twister. If you are a ReSharper fan there is some even better news for you. A user has just contributed an open systems add in to ReSharper optimizing Visual Studio for the editing of T4 Templates. If you’ve used ReSharper you know how it simplifies a lot of your code writing. Now those advantages are extended even to T4 Template maintenance. If you’ve done anything like that in the past, then you know this capability Really ROCKS!

Featured Article(s)Implementing a Custom Output Cache Provider in ASP.NET 4Initially the performance of the ASP.NET applications was a serious concern for web application developers. However many improvements have come in place over the time. This is evident in the newer versions of the .NET Framework. The IIS improvements also provide a better support to the application pools and so does the IIS compressions, etc. The use of CACHE as a state management technique for storing relatively stale data, i.e., data that doesn’t change much over time is a good measure. This minimizes redundant hits to database and hence enhances the speed of the application. Proper use of the CAHCE minimizes the network traffic and maximizes the responsiveness of the application. The ASP.NET Caching Framework by provides extension points which can be used to build custom cache providers easily. ASP.NET 4 allows you to extend the default cache model and build your own cache providers. This article will discuss the basics of cache state management techniques in ASP.NET and how we can extend its Caching Framework to implement our own custom made caching framework.