Earlier quoted context omitted.
I don't understand the distinction of "not domain logic". If your application requirements are "when user does X, update facebook" then that is clearly part of the domain and should absolutely be in the models.
Oh, i disagree with that completely. A user having a status is domain logic. Pulling that status from an external dependency is decidedly not.
The problem with controllers
11–20 of 23 posts
Re: The problem with controllers
#12Slightly off-topic, but does anyone have any resources for learning more about these and other design patterns that show up on HN from time to time?
Design Patterns in Ruby would probably be a good place to start, then the original GoF Design Patterns book, along with Enterprise Design Patterns which came later. Also check out the DDD/CQRS google group: http://groups.google.com/group/dddcqrs
Re: The problem with controllers
#13Earlier quoted context omitted.
I don't understand the distinction of "not domain logic". If your application requirements are "when user does X, update facebook" then that is clearly part of the domain and should absolutely be in the models.
Oh, i disagree with that completely. A user having a status is domain logic. Pulling that status from an external dependency is decidedly not.
Re: The problem with controllers
#14Earlier quoted context omitted.
Oh, i disagree with that completely. A user having a status is domain logic. Pulling that status from an external dependency is decidedly not.
How is it not? What draws the line between domain logic and non-domain logic? It would seem to me that, by definition, anything your application does would fall into that application's domain, right? What other domain would it be in? Where would you put a request to a third party for supplemental data, if not in the models?
Part of the problem with speaking about domains here (aside from being nonspecific about something that is by its very nature quite specific) is that Rails has an extraordinariliy half-assed approach to domain oriented design (I don't want to use 'DDD' here just to avoid buzzwords). Developers have been told for years to just push it into the model because all the work belongs there, but that's BS. a LOT of the work has no business being there.
Re: The problem with controllers
#15Earlier quoted context omitted.
How is it not? What draws the line between domain logic and non-domain logic? It would seem to me that, by definition, anything your application does would fall into that application's domain, right? What other domain would it be in? Where would you put a request to a third party for supplemental data, if not in the models?
If it were part of your domain, it'd be part of your application. Connection to facebook by definition is outside the scope of your domain. You can take a couple of different strategies to it, but in general the best way to handle that is to introduce a class whose responsibility is to connect to facebook and return a status (generally speaking, a Service) and something like a Command or Job that accesses the Faceboo…
Re: The problem with controllers
#16Earlier quoted context omitted.
How is it not? What draws the line between domain logic and non-domain logic? It would seem to me that, by definition, anything your application does would fall into that application's domain, right? What other domain would it be in? Where would you put a request to a third party for supplemental data, if not in the models?
If it were part of your domain, it'd be part of your application. Connection to facebook by definition is outside the scope of your domain. You can take a couple of different strategies to it, but in general the best way to handle that is to introduce a class whose responsibility is to connect to facebook and return a status (generally speaking, a Service) and something like a Command or Job that accesses the Faceboo…
Re: The problem with controllers
#17Earlier quoted context omitted.
If it were part of your domain, it'd be part of your application. Connection to facebook by definition is outside the scope of your domain. You can take a couple of different strategies to it, but in general the best way to handle that is to introduce a class whose responsibility is to connect to facebook and return a status (generally speaking, a Service) and something like a Command or Job that accesses the Faceboo…
[deleted]
Re: The problem with controllers
#18Earlier quoted context omitted.
If it were part of your domain, it'd be part of your application. Connection to facebook by definition is outside the scope of your domain. You can take a couple of different strategies to it, but in general the best way to handle that is to introduce a class whose responsibility is to connect to facebook and return a status (generally speaking, a Service) and something like a Command or Job that accesses the Faceboo…
It is part of the application, and thus part of the domain. A class that is responsible for getting status updates from facebook is part of your model. The way you say "updates your user model" makes it seem like you are thinking about the model as modelling the database. You keep saying this "has no business being in the model", but you haven't supported that in any way. Why doesn't it belong in the model?
Its not a part of your application. You have to connect to facebook over a network to get to it. That data is very clearly NOT a part of your application. Now if a facebook profile is actually a part of your domain in some way, you're going to have a class specifically to manage that. Connecting to the network to update that still isn't a part of that class's responsibility. Look at it this way: if there were someone who knew everything about your problem area, would their knowledge of the behavior of the data include reaching out to facebook and pulling it in over a network connection? almost certainly not, unless your domain is that of a browser. If your domain is something like klout, for example, your domain is going to include concepts like profiles, connections, posts, etc. Its not going to include anything involving Net::HTTP.
Re: The problem with controllers
#19Earlier quoted context omitted.
[deleted]
All that I am getting is that you seem convinced that the model is purely data. It isn't. Behaviours are part of the model. The behaviour of "getting info from some remote data source" is absolutely part of the model.
Even in a more typical Rails application, domain behaviors are supposed to be on the model. The responsibility for going over a network is almost never going to be a domain behavior. Just because you use the data in some way doesn't make it a domain behavior. Getting data from a remote data source is definitely not a part of the domain, and the fact that Rails has many developers convinced that's the way its supposed to be illustrates just how far down the rabbit hole the Rails world has fallen.
Re: The problem with controllers
#20Earlier quoted context omitted.
How is it not? What draws the line between domain logic and non-domain logic? It would seem to me that, by definition, anything your application does would fall into that application's domain, right? What other domain would it be in? Where would you put a request to a third party for supplemental data, if not in the models?
If it were part of your domain, it'd be part of your application. Connection to facebook by definition is outside the scope of your domain. You can take a couple of different strategies to it, but in general the best way to handle that is to introduce a class whose responsibility is to connect to facebook and return a status (generally speaking, a Service) and something like a Command or Job that accesses the Faceboo…
The goal of the "model" in MVC is to build an in-application model of outside-application (possibly "real world") state, whether it be a tree of browser bookmarks in folders or a tree of files in filesystem folders or a tree of reports in a command hierarchy; as your application needs to be able to understand these things, it needs to model them.
In an ideal world, your model presents a reasonably abstract rendition of the thing that you are modeling (so that you will be able to reuse views and controllers for anything that is sort of tree-like), however you may also be modeling something very particular to your application, in which case you will have a rather convoluted one-off model.
Now, to be clear, I'm not disagreeing with your suggestion of how to structure the logic of your application: having a bunch of data that is manipulated by connections to external systems can make a lot of sense; however, when "domain oriented design" is talked about, AFAIK the entire purpose is to decide how to internally structure your model, taking it as a given that, from an MVC perspective, that is where all of these behaviors and state are supposed to be kept.
http://blog.fedecarg.com/2009/03/11/domain-driven-design-and...
> Domain-driven design separates the model layer “M” of MVC into an application, domain and infrastructure layer. The infrastructure layer is used to retrieve and store data. The domain layer is where the business knowledge or expertise is. The application layer is responsible for coordinating the infrastructure and domain layers to make a useful application.