- Django Design Patterns and Best Practices
- Arun Ravindran
- 287字
- 2021-06-25 21:32:01
Fowler's patterns
In 2002, Martin Fowler wrote Patterns of Enterprise Application Architecture, which described 40 or so patterns he often encountered while building enterprise applications.
Unlike the GoF book, which described design patterns, Fowler's book was about architectural patterns. Hence, they describe patterns at a much higher level of abstraction and are largely programming language agnostic.
Fowler's patterns are organized as follows:
- Domain logic patterns: These include domain model, transaction script, service layer, and table module
- Data source architectural patterns: These include row data gateway, table data gateway, data mapper, and active record
- Object-relational behavioral patterns: These include Identity Map, Unit of Work, and Lazy Load
- Object-relational structural patterns: These include Foreign Key Mapping, Mapping, Dependent Mapping, Association Table Mapping, Identity Field, Serialized LOB, Embedded Value, Inheritance Mappers, Single Table Inheritance, Concrete Table Inheritance, and Class Table Inheritance
- Object-relational metadata mapping patterns: These include Query Object, Metadata Mapping, and repository
- Web presentation patterns: These include Page Controller, Front Controller, Model View Controller, Transform View, Template View, Application Controller, and Two-Step View
- Distribution patterns: These include Data Transfer Object and Remote Facade
- Offline concurrency patterns: These include Coarse-Grained Lock, Implicit Lock, Optimistic Offline Lock, and Pessimistic Offline Lock
- Session state patterns: These include Database Session State, Client Session State, and Server Session State
- Base patterns: These include Mapper, Gateway, Layer Supertype, Registry, Value Object, Separated Interface, Money, Plugin, Special Case, Service Stub, and Record Set
Almost all of these patterns would be useful to know while architecting a Django application. In fact, Fowler's website at http://martinfowler.com/eaaCatalog/ has an excellent catalog of these patterns online. I highly recommend that you check them out.
Django also implements a number of these patterns. The following table lists a few of them:

- Web交互界面設計與制作(微課版)
- R語言編程指南
- Python爬蟲開發與項目實戰
- JavaScript前端開發與實例教程(微課視頻版)
- Python程序設計案例教程
- 精通Python設計模式(第2版)
- C#實踐教程(第2版)
- Java面向對象程序設計
- Python深度學習原理、算法與案例
- Mastering Concurrency Programming with Java 9(Second Edition)
- C# 7.1 and .NET Core 2.0:Modern Cross-Platform Development(Third Edition)
- jQuery Mobile Web Development Essentials(Second Edition)
- SaaS攻略:入門、實戰與進階
- Mobile Test Automation with Appium
- Learning Swift