I just learned about the MVC architecture. I was going back and working on a command line file transfer application I wrote, and I was curious, to what degree should command line interfaces follow the MVC pattern?


1 Answer 1


Model View Controller isn't just for applications with GUI's. Very simply it's the idea that you can separate your code into at least three areas of responsibility. Actually, under MVC the fact that your application is a CLI is a detail to which the model can be blissfully unaware. One of the advantages of this is that means you can use the same model untouched if you decide to make a GUI version of your App.

CLI or not, the "degree" to which you should follow MVC depends entirely on how much you care about writing code that welcomes a requirements change. Otherwise, feh, who cares?

  • Your second paragraph makes it sound like MVC is the only way to write flexible, maintainable software. That isn't true. Commented Oct 13, 2017 at 22:31
  • MVC is primarily about GUI (i.e. decoupling the View from the rest of the system), and since CLI doesn't have a GUI, well... Commented Oct 13, 2017 at 22:54
  • @RobertHarvey, I would say MVC is primarily about UI, which can take many forms, but graphical is certainly a very prevalent form. The View is all about presenting data to the user and that applies equally in a GUI and a CLI. Commented Oct 14, 2017 at 7:57
  • @BartvanIngenSchenau: Agreed. MVC isn't particularly interesting from a CLI perspective, however. Your CLI might be one class, or perhaps a parser. Commented Oct 14, 2017 at 14:34
  • I agree if you were to change view to interface M-UI-C instead of MVC, the idea would be clearer. At the end of the day it is about separation of concerns. Separating your user interface from your data from your algorithmic code will almost always get you better code. The extent to which this is beneficial is directly proportional to the complexity of the task. Commented Jun 23, 2023 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.