1

To preface, I work at a place that I feel misunderstands and overuses MVC, but I also recognize that maybe it's me who doesn't understand it.

I'm used the model/view exclusively within the context of UI's and storing/transforming/ and representing data intended to be displayed by UIs. In that my experience may be admittedly limited to working with Qt and other desktop UI frameworks.

In my current company - like EVERYTHING has a model/view. I'm writing some low-level API type functions in their own package intended to be called easily by users at a command line, it doesn't display or represent data, it merely runs processes, and was told I needed to convert it to model.py and view.py.

To me this seems a bit insane, and I've rarely seen anything like it anywhere I've worked or across all of the github code I've browsed over the years, but I want to know if I just completely misunderstand some broader usage for MVC outside of UI development.

Edit: For a basic example - This means that for even the most basic "hello world" application, you're expected to have:

class HelloModel(model): def hello_world(): print("Hello world") 

And to run it, you'd need to:

import hello_world.model model = hello_world.model.HelloModel() model.hello_world() 

Naturally, this gets a little more crazy the more you add to it.

3 Answers 3

4

This seems like a classic case of YAGNI (you ain't going to need it)

You see this a lot with interfaces as well. Devs are told interfaces are good, polymorphism is good and that you should use it.

Devs then start to blindly apply interfaces to everything even when there is only one type that implements it.

MVC is the same. It's good, it helps solve a specific set of problems, but unless you can give a clear and solid example of why you need the added complexity RIGHT NOW, you don't need it. Tending towards KISS(Keep it simple stupid) is the goal.

As a general rule, if you find yourself trying/fighting to apply a pattern/rule/principle to everything (including this one ^_^). You may have become a bit dogmatic and would do well to take a step back and remember. Context is everything.

That being said trying to drive this type of organisational change from the bottom up is extremely difficult. And it seems MVC is very heavily embedded in the minds of your colleges.

In my view I see three options for you. Good luck with it mate.

  1. Acknowledge it's a bit over kill and then fall in line. Sometimes the harmony of the team is more important in developing good software than being technically correct.

  2. Work your ass off on making major impacts on the company that the developers see and feel, gaining you clout within the organisation. Once people come to you for their problems and ideas you will be in a position to start to try and push this change. Though it will be hard fought still.

  3. Decide you are not a good fit for this company and move on to another company in which you are.

Refrence

https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it https://en.wikipedia.org/wiki/KISS_principle

0

It does sound like it is overused. Or at least that another pattern might be more useful.

As to the broader usage consideration:

  • Models are Buffers that contain one thing (themselves).
  • Views are Transformations and Filters that based on an input, produce an output.
  • Controllers are Orchestrators and Business Rule Engines that rearrange views and models to achieve a desired outcome.

This is essentially Pipe and Filter Architecture. The humble Unix command line is the premier example of this.

  • The controller is the description of a pipeline,
  • the programs in the pipeline are views,
  • and the pipes themselves that buffer the data are the models.

Perhaps that would make it more palatable to work with?

1
  • Thanks for the insight. With the paradigm used by this studio, virtually everything is wrapped in a model. So to use a tool called "foo", I need to: import foo.model; model = foo.model.Model(); model.do_stuff(); Commented Mar 18, 2021 at 5:04
0

"When in Rome, do what the Romans tell you to do." Because they're the ones with gold coins in their pocket. 🤷‍♂️

However – it's okay to suggest that "MVC is a good start," but that it really doesn't fit everything. Plenty of practitioners have realized that "sometimes the shoe is a good, clean fit ... and sometimes it causes bunions." Therefore, over time, other metaphors and metaphor-extensions have been implemented. For example, PHP's "Laravel" framework introduces the concept of Services, and also regularly-scheduled Commands. Whether you do or don't like that breakdown is not the point. The point is just that: "nobody ever said that you could have only three buckets ..."

Really, any metaphor will do, as long as you are able to apply it consistently. Don't do things "for religious reasons." But, also, pick your battles wisely. Sometimes it's okay to "just play along." Persuasion takes time.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.