문제

I am going to start a project of my own, which will be ASP.NET MVC + Fluent NHibernate. I want to use test-first approach as much as I can. So, where exactly do I start from? Database schema? Domain model? Mapping domain model classes to the database?

도움이 되었습니까?

해결책

If you have little experience in writing tests, it's the easiest to start from the domain model (or a higher level just below the UI). When you have driven the design of the domain model with TDD, then you will know that what the database schema needs to be like. It may be good to postpone introducing a database to the system, because dealing with database schema migration will add some overhead to the development. And that will also lead to a better design, because then the domain model will be better decoupled from the database layer.

If you are skilled in writing tests and in TDD, it may be beneficial to start from an end-to-end test (in this case they would be written against the web UI) and produce a thin slice of functionality which touches all architectural parts of the system (as recommended in GOOS). In other words, create a walking skeleton. The benefits from this approach are that (1) you will be able to tackle and solve integration problems right at the start, (2) when the end-to-end tests are used to drive the design, it can help you to avoid implementing superfluous parts, and (3) the difficulties of writing the end-to-end tests pressure you to improve the architecture and add monitoring hooks, which may also be useful in monitoring the system in production. (Focused unit test will still be needed, because they provide design pressure at the class level, plus they run faster and thus provide faster feedback.)

I've written more about this latter approach at Design for Integrability.

다른 팁

Requirements gathering.

Start with a mock/prototype (e.g. Balsamiq Mocks) of the application, then writre the views, mocking controllers as you go along, then write the controller logic, mocking the DAO/Repositorys along the way. By the time you start writing your DAO/Repositories, you'll have a good idea of your your required domain objects. Knock those out and use Fluent Nhibernate to build your database.

At least that's they way I'm trying to do things.

I recommend you S#arp Architecture Project that uses best practices combining:

  • NHibernate
  • FluentNhibernate
  • TDD / DDD with model firts approach with Sqlite database for unit testing
  • Mocking
  • Repository pattern

You can also install S#arp arch. template for Visual Studio IDE.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top