OOP - Object Oriented Principle
Abstraction, Polymorphism, Encapsulation and Inheritance are the 4 OOPS principles
Abstraction - Refers to the process of exposing only the relevant and essential data to the users without showing unnecessary information.
Polymorphism - Allows you to use an entity in multiple forms.
There are two types of polymorphism
1. Static polymorphism (Compile Time): Overloading
2. Dynamic polymorphism (Run Time): Overriding
Encapsulation - Prevents the data from unwanted access by binding code and data in a single unit called object.
Inheritance - Promotes the reusability of code and eliminates the use of redundant code. It is the property through which a child class obtains all the features defined in its parent class. When a class inherits the common properties of another class, the class inheriting the properties is called a derived class and the class that allows inheritance of its common properties is called a base class.
In simple language
Encapsulation is the bundling of data, including the methods that operate on that data, into a single, private unit
Polymorphism is the ability of a type to take on many forms using a single interface
Abstraction is the concealment of unnecessary program details so that the user only sees the essential attributes
Inheritance is the process where one class derives (or inherits) its attributes and methods from another
SOLID acronym:
Single Responsibility Principle: A class should have only a single responsibility
Open-Closed Principle: A class should be open extension for closed for extension
Liskov Substitution Principle:
Objects of a parent class should be replaceable with objects of its child class without breaking the application
Interface Segregation Principle: It is advisable to have multiple smaller interfaces rather than having a single big interface
Dependency Inversion Principle:
High level modules should not depend on low level modules; both should depend on abstractions.
Abstractions should not depend on details. Details should depend upon abstractions.
Program to interface, not to an implementation
Method overriding always needs inheritance.
In method overloading, methods must have the same name and different signatures.
Overriding occurs when the method signature is the same in the superclass and the child class.
Overriding is run-time/dynamic polymorphism
Method overloading may or may not require inheritance
In method overriding, methods must have the same name and same signature.
Overloading occurs when two or more methods in the same class have the same name but different parameters.
Overloading is compile-time/static polymorphism
GET - Retrieve information about the resource
POST - Create a resource
PUT - Update a resource
PATCH - Partial update a resource
DELETE - Delete a resource or related component
1XX - Informational
2XX - Success
3XX - Redirection
4XX - Client error
5XX - Server error
200 (Success/OK)
201 (Created)
204 No Content
301 (Permanent Redirect)
302 (Temporary Redirect)
304 (Not Modified)
404 (Bad Request)
401 (Unauthorized Error)
403 (Forbidden)
404 (Not Found)
500 (Internal Server Error)
501 (Not Implemented)
Serialization is the process of converting an object into a stream of bytes for storage on a memory, database, or file. This allows the developer to save the state of an object for future reference.
Converting an Object in memory to storable or transportable format.
Dependency is design pattern in which, Instead of creating the dependencies inside the dependent class we provide them as injection
Advantages
To achieve Loose Coupling between classes and its dependencies
Independently developable testable
Improves code reusability.
Eases the unit testing of applications through mocking/stubbing injected dependencies.
Reduces boilerplate code because dependencies are initialized by their injector component.
Makes it easier to extend the application classes.
Two developers can independently develop classes that use each other, while only needing to know the interface the classes will communicate through.
There are mainly three types of dependency injection
Constructor Injection
Methods Injection
Property injection
Microservice advantages
Microservices architecture allows cross-functional teams to develop, test, problem-solve, deploy, and update services independently, which leads to faster deployment and troubleshooting turnaround times.
Microservices are independently deployable and allow for more team autonomy
Microservices are independently scalable.
Microservices reduce downtime through fault isolation.
The smaller codebase enables teams to more easily understand the code, making it simpler to maintain.
Microservices disadvantages
communication between services can be complex.
debugging becomes more challenging with microservices.
while unit testing may be easier with microservices, integration testing is not
Up-front costs may be higher with microservices
Abstract
An abstract class allows you to create functionality that subclasses can implement or override.
Abstract can have both abstract and concrete methods
An abstract class is a good choice if we are using the inheritance concept since it provides a common base class implementation to derived classes.
If we want to provide common, implemented functionality among all implementations of our component, use an abstract class. Abstract classes allow us to partially implement our class, whereas interfaces contain no implementation for any members.
Interface
An interface only allows you to define functionality, not implement inside it.
Interface is pure form of Abstraction, only abstract methods not implementation
If the functionality we are creating will be useful across a wide range of disparate objects, use an interface. Abstract classes should be used primarily for objects that are closely related, whereas interfaces are best suited for providing a common functionality to unrelated classes.
Interfaces are also good when we want to have something similar to multiple inheritances since we can implement multiple interfaces.
SOAP
Transports data in standard XML format.
Because it is XML based and relies on SOAP, it works with WSDL
Works over HTTP, HTTPS, SMTP, XMPP
Highly structured/typed
Designed with large enterprise applications in mind
REST
Generally transports data in JSON. It is based on URI. Because REST follows stateless model, REST does not enforces message format as XML or JSON etc.
It works with GET, POST, PUT, DELETE
Works over HTTP and HTTPS
Less structured -> less bulky data
Designed with mobile devices in mind
Value type if it holds a data value within its own memory space. It means the variables of these data types directly contain values. Value Types are stored on Stack
Example, int i = 100;
Reference type doesn't store its value directly. Instead, it stores the address where the value is being stored. In other words, a reference type contains a pointer to another memory location that holds the data. Reference Types are stored on Heap
Example, string s = "Hello World!";
Cohesion represents the relationship within a module.
Coupling represents the relationships between modules.
Increasing cohesion and decreasing coupling is good for software.
Typescript is a superset of Javascript.
Typescript ensures type safety; it has a Type system. It is introduced and developed by microsoft
Typescript needs to be compiled to Javascript for the browser to understand it. This process is called transpilation
Typescript uses concepts like types and interfaces to describe data being used whereas JavaScript has no such concept.
Typescript provides optional static typing, classes, and interface.
Typescript is an object oriented language(not Pure)
Typescript has support for modules and interfaces
Typescript has better code structuring and object-oriented programming techniques and easy to maintain for large projects
Typescript allows better development time tool support
Typescript can extend the language beyond the standard decorators, async/await