Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio: What approach do you use to 'template' plumbing for similar projects?

When building ASP.NET projects there is a certain amount of boilerplate, or plumbing that needs to be done, which is often identical across projects. This is especially the case with MVC and ALT.NET approaches. [I'm thinking of things such as: IoC, ORM, Solution structure (projects), Session Management, User Management, I18n etc.]

I would like to know what approach you find best for 'reusing' this plumbing across projects?

  • Have a 'master solution' which you duplicate and rename somehow? (I'm using a this to a degree at the moment, but it's fairly messy. Would be interested how people do this 'better')
  • Mainly rely on Shared Library projects? (I find this appropriate for some things, but too restrictive for things that have to be customised)
  • Code generation tools, such as T4? (Similar to the approach used by SharpArchitecture - have not tried this myself)
  • Something else?
like image 527
UpTheCreek Avatar asked Mar 31 '10 09:03

UpTheCreek


2 Answers

Visual Studio supports Custom Templates.

like image 136
Omar Avatar answered Oct 11 '22 21:10

Omar


I definitely (mostly!) go for T4 templates in conjunction with a modified version of SubSonic 3. I kind of use the database to model my domain and then use the T4 templates to generate the model and associated controllers and views. It takes about 50-60% of the effort out and keeps a consistency in place.

I then work on overrides (partials) of the classes along with filters and extension methods to 'make the app'. Now that I'm familiar with the environment and what I'm doing, I can have a basic model with good plumbing in place in a very short space of time. More importantly, because I create a set of partial class files, I can regenerate all I want without losing any of my 'custom' coding.

It works for me anyway :)

like image 40
jimi Avatar answered Oct 11 '22 21:10

jimi