Part 23 - Learning MVC Frameworks for Beginners

Written by Eric Muss-Barnes, 5 January 2019

You don't need to learn MVC frameworks. I already taught it to you. Because my students are brilliant, you didn't even realize how smart you are!

What are MVC frameworks? MVC is an abbreviation for "Model View Controller" and a "framework" is nothing more than a design philosophy.

You know how I often complain about how stupid these supposedly "genius" computer nerds are?

Okay.

Here's a story for you.

Back in 1998, my good friend Mike Rozack and I invented MVC frameworks, all on our own. As we were developing numerous websites, and constructing databases, and using include files, and creating blocks of code to reuse, we began to notice a pattern. There were certain ways to structure the code that just made a lot of sense. We would build a form page (the "Controller") to update a database. We would build a page (the "View") to display information. We would build a separate page (the "Model") to process a form that interacted with a database. Back then, if you were to research "how" to do this work on the Internet, most forums and developers would do all of that coding on a single page. That was stupid. We learned right away, their suggestions were messy and confusing and made for webpages that were far too complicated. Why were they building websites in such ignorant ways? Our methodologies were far superior. We didn't have nerdy names for this structure. We just built everything that way. Because it was logical. Because it was sensible.

About 10 years later, in around 2008 or thereabouts, other web developers finally started to catch up and figure out, maybe they should compartmentalize their code this way. Naturally, they took it 5 steps too far, made it overly complicated, and began to package these prebuilt libraries and structures of code as "MVC frameworks". Some popular PHP ones go by names like Laravel, Zend, Symphony, CodeIgniter. Oh, and by the way, these frameworks typically require a dedicated server. You can't learn frameworks on a shared web host, because the core functionality of PHP is frequently altered. So, using these prebuilt frameworks is never a very user-friendly system.

At the core of this "frameworks" philosophy is simply the idea of making logical structures in your code, and reusing functions and features you have already written. Which, as I said in the beginning, is what any smart developer does, right from the moment they start to learn how to program.

On one of my very first interviews as a developer in California, I had a team of developers scrutinize me and with utter disbelief, they asked, "So, you never went to college?"

"No, sir." I replied.

"And you wrote all of this code on your own?"

"Yes, sir."

As some developer scoffed incredulously, I wondered, "Why do you ask?"

"Because, self-taught developers never write code this clean. Only people who go to school learn how to do this. So, it's just hard to believe you didn't go to school, but you wrote this code."

"Oh. Well, I did."

I didn't get that job, because I think they assumed I was lying.

In other words, if you follow the guidelines I have shown you in these articles, you are already creating MVC frameworks on your own. You have sensible directory structures. You comment your code and compartmentalize it, so you can reuse old code snippets in new projects. Through sheer experience, you create your own frameworks.

MVC frameworks are nothing more than templates of prewritten libraries and premade file structures.

Are there ever times when a MVC framework marketed by others could be useful?

Yes.

Potentially.

Say, for example, you are building a complicated e-commerce website, with all kinds of order tracking, and fulfillment, and live inventory updates, and things of that nature. That type of website would be extremely complicated and time-consuming to build from scratch, so it might benefit you to use some templates and frameworks, to help you connect that stuff together and create the site in 2 months, instead of 6 months.

But, if you are building a website to promote an independent musician, or show a photography portfolio, or promote grandmas brownie baking business, you don't need to use MVC frameworks built by other people. That would be like hiring a construction company to build a backyard treehouse. You could do it, but you'd be kind of a loser. Build the treehouse yourself. Leave the construction company to the skyscrapers.

And remember, kids, the world owes you nothing... until you create things of value.


Glossary

MVC

An abbreviation for "Model - View - Controller" which is nothing more than a sensible way to structure your code. MVC is a design philosophy. A principal of coding architecture. An idea. A concept. Nothing more. While there are people who profess to using "MVC frameworks", that doesn't actually mean anything. "MVC frameworks" is just fancy computer-nerd speak for "I use prebuilt libraries of code, written by other people, because I am not smart enough to figure out efficient code structures on my own."

frameworks

Prebuilt blocks of code for programmers who are too lazy to write their own code from scratch. A justifiable crutch if you are building a massive website for social media, or e-commerce, with millions of users. No excuse for using lazy "frameworks" when building websites for personal use, or for small (under 1000 employee) companies.


Other Articles