These principles will change your Object Oriented Programing life

Vishwalakpriya
6 min readFeb 26, 2022

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.

1. S.O.L.I.D

2. Approaching the solution

3. Implementing the solution

4. Practices

1) S.O.L.I.D

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?

  1. 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.

Embrace abstraction

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.

4) Practices

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.

JavaScript(JS)

Introduction

JavaScript (js) is a lightweight object-oriented programming language that is used to script web pages on many websites. When applied to an HTML document, it is an interpreted, full-fledged programming language that enables dynamic interactivity on websites. It was first used in 1995 to add programs to webpages in the Netscape Navigator browser. It has since been adopted by all other graphical web browsers.

Users can use JavaScript to create modern web applications that allow them to interact without having to reload the page every time. The traditional website makes use of js to provide various levels of interactivity and simplicity.

JavaScript is not compatible with the Java programming language. JavaScript is the scripting and query language used by databases such as CouchDB and MongoDB, as well as web browsers.

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.

Objects : Almost all JavaScript objects are instances of Object; a typical object inherits properties (including methods) from Object.prototype, though these properties may be shadowed (overridden). However, an Object can be purposefully created for which this is not true, or it can be altered so that this is no longer true.

Prototypes

One of the most important concepts for JavaScript practitioners to understand is the prototype object because JavaScript is a prototype-based language This article will provide a brief overview of the Prototype object using various examples. You should have a basic understanding of this reference in JavaScript before reading this article.

‘this’ keyword

‘this’ keyword is one of the most commonly used and yet confusing keywords in JavaScript. This is where you will learn everything there is to know about this keyword. ‘this’ indicates a specific object. Which object is that depends on how a function with the ‘this’ keyword is called.

Strict notation

ECMAscript 5 adds a second operating mode, “strict mode,” in addition to the normal mode. This mode, as the name implies, makes Javascript run under more stringent conditions.

The following are the primary goals of establishing “strict mode”:

→Remove some unreasonable and imprecise aspects of Javascript syntax, as well as some strange behaviors;

→Remove some insecure aspects of code operation and ensure code operation safety

→Improve the compiler’s efficiency and speed of execution;

→Prepare the way for a future version of Javascript.

Function closure

A closure is a function that has been bundled together (enclosed) with references to its surrounding state. In other words, a closure provides access to the scope of an outer function from an inner function. Closures are created in JavaScript whenever a function is created.

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

Callbacks : When a function simply accepts another function as an argument, the function contained within it is referred to as a callback function. Callback functions are a fundamental functional programming concept that can be found in almost all JavaScript code, whether in simple functions like ‘setInterval’, event listening, or when making API calls.

promises : A promise is used to handle an operation’s asynchronous result. JavaScript is designed to not wait for an asynchronous block of code to complete before running other synchronous sections of code. For example, when making API requests to servers, we have no idea whether the servers are offline or online, or how long it takes for the server request to be processed.

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.

--

--