These principles will change your Object Oriented Programing life
The Application Framework module focuses on application development using industry standards and frameworks that become industry leaders. This module’s first lecture focuses on industry practices and principles in software engineering.
The first lecture is categorized into four sections.
2. Approaching the solution
3. Implementing the solution
Single Responsibility Principle (SRP)
SRP is a computer programming principle that states that each function, class, or module should have a single responsibility and purpose. Where it only serves one purpose and there is only one reason to change.
Open-Close Principle (OCP)
According to the OCP principle, software entities or objects(class, methods, etc.) should be open to extension but not to modification.
Liskov Substitution Principle (LSP)
According to the LSP principle, any subclass object should be substitutable for the superclass object from which it is derived.
Interface Segregation Principle (ISP)
ISP states that no code should be forced to depend on methods it does not use.
Dependency Inversion Principle (DIP)
According to DIP, high-level modules should not depend on low-level modules. Instead, both should depend on abstractions.
2) Approaching the solution
In software engineering, we try to find a technical solution to a business problem. How can we best achieve this solution?
- Think throughout the problem : Before we can approach any solutions, we must first thoroughly consider the problem. We must ensure that we have a complete understanding of the problem.
2. Divide and conquer : Divide the problem into smaller parts to make it more manageable, and determine the priority level.
3. KISS : Keep it simple and stupid, and avoid overthinking.
4. Learn, especially from mistakes : Accept change and try to anticipate it as much as possible.
5. Always remember why software exists : Keep in mind why this software exists, and losing sight of the bigger picture may lead you down the wrong path.
6. Remember that you are not the user : Enduser is not as technically capable as you are. As a result, do not assume that the user will understand. It is important to consider user-friendliness and user experience.
3) Implementing the solution
There are some guidelines to follow when implementing the designed solution.
YAGNI — You ain’t gonna need it
This means that you should only implement things when you actually need them, not when you think you might need them.
DRY — Don’t repeat yourself
Always reuse the code you wrote and keep it as generalizable and reusable as possible.
Even if you don’t know how each component is implemented, make sure your system works properly.
DRITW — Don’t reinvent the wheel
It’s possible that the issue has already been addressed by someone else. Take advantage of it.
Write code that does one thing well
A single piece of code that does one thing and does it exceptionally well.
Debugging is harder than writing code
Make it readable as much as possible. Compact code is preferable to readable code.
Kaizen — Leave it better than when you found it
Not only should the problem be fixed, but so should the code that surrounds it.
Practices are a set of guidelines that we should follow to when writing code. This will be beneficial because it will reduce the complexity of the code, thereby reducing the possibility of errors.
The following are some of the software development practices that are widely accepted in the industry.
1. Unit testing
Unit testing involves testing a portion or unit of a program that will have an impact on the main program. For example, testing a module, an API, a function or a class, and so on.
2. Code quality
The quality of the code has an impact on the overall quality of the development. Quality also reflects the development’s safety, security, and dependability.
3. Code review
Code review is performed to ensure that the code is error-free. This process is carried out with the help of one’s fellow programmers, and the author of the code is informed of any errors in the code.
4. Version controlling
This is also referred to as source control. This is the process of tracking and managing software code changes. This is an important practice that can be used to retrieve older versions of the source code.
5. Continuous integration
This comes under the category of Software Development practices. After the development and testing are completed, the developers merge the code into a main centralized repository.
Classes and objects
Classes : Classes serve as a starting point for the creation of objects. They encapsulate data with code that allows them to work with it. Classes in JS are prototype-based, but they also have some syntax and semantics that are not shared with ES5 class-like semantics.
Classes are “special functions,” and the class syntax, like function expressions and function declarations, has two components: class expressions and class declarations.
The following are the primary goals of establishing “strict mode”:
→Remove some insecure aspects of code operation and ensure code operation safety
→Improve the compiler’s efficiency and speed of execution;
The closure has three scope chains
*The ability to access its own scope.
*The outer function’s variables are accessible.
*Global variable access.
Callbacks and promises
We can use Promises to postpone the execution of a code block until an async request is completed. Other operations can continue uninterrupted as a result.