开发者

ASP.NET MVC and Test Driven Development

I am novice.NET programmer. I've learned C#, Windows Programming, SQL Server 2005, ASP.NET 3.5. I want to ask if it would be difficult or not appropriate for me to start working at a job which requires ASP.NET MVC and Test Driven Development. I've already obtained the book "Pro ASP.NET MVC Framework", but this book overburdens me. So what can I do? Please help.

--

Thanks for your answers, all! I am more confused now :-) But I am 开发者_JAVA百科going to fight against it show persistance to learn.


If you don't understand MVC or TDD and the job requires experience in both those areas, it is unlikely that you will get the job, however if you are open and honest about your experience, skills and aspirations you could ask if they have any junior positions available where you can work with people in these areas so that you can learn and move up.

The TL;DR Version =)

  1. Read blogs
  2. Learn TDD
  3. Build simple MVC app
  4. Extend simple MVC app with IoC and ORM
  5. Share simple MVC app via github or similar

The Full Version

Learning TDD and MVC at the same time is a lot of work as while MVC is more testable than webforms, there are still many areas of it that are extremely difficult to test ( outbound routing is one that comes to mind immediately ).

A good place to start is by looking at some of the .NET TDD katas that are around as these will show you how an experienced TDD practitioner solves simple problems using TDD. You can also start practicing these katas yourself to get comfortable with the concepts and approaches used. Have a look around the blogosphere - there are plenty of good bloggers writing excellent content around MVC and TDD.

Once you get over the initial TDD hurdle, build yourself a simple MVC website - something like the classic blog engine. To reduce your initial cognitive load, keep it real simple:

  • Store everything in lists in memory and use a simple interface to hide the implementation of that from your controllers - this means you can ignore your data access for the short term.
  • Use testing constructors i.e. public MyController( IPostDao posts ) { ... } and overload it for runtime use with public MyController() : this( new SessionPostDao() ) {} - this means you can ignore IoC containers for the short term.

Always be aware that these "shortcuts" are only there to reduce the steepness of the learning curve and should never be used in production code.

Once you start to get the hang of building a simple MVC app, add an IoC container into the mix. I would suggest Ninject as that has the best documentation of the common .NET IoC containers and also appears to be the simplest to get up and running. Remember to delete those ugly overloaded constructors now that you are using IoC to build up your controllers.

Next up add some real persistence, I prefer NHibernate to EF but the NH learning curve is insanely steep ( even when you use ActiveRecord ). LightSpeed is a great option as the free edition is limited to 8 model classes and it is very simple to use however the downside is that prospective employers may not be using it.

Now you have a simple blog engine build using MVC, with your controllers assembled via an IoC container and your persistence handled via an ORM ( all covered by various unit and integration tests ) that you can use to show prospective employers how much you know - but remember this is only a surface treatment, there is a lot more to building MVC apps than bolting together a few controllers, an IoC and an ORM ( e.g. routing, view heplers, filters, alternative view engines).

To make sharing your blog engine with prospective employers even simpler, use a free github account to store your project, that way you can learn git as well as mvc / tdd / ioc and orm =)


You're going to have a lot to learn, but thats usually expected of junior developers. I think if you find a chance to work with a team experienced in TDD and can learn from them, that is a great oppportunity go for it.


If you are up for a BIG challenge by all means continue. By the look of things you are in way over your head. If you ain't certain you can manage I recommend getting some more experience first. MVC is as big as WebForms and TDD is even bigger.

The question really is, do you WANT to spend 24/7 the next few months catching up?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜