We will need to come up with a heuristic to base complexity off of, perhaps by counting the list_ and get_ functions to identify number of resources. Since our generators are learning tools, we should try to steer users into breaking their contexts into related groups if they treat a given one as a dumping ground. When running the generators, we can show a prompt or warning to the effect:
It looks your context is getting overly complex. Would you like to proceed?
* It's ok to have multiple resources in the same context,
but they should be closely related
* If they are not closely related, another context probably works better
* If in doubt, prefer a new context over adding to the existing one
We could also add a section to the context guide about this and link to it from the output
If this is implemented, I think we need a strong section in the docs on how to deal with it with some examples and couple strategies.
I don't think we should have a heuristic. We should just always show the warning and give the user the data and directions so they can take the decision.
You are generating into an existing context. This context currently has 40 functions and 4 files in its directory.
* It's ok to have multiple resources in the same context as long as they are closely related
* If they are not closely related, another context probably works better
If you are not sure, prefer building a new context over adding to the existing one.
Would you like proceed? [Y/n]
Great idea Jos茅. I think always showing it and giving "food for thought" is a great approach
I like that approach, Jos茅.
Coming to phoenix recently from Rails, I was very confused about what contexts are supposed to be, even after some reading. My first attempt at naming a context was "Frontend" and I was going to put all of my front-end, non-admin stuff in there, because I was thinking of context as being mainly a namespace thing, not a place where code actually lives.
A message like this when scaffolding my second resource would have been great.
Most helpful comment
I don't think we should have a heuristic. We should just always show the warning and give the user the data and directions so they can take the decision.