Applying TDD when the application is 100% CRUD

后端 未结 9 1754
梦谈多话
梦谈多话 2021-01-30 04:23

I routinely run into this problem, and I\'m not sure how to get past this hurdle. I really want to start learning and applying Test-Driven-Development (or BDD, or whatever) but

9条回答
  •  醉梦人生
    2021-01-30 04:31

    TDDing a simple CRUD application is in my opinion kind of like practicing scales on a guitar- you may think that it's boring and tedious only to discover how much your playing improves. In development terms - you would be likely to write code that's less coupled - more testable. Additionally you're more likely to see things from the code consumer's perspective - you'll actually be using it. This can have a lot of interesting side effects like more intuitive API's, better segregation of concerns etc. Granted there are scaffold generators that can do basic CRUD for you and they do have a place especially for prototyping, however they are usually tied to a framework of sorts. Why not focus on the core domain first, deferring the Framework / UI / Database decisions until you have a better idea of the core functionality needed - TDD can help you do that as well. In your example: Do you want messages to be a queue or a hierarchical tree etc? Do you want them to be loaded in real time? What about sorting / searching? do you need to support JSON or just html? it's much easier to see these kinds of questions with BDD / TDD. If you're doing TDD you may be able to test your core logic without even using a framework (and waiting a minute for it to load / run)

提交回复
热议问题