官术网_书友最值得收藏!

Designing the application

When you have a fairly good idea of what you need to build, you can start thinking about the implementation in Django. Once again, it is tempting to start coding away. However, when you spend a few minutes thinking about the design, you can find plenty of different ways to solve a design problem.

You can also start designing tests first, as advocated in the Test-driven Development (TDD) methodology. We will see more of the TDD approach in Chapter 11: Testing and Debugging.

Whichever approach you take, it is best to stop and think:

  • What are the different ways in which I can implement this?
  • What are the trade-offs?
  • Which factors are more important in our context?
  • Finally, which approach is the best?

The best designs are often elegant and harmonious as a whole. This is usually where design patterns can help you. Well-designed code is not only easier to read, but also faster to extend and enhance.

Experienced Django developers look at the overall project in different ways. Sticking to the DRY principle (or sometimes because they get lazy), they think, have I seen this functionality before? For instance, can this social login feature be implemented using a third-party package such as django-all-auth?

If they have to write the app themselves, they start thinking of various design patterns in the hope of an elegant design. However, they first need to break down a project at the top-level into apps.

主站蜘蛛池模板: 稻城县| 溧水县| 抚顺县| 盘山县| 浦城县| 拉孜县| 长宁区| 化州市| 河西区| 峡江县| 聊城市| 内江市| 克拉玛依市| 桦川县| 兴宁市| 普安县| 平昌县| 景泰县| 东乡族自治县| 永寿县| 神木县| 商河县| 鄂伦春自治旗| 湖北省| 商城县| 金沙县| 光山县| 班玛县| 大石桥市| 喜德县| 准格尔旗| 兴安盟| 广东省| 盐城市| 靖远县| 通榆县| 台前县| 延安市| 商河县| 黔南| 科尔|