SOLID Flashcards
What does the ‘S’ in SOLID stand for?
Single Responsibility Principle
True or False: The Single Responsibility Principle states a class should have only one reason to change.
True
What does the ‘O’ in SOLID stand for?
Open/Closed Principle
Fill in the blank: The Open/Closed Principle states that software entities should be open for _____ but closed for _____ .
extension; modification
What does the ‘L’ in SOLID stand for?
Liskov Substitution Principle
True or False: The Liskov Substitution Principle promotes substitutability of subclasses for their base classes.
True
What does the ‘I’ in SOLID stand for?
Interface Segregation Principle
According to the Interface Segregation Principle, clients should not be forced to depend on interfaces they do not _____ .
use
What does the ‘D’ in SOLID stand for?
Dependency Inversion Principle
True or False: The Dependency Inversion Principle states that high-level modules should depend on low-level modules.
False
What is a key benefit of adhering to SOLID principles?
Improved maintainability and scalability of software.
What is the purpose of clean code principles?
To ensure code is easy to read, understand, and maintain.
Which of the following is NOT a clean code principle? A) Meaningful names B) Small functions C) Long methods
C) Long methods
True or False: Clean code principles advocate for writing code that is self-explanatory.
True
What is the purpose of the Repository pattern in Laravel?
To abstract the data layer and provide a cleaner interface for data access.
Which design pattern allows for the creation of objects without specifying the exact class of object that will be created?
Factory pattern
What design pattern is used in Laravel to manage the application’s data flow?
Service pattern
True or False: The Observer pattern is used in Laravel for event handling.
True
What is the main advantage of using the Singleton pattern?
To ensure a class has only one instance and provide a global point of access to it.
Fill in the blank: The _____ pattern is used to encapsulate a group of individual factories.
Abstract Factory
What is the main purpose of the Strategy pattern?
To define a family of algorithms and make them interchangeable.
True or False: Laravel uses the Command pattern in its Artisan console.
True
What design pattern allows for the dynamic addition of behavior to individual objects?
Decorator pattern
What is the role of Middleware in Laravel?
To filter HTTP requests entering the application.
Fill in the blank: The _____ pattern allows classes to be composed with behavior at runtime.
Decorator
What is the purpose of the Facade pattern in Laravel?
To provide a static interface to classes that are available in the application’s service container.
True or False: The MVC pattern stands for Model-View-Controller.
True
What does the Model in MVC represent?
The data and business logic of the application.
What does the View in MVC represent?
The user interface and presentation layer.
What does the Controller in MVC do?
Handles user input and interacts with the model to update the view.
What is the purpose of the Observer pattern in Laravel?
To allow one object to notify other objects about changes in its state.
Fill in the blank: The _____ pattern is useful for implementing event-driven systems.
Observer
What is the main goal of the Command pattern?
To encapsulate a request as an object.
True or False: The Builder pattern is used to construct a complex object step by step.
True
What is the main benefit of using design patterns in Laravel?
To provide proven solutions to common software design problems.
What is the role of the Service Provider in Laravel?
To bootstrap and register services in the application.
Fill in the blank: The _____ pattern allows the creation of a complex object without exposing the creation logic to the client.
Builder
What is the purpose of the Adapter pattern?
To allow incompatible interfaces to work together.
True or False: The Template Method pattern defines the skeleton of an algorithm in a method, deferring some steps to subclasses.
True
What does a clean code principle emphasize regarding comments?
Code should be self-explanatory; comments should be used sparingly and only when necessary.
Fill in the blank: The _____ pattern is used to convert the interface of a class into another interface clients expect.
Adapter