11

I have been using Django for many years (since Django 1.2). and in the past, I used different type of web frameworks (such as CakePHP, Rails, ASP.NET MVC, and some other full-stack framework). Django wasn't my first framework.

Different frameworks have differences in their approaches and benefits. There are certain part of those framework I like and I don't. In this context, I'd like to look at the design of Django Framework in more specific.

After transition to Django, I like how it design its framework. When learning a new language (such as Go, Scala, Ruby, Haskell), I try to looks for a framework that has some similarity in its design especially those I mentioned later.

The following are the 2 Django framework design decision that is very different:

I would not believe that Django pioneer such features. I believed this pattern is very common in Framework Design. Just that I have no idea, what is this (design) pattern called? This concept is very useful to be applied in other framework. I believed knowing the name of the pattern could help me understand or even build a new framework on different language with the same concept.

Currently there are tons of web framework, most of them are following the classic MVC pattern. Some use the concept of plugin to add certain capability. Plugin however solve the reusability in different approach depending on the context.

So I did tried to learn as many framework I could in order to find an alternative framework in different languages. Hoping that I could find out the pattern that Django use. However, it is very difficult for me to learn all of them. In fact, I haven't found one so far.

I have been searching for:

Unfortunately, none of them really, highlight the concept that I'm interested in.

In this Q&A, I would like to know what do people call such framework? (Or What pattern is Django use?) Would be good if you could give a references in this design which other framework might have been using it too?

Community
  • 1
  • 1
Yeo
  • 11,416
  • 6
  • 63
  • 90
  • Don't fall into this like to like comparison. In truth I've been searching for this pattern also but I've found that not every language gives the same experience and expressive power as another one. PHP is different than ruby and Scala is different than Go. Their frameworks will be different also. Django is unique for what it is. – Fanis Despoudis May 10 '15 at 09:43
  • @FanisDespoudis, Agree we shouldn't find single truth framework, different framework has different capability. They also serve better in different domain. Just that this question is for the purpose of learning the pattern, so that we could apply to different domain. – Yeo May 10 '15 at 12:51
  • I'm not sure why those downvoters should downvote this question. Hope we don't compare which frameworks is better. But rather we learn what we could from different frameworks. – Yeo May 13 '15 at 13:35
  • 1
    question is too broad, and primarily opinion-based... – dnozay May 16 '15 at 05:34

3 Answers3

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):

Yeo
  • 11,416
  • 6
  • 63
  • 90
Daniel Backman
  • 5,121
  • 1
  • 32
  • 37
  • Thank you for giving some examples of how the design patterns are applied and mapped in different parts of Django internally. I've include some reference to the django source code into your examples. – Yeo May 19 '15 at 18:56
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
  • 23,846
  • 6
  • 82
  • 104
  • I am interested in app reusability. I agree with the aspects you've highlighted. They are common in most framework, but not the app reusability. You heard about [Flask-blueprint](http://flask.pocoo.org/docs/latest/blueprints/). It is also using the same pattern as Django-apps. – Yeo May 16 '15 at 09:13
  • if you mean the **DRY** (don't repeat yourself) principle, yes, `django` uses that principle as a guideline / design philosophy. – dnozay May 18 '15 at 03:20
  • Nice. One point: I wouldn't compare Django `admin` to `phpmyadmin` or `workbench` though, not even close. – Wtower May 19 '15 at 14:03
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
  • 2,297
  • 17
  • 30