3.1 Introduction to Frameworks & Libraries Flashcards
What does the term “Design Pattern” mean?
The term design pattern is used in a variety of industries, such as architecture and UX design, and refers to a common solution to a recurring problem.
In software development in particular, a design pattern takes the form of a reusable solution to a problem frequently encountered by programmers, usually in the form of a set of guidelines for structuring your code.
What is MVC (model-view-controller)?
Model-View-Controller, or MVC, is an architectural pattern—or design pattern—that defines the structure of an application, or part of an application, by separating it into specific parts with specific roles. It first emerged in the seventies and has since become an industry standard among web development patterns, thanks largely to its scalability and extensibility in regards to the graphical user interface component of applications.
What is the “model” in MVC?
In MVC architecture, the model structures the data that the client-side of your application will access and interact with. This data is generally sent back to the client from the server-side, but it can also be loaded from static files.
The model is the most important member of the trio, around which the view and controller are organized. It should be view- and controller-agnostic, which means it can be reused in a different application.
What is the “view” in MVC?
The view is what’s displayed to the user when they interact with your application. It usually consists of an interactive graphical interface, possibly containing UI components such as charts, tables, and forms. Think of the view as a visual representation of the model.
What is the “Controller” in MVC?
The controller is the intermediary between the view and the model. It’s the component that users interact with when making requests (as opposed to the view, which users just look at). The controller manipulates the model based on users’ requests and communicates instructions from the model to the view to display.
How could MVC look like in practice, for example for your movie API?
Model: Loads movies from the server.
View: Displays the movies, each with a special toggle for users to click on if they want to “Favorite” or “Unfavorite” a particular movie.
View → Controller: Each time the user clicks on the toggle to add a movie to their “Favorites” list, the controller is triggered.
Controller → Model: The controller sends the user’s request to favorite the movie to the model and instructs the model to refresh.
Model: The model is refreshed. Back to step one.
What’s one disadvantage of using the MVC model?
One downside of the MVC model is that by forcing developers to create these layers of abstraction, every new part of an application has to adopt the MVC structure: one model, one view, and one controller, with corresponding files for each. This can start to feel like overkill, especially for small projects. You might end up with three files for a single, small feature, which can make your code harder to navigate.
Why would it be an advantage to use MVC model for your movie API?
The key player in the MVC design pattern is the model. To recap, it’s the model that structures the data the client-side of your application will access and interact with. Therefore, the MVC pattern works well with data-centric code. For your myFlix app, the model layer is centered on the movies stored in your database, making myFlix data-centric and (subsequently) MVC architecture a good choice.
What are frameworks and libraries?
Frameworks and libraries are tools used by developers to expedite their work. They contain pre-packaged code (usually) written by other developers that can be used to perform a wide variety of tasks and even structure your entire application. In fact, virtually anything in the web development world–client-side and server-side–can be completed with a third party tool; the hard part is knowing when and when not to use them.
What is a library?
A library is a pre-packaged piece of code that you can incorporate into your project as you like. You can think of a library as a box of tools. Libraries range in size from just a few lines of code about very specific things to a plethora of functions and utilities you can use for all manner of tweaks, features, and functionalities.
What is a framework?
A framework is a predefined structure into which you enter your code. Essentially, it determines how your application is built (this is also known as being “opinionated”). By providing a set of universal and reusable functions, frameworks can streamline the building of a certain type of application. Remember the table analogy given in Exercise 2.4: Web Server Frameworks & Express? As a refresher, the programming language you use is like the raw lumber for creating a table, and the programming framework is like the pre-made table pieces available on Amazon you can use to build the table more quickly.
What is the main difference between a framework and a library?
And there you have the main difference between a library and framework: with a library, you’re free to structure your code however you want. You can dip into a library and choose when and where to use its functions to complete certain tasks (just as you might drop into your local library to pick out different books). In contrast, a framework dictates how your application is built and the way your code is written, acting, you guessed it, as a frame!
You can also think of this difference in terms of an inversion of control. When you
Why is choosing the right framework for your project so important?
Because a framework will determine how an entire application will be built. Remember, you can always replace one library with another; however, if you change your mind about a framework—and this is no exaggeration—you’ll have to rewrite you entire application from the ground up.
What do you need tot hink about when choosing a framework for your project?
You first need to think about your project requirements and what you want to learn.
What is the MERN tech stack made of?
MongoDB
Express
React
Node.js.