The document discusses the principles of object oriented class design known as SOLID principles, which are Single Responsibility Principle (SRP), Open Closed Principle (OCP), Liskov Substitution Principle (LSP), Interface Segregation Principle (ISP), and Dependency Inversion Principle (DIP). It provides examples and explanations of each principle, with SRP focusing on a single responsibility, OCP on extension without modification, LSP on substitutability of subclasses, ISP on specific interfaces over general interfaces, and DIP on depending on abstractions rather than concretions.
The theory of SOLID principles was
introduced by Robert C. Martin in his 2000
paper “Design Principles and Design
Patterns”.
SOLID => Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion.
The theory of SOLID principles was
introduced by Robert C. Martin in his 2000
paper “Design Principles and Design
Patterns”.
SOLID => Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion.
Learning solid principles using c#
S Single Responsibility Principle
O Open Closed Principle
L Liskovs Substitution Principle
I Interface Segregation Principle
D Dependency Inversion principle
This presentation is based on a blog post I made:
http://eyalgo.com/2014/02/01/the-single-responsibility-principle/
More details are in that blog post.
I had a presentation at work with these slides.
SOLID Design Principles applied in JavaIonut Bilica
Video: https://www.youtube.com/watch?v=0cU-4LrcWI0
SOLID Design Principles applied in Java: rules to develop scalable and easily maintainable code
Speaker: Ionut Bilica - Senior Software Developer @ Luxoft Romania.
During this talk we will discuss about the SOLID Principles described by Robert C. Martin, applying them in the Java programming language. Each principle will be explained in detail, with practical Java examples.
We will asses how these principles make it easy to develop the software for the entire duration of the project, and how some problems can appear if these principles are not applied. We will present common code fragments that do not respect these principles, and we'll see how we can correct them. Taking the SOLID principles into consideration, we will also analyse a real Java project using a Static Code Analyzer tool (e.g. STAN).
Finally, we will discuss the strategies on how to apply these design principles in "greenfield" projects, as well as "legacy" projects, while offering some tips and tricks.
Introduction to Design Patterns and SingletonJonathan Simon
This is Class 1 on a 6 week course I taught on Software Design Patterns.
This course provides an introduction into Design Patterns and delves into the Singleton Pattern.
Class based on "Head First Design Patterns."
JavaScript Module Patterns: How to build and use JavaScript modules. We cover the Basic Module Pattern, Revealing Module Pattern, CommonJS, AMD, CommonJS, UMD and ES6 modules.
During this talk we will discuss about the SOLID Principles described by Robert C. Martin, applying them in the Java programming language. Each principle will be explained in detail, with practical Java examples.
We will assess how these principles make it easy to develop the software for the entire duration of the project, and how some problems can appear if these principles are not applied. We will present common code fragments that do not respect these principles, and we'll see how we can correct them. Taking the SOLID principles into consideration, we will also analyse a real Java project using a Static Code Analyzer tool (e.g. STAN).
Finally, we will discuss the strategies on how to apply these design principles in "greenfield" projects, as well as "legacy" projects, while offering some tips and tricks.
Learning solid principles using c#
S Single Responsibility Principle
O Open Closed Principle
L Liskovs Substitution Principle
I Interface Segregation Principle
D Dependency Inversion principle
This presentation is based on a blog post I made:
http://eyalgo.com/2014/02/01/the-single-responsibility-principle/
More details are in that blog post.
I had a presentation at work with these slides.
SOLID Design Principles applied in JavaIonut Bilica
Video: https://www.youtube.com/watch?v=0cU-4LrcWI0
SOLID Design Principles applied in Java: rules to develop scalable and easily maintainable code
Speaker: Ionut Bilica - Senior Software Developer @ Luxoft Romania.
During this talk we will discuss about the SOLID Principles described by Robert C. Martin, applying them in the Java programming language. Each principle will be explained in detail, with practical Java examples.
We will asses how these principles make it easy to develop the software for the entire duration of the project, and how some problems can appear if these principles are not applied. We will present common code fragments that do not respect these principles, and we'll see how we can correct them. Taking the SOLID principles into consideration, we will also analyse a real Java project using a Static Code Analyzer tool (e.g. STAN).
Finally, we will discuss the strategies on how to apply these design principles in "greenfield" projects, as well as "legacy" projects, while offering some tips and tricks.
Introduction to Design Patterns and SingletonJonathan Simon
This is Class 1 on a 6 week course I taught on Software Design Patterns.
This course provides an introduction into Design Patterns and delves into the Singleton Pattern.
Class based on "Head First Design Patterns."
JavaScript Module Patterns: How to build and use JavaScript modules. We cover the Basic Module Pattern, Revealing Module Pattern, CommonJS, AMD, CommonJS, UMD and ES6 modules.
During this talk we will discuss about the SOLID Principles described by Robert C. Martin, applying them in the Java programming language. Each principle will be explained in detail, with practical Java examples.
We will assess how these principles make it easy to develop the software for the entire duration of the project, and how some problems can appear if these principles are not applied. We will present common code fragments that do not respect these principles, and we'll see how we can correct them. Taking the SOLID principles into consideration, we will also analyse a real Java project using a Static Code Analyzer tool (e.g. STAN).
Finally, we will discuss the strategies on how to apply these design principles in "greenfield" projects, as well as "legacy" projects, while offering some tips and tricks.
Die SOLID Prinzipien gehören heutzutage zum festen Handwerkszeug eines jeden Clean Code Developers. Java 8 enthält großartige Neuerungen und Sprach-Features, die aus der Sicht der SOLID-Prinzipien beleuchtet werden. Sie werden erfahren, in welchen Bereichen die Sprache uns Entwickler noch besser unterstützt und wie die JDK-Designer ihrerseits die SOLID-Prinzipien berücksichtigt haben.
Gehen Sie mit mir auf einen Streifzug durch die Java 8 Welt und lernen Sie die neuen Sprachfeatures SOLIDe kennen.
List of Software Development Model and MethodsRiant Soft
RiantSoft a Software Development Company derived the most useful and different types of Software Development Model for the users who want to know the development process. RiantSoft is specialized in custom software development with latest cutting edge technologies.
The maze of Design Patterns & SOLID PrinciplesMuhammad Raza
There are several mistakes usually developers make during product development. So keeping your demand of how to optimize time and resources so that there should be the least scope of errors and bugs we brought a demanding topic for you. This talk will cover the best practices that should be involved in web development and if you are adopting them your code will project you more experienced than an experienced developer.
An Introduction to the SOLID PrinciplesAttila Bertók
SOLID Principles are the most important principles of writing maintainable, easy-to-read, easy-to-write clean code. This presentation attempts to give a basic overview of these principles with some examples of violations and ways to correct them.
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...Raffi Khatchadourian
Java 8 is one of the largest upgrades to the popular language and framework in over a decade. In this talk, I will first overview several new, key features of Java 8 that can help make programs easier to read, write, and maintain, especially in regards to collections. These features include Lambda Expressions, the Stream API, and enhanced interfaces, many of which help bridge the gap between functional and imperative programming paradigms and allow for succinct concurrency implementations. Next, I will discuss several open issues related to automatically migrating (refactoring) legacy Java software to use such features correctly, efficiently, and as completely as possible. Solving these problems will help developers to maximally understand and adopt these new features thus improving their software.
In computer programming, SOLID (single responsibility, open-closed, Liskov substitution, interface segregation and dependency inversion) is a mnemonic acronym introduced by Michael Feathers for the "first five principles" named by Robert C. Martin - principles of object-oriented programming and design.
Similar to principles of object oriented class design (20)
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
4. Good class design
• Represents any real world entity
• Better code readability/ understanding
• Loosely coupled with other classes
• Compact & Optimized
• Easily testable
5. Single Responsibility Principle (SRP)
• One responsibility.
• One, and only one, reason to change.
• Change in the class should not force
programmers to change into other classes.
• BankAccount class- Example
6. Single Responsibility Principle (SRP) - Example
Class BankAccount{
private double bal; //setters & getters
public String getCurrentBalanceInRupees (){…}
public String getCurrentBalanceInUSD(){…}
public double getBalance(){
//return balance in round figures upto 2 decimals}
public double debit (double amount){…}
//how to handle diff.currency addition
public double credit (double amount){…}
//so on
}
7. Single Responsibility Principle (SRP)-Responsibility
• Responsibility of Bank Account class
▫ Currency conversion
▫ Checking currency for addition & subtraction
▫ Rounding-off the balance
▫ Debit the amount
▫ Credit the amount
▫ Details of account holder
▫ Transaction history
▫ //so on…
8. Single Responsibility Principle (SRP) - Solution
Class Money{
private double value;
private String currencyType; //setters & getters
public double getValue (){
//convert money value according to currencyType
// class currency converter
//round-off value upto 2 decimals
}
public double addMoney(Money amount){…}
public double subtractMoney(Money amount){…}
}
9. Single Responsibility Principle (SRP) - Solution
Class BankAccount{
private Money balance; //setters & getters
public double getBalance (){…}
public double debit (Money amount){
//call balance.addMoney(amount)…}
public double credit (Money amount){
//call balance.subtractMoney(amount)…}
}
10. Single Responsibility Principle (SRP)-Responsibility
• Responsibility division for BankAccount class
▫ CurrencyConverter Class – Currency conversion
▫ Money Class – Check currency for addition or
subtraction
▫ BankAccount class – Debit/Credit the amount
▫ Details of account holder – Person class
▫ Transaction history – TransactionHistory class
▫ //so on…
12. So, What is Single Responsibility Principle (SRP)?
13. Open Closed Principle (OCP)
• Open for Extension and closed for Modification.
• Don’t change existing code or classes.
• Add new functionality by adding new subclasses or
methods, or by reusing existing code through delegation.
Advantage:
• Prevents you from introducing new bugs in existing
code.
14. Open Closed Principle (OCP) - Example
Polymorphism for conforming to the OCP:
void LogOn (Modem m, string user, string pw)
{
if (m instanceOf Hayes)
DialHayes((Hayes)m, user);
else if (m instanceOf courrier)
DialCourrier((Courrier)m, user);
else if (m instanceOf ernie)
DialErnie((Ernie)m, user)
// ...so on
}
15. Open Closed Principle (OCP) - Example
Consider the class design something like this:
Here LogOn has been closed for modification.
16. Open Closed Principle (OCP) - Example
Abstract Class Modem{
Void Dial(String s);
Void send(Char c);
Char recv();
Void HangUp();
Void LogOn(Modem m, string user, string pw)) {
m.Dial();
}
}
Here LogOn method conforms to the OCP. Its behavior can be
extended without modifying it.
17. Open Closed Principle (OCP)
Goals of OCP:
• Create modules that are extensible, without being
changed.
• Use Unit tests if you are adding in the existing code
20. Liskov Substitution Principle (LSP)
The LSP applies to inheritance hierarchies.
• It specifies that you should design your classes so that client
dependencies can be substituted with subclasses.
• All subclasses must, therefore, operate the same manner as their
base classes.
• The specific functionality of the subclass may be different but must
conform to the expected behavior of the base class.
• To be a true behavioral subtype, the subclass must not only
implement the base class' methods and properties but also conform
to its implied behavior.
21. Liskov Substitution Principle (LSP)
It helps to get answers of following questions:
• Provides the design rules that govern the particular use
of inheritance.
• Characteristics of the best inheritance hierarchies
22. Liskov Substitution Principle (LSP) - Definition
• If for each object o1 of type S
S o1 = new S();
and,
there is an object o2 of type T
T o2 = new T();
such that
for all programs P defined in terms of T, the behavior of P is
unchanged when o1 is substituted for o2 then S is a subtype
of T.
23. Liskov Substitution Principle (LSP)
• Subtypes must be substitutable for their base types.
• In simpler version,
▫ Functions that use pointers or references to base classes
must be able to use objects of derived classes without
knowing it.
The canonical example is the Rectangle/Square dilemma.
24. Liskov Substitution Principle (LSP)
Class Rectangle{
int length, breadth;
void setLength(){…}
void setBreadth(){…}
}
Class Square extends Rectangle{
void setLength(int a){ // similarly for setBreadth
Super.setLength(a);
Super.setBreadth(a);
}
}
25. Liskov Substitution Principle (LSP)
Consider the following function:
void func(Rectangle r){
r.SetLength(20);
r.SetBreadth(32);
}
26. Liskov Substitution Principle (LSP)
• Ugly fix for LSP violation for Rectangle & Square
void f(Shape shape){
If(shape instanceOf Rectangle){
//call funcForRectangle();
} else {
//call funcForSquare();
}
}
which rule is violating here??
28. Why is the LSP important?
• Because if not, then class hierarchies would be a
mess.
▫ Mess being that whenever a subclass instance was
passed as parameter to any method, strange
behavior would occur.
• It provides the design rules that govern the particular
use of inheritance, and Characteristics of the best
inheritance hierarchies
30. So, What is Liskov Substitution Principle (LSP)??
31. Interface Segregation Principle (ISP)
• Many client specific interfaces are better than one
general purpose interface.
• The clients should not be forced to implement interfaces
they don't use.
▫ Instead of one fat interface many small interfaces are
preferred based on groups of methods, each one serving one
sub-module.
32. Interface Segregation Principle (ISP)
The methods needed by each client are placed in single interface that are
specific to the client.
Fat Service with Integrated Interfaces
33. Interface Segregation Principle (ISP)
The methods needed by each client are placed in special interfaces that are
specific to that client.
Segregated Interfaces
34. Interface Segregation Principle (ISP)
How would you handle if two clients have some common
methods?
Something like:
Client A – method1, method2, method3, method4
&
Client B – method1 , method2, method5, method6
35. Interface Segregation Principle (ISP) - Example
• Manager class – Represent the person which manages the workers.
• 2 types of workers – They can work & need daily lunch break to eat.
▫ some average, and
▫ some very efficient workers.
• But now some robots came in the company they work as well , but
they don't eat so they don't need a lunch break.
• One on side the new Robot class need to implement the IWorker
interface (work() & eat()) because robot works. On the other side,
the don't have to implement it because they don't eat.
36. Interface Segregation Principle (ISP) - Example
// interface segregation principle - bad example
interface IWorker {
public void work();
public void eat();
}
class Worker implements IWorker{
public void work() {
// ....working
}
public void eat() {
// ...... eating in lunch break
}
}
37. Interface Segregation Principle (ISP) - Example
class SuperWorker implements IWorker{
public void work() { //.... working much more}
public void eat() { //.... eating in lunch break}
}
class Manager {
IWorker worker;
public void setWorker(IWorker w) {
worker=w;
}
public void manage() {
worker.work();
}
}
38. Interface Segregation Principle (ISP) - Solution
// interface segregation principle - good example
interface IWorkable {
public void work();
}
interface IEatable{
public void eat();
}
39. Interface Segregation Principle (ISP) - Solution
class Worker implements IWorkable, IEatable{
public void work() {
// ....working
}
public void eat() {
// ...... eating in launch break
}
}
class SuperWorker implements IWorkable, IEatable{
public void work() { //.... working much more}
public void eat() { //.... eating in launch break}
}
40. Interface Segregation Principle (ISP) - Solution
class Robot implements IWorkable {
public void work() { //.... working}
}
class Manager {
IWorkable worker;
public void setWorker(IWorkable w) {
worker=w;
}
public void manage() {
worker.work();
}
}
42. So, What is Interface Segregation Principle (ISP)?
43. Dependency Inversion Principle (DIP)
• Depend upon Abstractions. Do not depend upon
concretions.
• In other words, it is the strategy of depending upon
interfaces or abstract functions & classes, rather than
upon concrete functions & classes.
• High level modules should not depend upon low-level
modules. Both should depend upon abstractions.
44. Dependency Inversion Principle (DIP) - Example
Example: ATM & Bank Account
Class ATM{
private BankAccount ba = new BankAccount();
public String displayBalance(){
return “ Your balance is: ” + ba.currentBalance();
}
}
45. Dependency Inversion Principle (DIP) - Example
Class BankAccount{
private Double bal; //setters & getters
public String currentBalance (){
return bal.toString();
}
}
46. Dependency Inversion Principle (DIP) - Solution
Solution: Use Interfaces
Because the dependency of one class to another one
should depend on the smallest possible interface.
47. Dependency Inversion Principle (DIP) - Solution
1) BankAccount Interface
Public Interface BankAccount{
public String currentBalance ();
}
2) StubBankAccount class
Class StubBankAccount implements BankAccount{
public String currentBalance (){
return “3000”;
}
}
48. Dependency Inversion Principle (DIP) - Solution
3) Implementation of BankAccount class
Class BankAccountImpl implements BankAccount
{
public String currentBalance (){
Your balance is: ” + ba.currentBalance();
}
}
49. Dependency Inversion Principle (DIP) - Solution
4) Class ATM{
private BankAccount ba;
ATM(BankAccount ba){
this.ba = ba;
}
public String displayBalance(){
return “ Your balance is: ” + ba.currentBalance();
}
}
50. Dependency Inversion Principle (DIP) - Solution
5) Class ATMTest{
@Test
public void shouldDisplayTheBalance(){
StubBankAccount sba = new StubBankAccount();
ATM atm = new ATM(sba);
assertEquals( “ Your balance is: 3000”,
atm.displaybalance());
}
}
51. Dependency Inversion Principle (DIP) - Solution
5) Class SomeClassUsingATM{
BankAccountImpl ba = new BankAccountImpl();
ATM atm = new ATM(ba);
sopln (atm.displayBalance());
}
52. Dependency Inversion Principle (DIP)
• What Inversion means in DIP??
▫ It is primarily about reversing the conventional direction
of dependencies from "higher level" components to "lower
level" components such that "lower level" components are
dependent upon the interfaces owned by the "higher level"
components.
53. Dependency Inversion Principle (DIP) - Advantage
• Choose which implementation is better suited for your
particular environment
• Either at compile time in the application, or
• At the runtime by configuration.
• Simplifies the unit testing.
• Loosely coupled design.
54. Inversion Of Control (IOC)
• Inversion of Control is a design pattern where an Objects
gets handed its dependency by an outside framework,
rather than asking a framework for its dependency.
• The benefits of IoC are:
▫ You have no dependency on a central framework, so this
can be changed if desired.
▫ Since objects are created by injection, preferably using
interfaces, it's easy to create unit tests that replace
dependencies with mock versions.
▫ Decoupling off code.
55. Inversion Of Control (IOC)
• The "inversion" in DIP is not the same as in Inversion of
Control.
▫ The first one is about compile-time dependencies,
while the second one is about the flow of control between
methods at runtime.
57. So, What is Dependency Inversion Principle (DIP)?
58. Summary
Principles of class design (aka SOLID):
• Single Responsibility Principle (SRP)
▫ Create as many classes you want but
They should follow some real world entity
And have single responsibility
• Open Closed Principle (OCP)
▫ Open for Extension, Closed for Modification
59. Summary
• Liskov Substitution Principle (LSP)
▫ Object of derived class can be passed instead of
object of base class without changing the behavior
of program.
• Interface Segregation Principle (ISP)
▫ Create multiple client specific interface rather
than creating single interface for multiple clients.
60. Summary
• Dependency Inversion Principle (DIP)
▫ It is the strategy of depending upon interfaces or abstract
functions and classes, rather than upon concrete functions
and classes