The Importance of Upholding OO Design Patterns
When I was 13 years old, I was introduced to coding C/C++ in a small window on my parent’s DELL computer. To me, code was a way to get things done. I got started by using the Arduino platform — a small USB micro-controller. If you wanted to have the board perform a task, you’d type some variables and functions into the IDE, and you’d see the results live… in front of you. There was rarely a program over 100 lines.
When I had my first real world internship, I expected code to be very organized. These are professionals I was thinking. While my code was wrought with legacy problems at home, I was sure that if a person was getting paid to code then their code must be clean right?
The opposite happened in this case.
Instead of having clean, modular, documented code, I dealt with a couple files that had no modularity to speak of. These were career software developers getting paid 6-figures to often write and deal with legacy code that had poor design and no modularity. Writing beautiful code is hard to create if your manager values results without valuing stable infrastructure.
When you move fast and break things, you write shitty code in the process.
When people wonder — a year later — why they cannot pinpoint an issue with code, it usually comes down to bad design or not taking care of legacy code issues.
This is what prompted Facebook to change their catchphrase. Move fast with stable infrastructure. Stable infrastructure is the cornerstone of any good product or service. If your infrastructure sucks, it’s really hard to build a great product.
When we think about mobile products, the Model-View-Controller (MVC) design pattern is key. While design patterns in OOP are often ignored, I firmly believe that MVC needs to be upheld in almost every mobile application (or a relevant design pattern) in order for you product to scale at a stable rate. When you code with a proper design pattern, objects communicate without inefficiency.
There are a lot of different OO design patterns, and design patterns in other paradigms, but MVC stands out for most consumer-based applications. You can see a list-description of other OO design patterns in the link below:
Ensure that only one instance of a class is created and Provide a global access point to the object. Singleton pattern…www.oodesign.com
overview study model/view/controller design pattern ("mvc") see how to apply mvc in flash build an example mvc…www.moock.org
Of course, the MVC design pattern only works for limited types of software. As you might expect, MVC works well when you are using an OO language with an interface, logic, and user input. Not all of the software you write will require of work well with this pattern.
However, when it comes to writing mobile applications, MVC is incredibly useful to follow. MVC separates power into 3 distinct branches, with specific rules for each branch. You can read more about MVC in the link above, but the basic model goes as follows:
- The model handles all the business logic. It handles any requests you might have to a server, to device-based SQL interfaces, and logic functions.
- The view is what the use sees, interacts with, and manipulates.
- The controller manages the view, and then communicates user input back to the model to process. The model then tells the controller how to update the view, based on a response.
Stanford’s Swift / Objective-C classes in years prior have always used a really well put together diagram of the MVC design pattern, which I will include below this paragraph.
MVC solves the infrastructure problem that I talked about earlier. It compartmentalizes the role of different parts of code so that each department works together efficiently.
If you found this article at all useful, please click the ❤ below. I think this is something that many early, first-time programmers don’t learn to use properly. Use it! :)