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
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.
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.
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.
The Single Responsibility Principle (SRP) is one of the 5 SOLID principles. These slides gives you an overview of the principle as well as a refactoring from a non-SRP code to a SRP-code.
SOLID Principles and The Clean ArchitectureMohamed Galal
This presentation is held at @blablaconnect Cairo office, Monday 31 December 2018.
In this presentation we will discuss the following topics:
- SOLID principles.
- Design Pattern vs. Clean Architecture.
- Successful software architecture characteristics.
- The Clean Architecture.
- Real life example.
What is Dependency Injection in Spring Boot | EdurekaEdureka!
YouTube Link: https://youtu.be/O9mqe53syGc
** Microservices Architecture Training: https://www.edureka.co/microservices-... **
This Edureka tutorial on "What is Dependency Injection" will give you an introduction to dependency injection and also show a practical implementation of dependency injection with Spring Boot.
In this PPT, you will learn the following:
What is Dependency Injection?
Inversion of Control
Types of Dependency Injection
Benefits of Dependency Injection
Implement Dependency Injection using Spring Boot
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
Welcome to presentation on Spring boot which is really great and relatively a new project from Spring.io. Its aim is to simplify creating new spring framework based projects and unify their configurations by applying some conventions. This convention over configuration is already successfully applied in so called modern web based frameworks like Grails, Django, Play framework, Rails etc.
"S"OLID Principles - Single responsibility principleNishant Upadhyay
This slides will explain you how to use SOLID principles, its benefit with Ruby code example. SOLID principle helps for designing your code in more better way.
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.
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
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.
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.
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.
The Single Responsibility Principle (SRP) is one of the 5 SOLID principles. These slides gives you an overview of the principle as well as a refactoring from a non-SRP code to a SRP-code.
SOLID Principles and The Clean ArchitectureMohamed Galal
This presentation is held at @blablaconnect Cairo office, Monday 31 December 2018.
In this presentation we will discuss the following topics:
- SOLID principles.
- Design Pattern vs. Clean Architecture.
- Successful software architecture characteristics.
- The Clean Architecture.
- Real life example.
What is Dependency Injection in Spring Boot | EdurekaEdureka!
YouTube Link: https://youtu.be/O9mqe53syGc
** Microservices Architecture Training: https://www.edureka.co/microservices-... **
This Edureka tutorial on "What is Dependency Injection" will give you an introduction to dependency injection and also show a practical implementation of dependency injection with Spring Boot.
In this PPT, you will learn the following:
What is Dependency Injection?
Inversion of Control
Types of Dependency Injection
Benefits of Dependency Injection
Implement Dependency Injection using Spring Boot
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
Welcome to presentation on Spring boot which is really great and relatively a new project from Spring.io. Its aim is to simplify creating new spring framework based projects and unify their configurations by applying some conventions. This convention over configuration is already successfully applied in so called modern web based frameworks like Grails, Django, Play framework, Rails etc.
"S"OLID Principles - Single responsibility principleNishant Upadhyay
This slides will explain you how to use SOLID principles, its benefit with Ruby code example. SOLID principle helps for designing your code in more better way.
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.
Writing Maintainable Software Using SOLID PrinciplesDoug Jones
Uncle Bob Martin (Robert C. Martin) conceptualized these 5 object oriented design principles (the SOLID principles) almost 20 years ago, yet they're just as applicable today. I'll walk through the SOLID principles and dependency injection, and offer a methodology that adheres to those principles that's worked well for me. I'll give you examples in .NET Core 2.0, but you'll find these timeless principles work in any language. Come enjoy a discussion away from the technology treadmill!
Design Principle and Design Pattern examples on C# .NET Core.
(Note: Not all the contents are original, I copied some of them from online tutorials while learning and found great explanations. A great thanks to all for this information.)
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.
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.
Generating a custom Ruby SDK for your web service or Rails API using Smithyg2nightmarescribd
Have you ever wanted a Ruby client API to communicate with your web service? Smithy is a protocol-agnostic language for defining services and SDKs. Smithy Ruby is an implementation of Smithy that generates a Ruby SDK using a Smithy model. In this talk, we will explore Smithy and Smithy Ruby to learn how to generate custom feature-rich SDKs that can communicate with any web service, such as a Rails JSON API.
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
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/
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.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
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
2. Agenda
What are SOLID?
Why should we care?
How can we apply SOLID principles?
◦ S – Single responsibility principle
◦ O – Open–closed principle
◦ L – Liskov substitution principle
◦ I – Interface segregation principle
◦ D – Dependency inversion principle
SOLID - TOAN NGUYEN
3. About me
Nguyen Huu Toan
Senior Dev – skype nguyentoanuit@gmail.com
SWGLayer team
https://app.kolekto.nl
SOLID - TOAN NGUYEN
4. What is SOLID?
“It is not enough for code to work.”
- Robert C. Martin
SOLID is five basic principles which help us write clean code
◦ Understandable
◦ Easier to maintain
◦ Easier to extend
The abbreviation SOLID was introduced by Michael Feathers
But the concept of SOLID principles were first introduced by Robert C. Martin
in his book, Design Principles and Design Patterns.
So let see how SOLID can help us be stronger
SOLID - TOAN NGUYEN
6. Why should we care?
Can we just make it work without following these principles?
Finish the business rules/PBI and delivery functionality to
client are our main task, why do we need to care about these
annoying rules/principles?
SOLID - TOAN NGUYEN
7. Why should we care?
Yes, of-course.
BUT..... the functionality that you create today has a good
chance of changing in the next release.
The more you care about good code today, the more you are
loved by your teammate later
SOLID - TOAN NGUYEN
8. Why should we care?
So I will make it work first and refactor later on?
SOLID - TOAN NGUYEN
9. Why should we care?
Yes, sure! But it will be very expensive.
SOLID - TOAN NGUYEN
10. Why should we care?
“People will forget how fast you did a job, but they remember
how well you did it!”
- iDev
SOLID - TOAN NGUYEN
11. How can we
apply SOLID
principles?
S – Single responsibility principle (SRP)
O – Open–closed principle (OCP)
L – Liskov substitution principle (LSP)
I – Interface segregation principle (ISP)
D – Dependency inversion principle (DIP)
SOLID - TOAN NGUYEN
12. S – Single responsibility principle
“A class should only have a single responsibility”
So that, a class should have one and only one reason to change.
SOLID - TOAN NGUYEN
13. S – Single responsibility principle
public class Production
{
public Guid Id { get; set; }
public string Title { get; set; }
public string ShortDescription { get; set; }
public string ImageUrl { get; set; }
public int RemainItems { get; set; }
public string CheckStatus()
{
if (RemainItems > 500)
{
return "There are a lot of remaining items";
}
else if (RemainItems <= 500 && RemainItems > 200)
{
return "Warning: We should buy more";
}
else
{
return "Red warning: We need by more";
}
}
}
SOLID - TOAN NGUYEN
Inventory
business
14. S – Single responsibility principle
public void SendEmail(EmailData emailData)
{
var email = new
{
from = emailData.From,
to = emailData.To,
message = emailData.Message
};
graph.sendEmail(email);
}
SOLID - TOAN NGUYEN
15. S – Single responsibility principle
SOLID - TOAN NGUYEN
public void SendEmail(EmailData emailData, bool generateAttachment)
{
var email = new GraphEmail
{
from = emailData.From,
to = emailData.To,
message = emailData.Message
};
if (generateAttachment)
{
var document = new
{
title = emailData.AttachmentName,
content = pdfGenerator.GeneratePDF(emailData.Message)
};
email.attachment = document;
}
graph.sendEmail(email);
}
Generate attachment is not
a job of send email function
16. Avoid violate SRP
1. Long method
2. Boolean flag
3. Class (service) serve many operations
4. Always ask why is the responsibility of class/service/module when extending
SOLID - TOAN NGUYEN
17. Benefits of SRP
1. Easy to follow/understand
2. Maintainable
3. Test easily
4. Easy to extend
SOLID - TOAN NGUYEN
23. Open–closed principle
As application grow up, a lot of new behaviors of the form will be added such as
◦ Handle dirty form
◦ Confirmed/warning message
◦ User only can view data, can’t make a change in the form
◦ Show overlay when data is loading
◦ more and more …..
SOLID - TOAN NGUYEN
26. Benefits of OCP
1. Reusable and maintainable
2. Avoid regression bugs
3. Extend easily and quickly
SOLID - TOAN NGUYEN
27. Avoid violate OCP
1. Using inheritance
2. Using Composition
3. Using interface
SOLID - TOAN NGUYEN
28. Liskov substitution principle
Let Φ(x) be a property provable about objects x of type T. Then Φ(y)should be true for
objects y of type S where S is a subtype of T.
Developer language
"Objects in a program should be replaceable with instances of their subtypes without
altering the correctness of that program.“
Related to???
Open – close principle
SOLID - TOAN NGUYEN
29. Liskov substitution principle
SOLID - TOAN NGUYEN
public class Airplane
{
public string Name { get; set; }
public virtual void TakeOff()
{
Console.WriteLine("Hello madam and gentleman, we are taking off");
}
public virtual void Landdown()
{
Console.WriteLine("Hello madam and gentleman, we are landing");
}
public virtual void Up()
{
Console.WriteLine("Air plane go up");
}
public virtual void Down()
{
Console.WriteLine("Air plane go down");
}
}
public class TraditionalAirPlane : Airplane
{ public TraditionalAirPlane()
{
Name = “Traditional one";
}
}
30. Liskov substitution principle
SOLID - TOAN NGUYEN
static void Main(string[] args)
{
var airPlane = new BoeingB52();
var pilot = new Pilot(airPlane);
pilot.HandleAirePlane();
}
31. Liskov substitution principle
SOLID - TOAN NGUYEN
public class SmartAirplane : Airplane
{
public bool AirPlaneUp { get; set; }
public bool OffAutoDetection { get; set; }
public SmartAirplane()
{
Name = "I am smart air plane" ;
}
public override void Up()
{
if (AirPlaneUp && !OffAutoDetection)
{
throw new System. Exception ("No worry, I will control it");
}
base.Up();
}
public void TurnOffAutoDetect()
{
OffAutoDetection = true;
}
}
32. Liskov substitution principle
SOLID - TOAN NGUYEN
static void Main(string[] args)
{
var airPlane = new SmartAirePlane ();
var pilot = new Pilot(airPlane);
airPlane.AirPlaneUp = true;
pilot.HandleAirePlane();
}
34. Avoid violate LSP
1. No easy way to detect the violation
2. Review code
3. Shouldn’t implement stricter validation than implementation of superclass
4. Shouldn’t break superclass behavior
5. Should run test case (unit test) for all subclass instances
SOLID - TOAN NGUYEN
40. Avoid violate ISP
1. Large interface (flat interface)
2. throw new NotImplementedException();
SOLID - TOAN NGUYEN
41. Dependency inversion principle
1. High-level modules should not depend on low-level modules. Both should depend on
abstractions.
2. Abstractions should not depend on details. Details should depend on abstractions.
Related to???
OCP & LSP
SOLID - TOAN NGUYEN
42. Benefits of DIP
Decoupling between
1. Abstractions and details
2. High level and low level
SOLID - TOAN NGUYEN
43. Distinguish between DIP, IoC and DI
1. DIP: Dependency inversion principle is about decoupling
2. IoC: Inversion of control is a design principle used by framework libraries that allow the
framework to regain and instance of class during program execution. Or could be referred by
"Hollywood Principle: Don't call us, we'll call you"
3. DI: Dependency Injection is an implementation of IoC. Another implementation of IoC is
service locator
SOLID - TOAN NGUYEN
It doesn't mean that a class should have one property and one method.
All the methods and properties should all work towards the same goal
Later, we need to check status of a production to decide buy more or not
Later we want to support send email with attachment
We have base form like this
So we can add more form like product, invoice without changing base form
How can se communicate between these components? => Pub/Sub pattern
Why we have interface here? If you think of application level, for example your application need support send email
1. we will implement email service which use graph api for example,
2. later we also need to support SendGrid as send mail service as well.
So by implement interface IEmailService we can extend application easily by don’t modify the service using graph api.
A company’s broken this rule and get a very big problem now. => Boeing
Easy to follow/understand
Maintainable
Test easily
The Open/Closed Principle required a software component to be open for extension, but closed for modification. You can achieve that by introducing interfaces for which you can provide different implementations. The interface itself is closed for modification, and you can easily extend it by providing a new interface implementation.
Your implementations should follow the Liskov Substitution Principle so that you can replace them with other implementations of the same interface without breaking your application.