Industry Practices and Principles in Software Engineering & an Introduction to JavaScript

Thilini Herath
6 min readFeb 26, 2022

SOLID PRINCIPLES

In software engineering, SOLID is a mnemonic acronym for five design principles intended to make software designs more understandable, flexible, and maintainable.

SOLID Principles

01. Single responsibility principle (SRS)

“A class should have one, and only one, reason to change.”

The first principle of SOLID was developed by Robert Martin. Only one responsibility can be assigned to a class or actor. This enables the developer to write code with fewer errors and improve the development speed.

However, if the class’s responsibility is changed, the class must be changed as well. This is simply due to the fact that each class has its own set of responsibilities. A change in one class has no effect on another.

02) Open/close principle (OCP)

“Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification.”

Developing software entities that can have their behavior modified without having to rewrite and recompile the code.

When developers change the current code of a class, the subclasses of that class are affected. That might be a problem. As a result, applying this principle can help to avoid this issue.

03) Liskov substitution principle

“Any object in a subclass should be substitutable with the superclass object from which it is derived.”

This principle specifies that subclass objects should behave in the same way as their parent classes’ objects. Assume that there is a baby duck and a genuine duck, as depicted in the above Figure. The baby duck has all of the characteristics of a real duck.

04) Interface segregation principle

“Clients should not be exposed to methods that they do not require.”

Any software solution should be clear and understandable. If a class, interface, or feature appears to be complicated, it is likely to be difficult to understand, and customers may be disappointed. As a result, it is preferable if the developers create a solution (software design) that is clear and concise.

05) Dependency inversion principle

“High-level modules should not depend on low-level modules; instead, both should depend on abstractions.”

The dependency inversion principle is implemented by creating a layer of abstraction between the high-level policy and the low-level details. This abstraction decouples the policy’s core functionality from its direct dependence on the details, allowing for simpler re-use.

We try to find a technical solution for a business problem in software engineering.

Think throughout the problem

Think through the problem before reaching the solution or even starting to think about it.

Divide and conquer

Break the problem down into smaller parts. And make it manageable and simple to comprehend.

KISS

Keep it simple and stupid

Learn, especially from mistakes

Accept the change. Always try to anticipate as many changes as possible.

Always remember why software exists

Keep in mind why this software exists in the first place.

Remember that you are not the user

The end user does not have the same technological capabilities as you. Don’t assume the user knows what you’re talking about. User friendliness and experience are important.

PRACTICES

Practices are standards or principles that we should follow when developing code.

Unit testing

Unit testing is a software development technique in which the smallest testable parts of a program, referred to as units, are checked separately and independently for proper operation. Software developers and, on occasion, QA employees use this testing methodology during the development process.

Code quality

Quality code should always be: Easy to understand (readability, formatting, clarity, well-documented) Easy to change (maintainability, extensibility)

Code review

The act of actively and methodically gathering with one’s fellow programmers to review each other’s code for problems, also known as Peer Code Review, has been proved to speed and streamline the process of software development like few other methods can.

Version controlling

The method of tracking and controlling changes to software code is known as version control. In a special type of database, version control software keeps track of every modification to the code.

Continuous integration

A software development practice in which developers merge their code changes into a central repository on a regular basis before running automated builds and testing.

JavaScript

Introduction

JavaScript is a lightweight, cross-platform, interpreted scripting language. It’s most recognized for web page development, but it’s also utilized in a variety of non-browser applications. Both client-side and server-side development is possible with JavaScript. A standard object library, such as Array, Date, and Math, is included in JavaScript, as well as a basic set of language components including operators, control structures, and statements.

Classes, objects, and prototype

Classes are used to create things as a starting point. They encase data in code so that they can manipulate it. Although JS classes are prototype-based, they have some syntax and semantics that are not shared with ES5 class-like semantics.

Objects-The most significant data type in JavaScript is objects, which serve as the foundation for modern JavaScript. These objects differ from JavaScript’s primitive data-types (Number, String, Boolean, null, undefined, and symbol) in that they store many values, whereas the primitive data-types only store one (depending on their types).

How ‘this’ acts

The value of this is usually decided by how a function is invoked (runtime binding). It cannot be set during execution by assignment, and it may change each time the function is invoked. The bind() method was introduced in ES5 to set the value of a function regardless of how it was called, while arrow functions that don’t offer their own binding were introduced in ES2015.

Strict notation

Strict mode alters the standard semantics of JavaScript in various ways:
Converting some JavaScript silent errors to throw errors removes them. Corrects flaws that make JavaScript engines work harder to optimize: It is sometimes possible to make tight mode code run quicker than non-strict mode code. Some syntax that will most likely be defined in future ECMAScript versions is forbidden.

Function closure

A closure is a function that has been packed (wrapped) with references to the state of its environment (the lexical environment). In other words, a closure allows an inner function to access the scope of an outside function. When a function is formed in JavaScript, closures are produced at the same time as the function.

Callbacks and promises

The print () method takes another function as a parameter and calls it inside the callback function. In JavaScript, this is correct. When another function has finished, a callback function can be executed.

The built-in method “setTimeOut” in JavaScript calls a function or evaluates an expression after a set amount of time has passed (in milliseconds).

A Promise is a JavaScript object that contains a value that may or may not be accessible when the code line is executed. At some point in the future, these values will be rectified. It helps you to build more synchronous asynchronous code.

MongoDB

MongoDB is a cross-platform document-oriented database program that is open source. MongoDB is a NoSQL database application that works with JSON-like documents and optional schemas.

Git Version Control System

Git is a free and open source distributed version control system that can handle everything from small to very large projects with speed and efficiency. Linus Torvalds invented Git in order to continue the development of the Linux kernel.

--

--

Thilini Herath

BSc (Hons) in Information Technology Specializing in Software Engineering undergraduate at SLIIT