[Solved]-Django-like Framework Pattern

2đź‘Ť

Looking at Django design philosophies

I think they use/combine a lot of different design patterns trying to fulfill the philosophies. It’s difficult to map to a single concept.

Tip is to look at Software Design Pattern and it should be possible to identify many patterns are used in django. Many patterns are of course common in other frameworks as well.

For example (patterns more or less used):

  • modelform_factory maps to “Builder”
  • QuerySet can be mapped to “Lazy initialization”
  • The ORM/database mapped to “Adapter”

1đź‘Ť

What is it about django that you cannot do in other languages?

  • is it the access to the database, or the models? – no, python also has SQLAlchemy; ruby has Active Record…
  • is it the views, or web framework? – no, you can provide views with Flask, Pyramid, rails, php …
  • it is the templating system? – no, you also have Jinja; mustache, Liquid…
  • is it the admin contrib packages? – no, you have phpmyadmin, workbench …
  • is it a set of libraries to make your development easy? a toolkit?

django has great tooling, many packages you can use; it is a platform, meaning it has enough of a core to be the starting point of many projects, and enough community behind it to have many packages to make integration into a turn-key solution a breeze.

django uses the DRY (Don’t Repeat Yourself) principle as a design philosophy. From the point of reusability, keeping clear responsibilities for each piece / app makes it easy to reuse components. But that doesn’t take a well-designed platform; the emphasis should be on the components that are written in a way to be reused. E.g. generic tagging, configuration / data-driven components…

👤dnozay

0đź‘Ť

Django is MVC.

MVC is a pattern not a strict rule frameworks have to apply. The pattern tries to give a commonly accepted solution to a frequent problem. The problem is “How to properly organize a web framework” and the solution is “by separating data, logic and UI” in meaningful modules.

Therefore Django is MVC. Django logically separates those concepts (and many others) in modules. That’s what matters IMO. Django view is not the same as MVC view, but… poteto potato…

About app reusability:

Django is The web framework for perfectionists(…) and perfectionists (or simply good developers) write reusable code. This is expressed by Django DRY philosophy and materializes in Django apps.

I’m pretty sure you can design app-like components with other web frameworks. Of course, since apps are in Django’s nature since many years, it has much better support!

👤Sdra

Leave a comment