3

I'm a long time Java programmer and I'm digging into Django recently to see what it offers.

It looks to me that Django doesn't fit Java web developers taste.

I mean in MVC Java web frameworks we have usually a controller class that receives the request, do the logic and then forwards the request to another destination.

Rails also follows this paradigm.

Django on the other hand looks a little bit procedural, you map requests in a file, write your handlers in another, write your domain classes in another ...

So, I think Rails suits Java web developers taste and Django suits PHP folks.

If you are a Java web developer, how do you see Django?

Are you a Java programmer that is happy using Django?

(I'm not underestimating Django, Django framework is unquestionable).

Chiron
  • 20,081
  • 17
  • 81
  • 133

1 Answers1

4

Django on the other hand looks a little bit procedural, you map requests in a file, write your handlers in another, write your domain classes in another ...

As a Java developer, how is this any different than a traditional Java MVC pattern? It's just different names: Django uses "view" for what is traditionally (in Java-land) called a Controller, "template" for View, etc.

Don't you have domain classes in your Java application as well?

In Java-land, when you have an MVC webapp, you have the same sort of splitting of logic:

  • You write the request-handling logic in your Controller
  • You represent the "domain" in your Model/domain classes
  • You write the display logic in your view templates/classes

I'm having a hard time understanding what you think is different about Django beyond the names.

matt b
  • 138,234
  • 66
  • 282
  • 345
  • Django uses single file for domain objects, single file to collect request handlers. In Java you write a POJO or you inherit a class, in Python you write plain methods, there is no feel of Object Oriented world. I don't feel there is kind of splitting or "clean layout". That what I meant by procedural nature. – Chiron Aug 04 '10 at 13:34
  • 3
    @El Gusto - no one requires you to write your "domain classes" (by which I assume you mean Django models) in one file - in fact, it's a much better practice to split them up. I've no idea what you mean by Django not feeling OO. Do you mean you can't have object-oriented views? If so, you can (see http://stackoverflow.com/questions/742/class-views-in-django). – Dominic Rodger Aug 04 '10 at 13:56
  • Yes sorry I mean Django models (sorry I'm new in Django land). How to split models over multiple files? say I want each model to has its own file. Aren't all models supposed to be in models.py? – Chiron Aug 04 '10 at 14:07
  • No, they don't need to be. In python there is no difference between having one `.py` file with many `classes` and having many `.py` files each with one class in them. – matt b Aug 04 '10 at 14:20
  • Weather its best practice or not, I tend to consider django as an hmvc framework, mapping domain classes for an 'app' to one model file, but breaking the logic up into modules or apps, and if there are logical groups of domain classes, grouping them together into sub-packages: i.e: (book.yellowpages.company.person.model) . Each app maintains the mvc separation. You can pretty much put domain logic anywhere you want though, django only gives you some defaults for the way this is set up. – danbgray Apr 07 '12 at 19:43