0% found this document useful (0 votes)
1 views10 pages

OOPs and SOLID Principle Using Typescript 1740583851

The document outlines foundational concepts of Object-Oriented Programming (OOP) using TypeScript, including classes, objects, encapsulation, inheritance, polymorphism, and abstraction. It also introduces the SOLID principles which guide OOP design, focusing on single responsibility, open/closed, Liskov substitution, interface segregation, and dependency inversion principles. The content is structured to provide practical examples and applications of these concepts in real-world scenarios.

Uploaded by

Shreya Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views10 pages

OOPs and SOLID Principle Using Typescript 1740583851

The document outlines foundational concepts of Object-Oriented Programming (OOP) using TypeScript, including classes, objects, encapsulation, inheritance, polymorphism, and abstraction. It also introduces the SOLID principles which guide OOP design, focusing on single responsibility, open/closed, Liskov substitution, interface segregation, and dependency inversion principles. The content is structured to provide practical examples and applications of these concepts in real-world scenarios.

Uploaded by

Shreya Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

INDEX

Basics
Class
Object
Property (Attribute)
Method (Behavior)
Base Class (Superclass/Parent Class)
Derived Class (Subclass/Child Class)
Abstract Class
Interface

Core OOPs
Inheritance
Encapsulation
Polymorphism
Abstraction

SOLID Principles
Single Responsibility Principle (SRP)
Open/Closed Principle (OCP)
Liskov Substitution Principle (LSP)
Interface Segregation Principle (ISP)
Dependency Inversion Principle (DIP)

Notes Prepare By Suryansh


Email: [email protected]
Phone: +91-8791234693
Foundational OOP Concepts using TypeScript
1. Classes and Objects:
Understand what a class is (a blueprint for creating objects) and how to define them in
TypeScript. Pay attention to properties (data) and methods (functions that operate on the
data).
Learn how to create objects (instances of a class) using the new keyword.
Practice defining classes with different data types for properties and various method
signatures.

Classes and Objects (Real-world: E-commerce Product)


2. Encapsulation:
Learn how to control access to the properties and methods of a class using access
modifiers: public, private, and protected. Understand why encapsulation is important for
data integrity and code maintainability.
Practice creating classes where some properties are private and accessed through getter
and setter methods.

Encapsulation (Real-world: User Account)


3. Inheritance:
Understand the "is-a" relationship and how to create new classes (derived classes) that
inherit properties and methods from existing classes (base classes). Use the extends
keyword.
Learn about method overriding (providing a different implementation for a method in the
derived class).
Practice creating class hierarchies.

Inheritance (Real-world: Different Types of Employees)


4. Polymorphism:
Understand how objects of different classes can be treated as objects of a common type
(usually through an interface or abstract class).
Learn about interfaces in TypeScript and how they define contracts that classes can
implement.
Practice writing code that works with objects of different classes through a common
interface.

Polymorphism (Real-world: Payment Processing)


5. Abstraction:
Abstraction is a fundamental concept in object-oriented programming (OOP) that simplifies
complex systems by focusing on essential characteristics and hiding unnecessary details. It
allows you to work with objects at a higher level of understanding, without needing to know
all the intricate implementation details.

Abstraction (Real-world: Drawing application


Consider a drawing application. You might have an abstract class Shape with
methods like draw(), move(), and resize(). Then, you could have concrete subclasses
like Circle, Rectangle, and Triangle that inherit from Shape and provide specific
implementations for these methods. The user of the drawing application can then
work with Shape objects without needing to know the specific type of shape they are
dealing with. This simplifies the design of the application and makes it easier to add
new shapes in the future.

How Abstraction is Achieved in OOP:


Abstract Classes: An abstract class cannot be instantiated directly. It serves as a
blueprint for creating concrete subclasses. Abstract classes can contain abstract
methods (methods without a body), which must be implemented by the
subclasses. Abstract classes are used to represent abstract concepts or
categories.
Interfaces: An interface defines a contract that classes can implement. It specifies a set of
methods that a class must implement. Interfaces do not provide any implementation details.
They are used to define a common set of behaviors that different classes can share.
SOLID Principle
Single Responsibility Principle (SRP): Decoupling responsibilities into separate classes.
Improves maintainability and testability.

Open/Closed Principle (OCP): Extending functionality without modifying existing code.


Promotes flexibility and reduces risk of introducing bugs.
Liskov Substitution Principle (LSP): Ensuring that derived classes can be used
interchangeably with base classes. Maintains correct program behavior.

Interface Segregation Principle (ISP): Creating smaller, more specific interfaces. Avoids forcing
classes to implement unnecessary methods.
Dependency Inversion Principle (DIP): Depending on abstractions rather than concrete
implementations. Increases flexibility and testability.

SOLID Principles (Guiding OOP Design)

You might also like