This document provides an overview and examples of the SOLID principles of object-oriented design:
- SRP (Single Responsibility Principle) states that a class should have one, and only one, reason to change. Examples show extracting validation and email sending logic into separate classes.
- OCP (Open-Closed Principle) states that software entities should be open for extension but closed for modification. Examples use inheritance and interfaces to add new filtering logic without modifying existing classes.
- LSP (Liskov Substitution Principle) states that subclasses must be substitutable for their base classes. Examples show invalid implementations that break the base class contract.
- ISP (Interface Segregation Principle
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
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
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 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 nedir, neden solid ilkelerine uymak gerekir, temel olarak solid prensipleri bizler için neyi ifade eder sorularını cevaplıyoruz.
Daha temiz, güzel kodları nasıl yazabileceğimizi, uygulamalarımızı uzun vadede daha rahat geliştirmeniz için gerekli olan bu yöntemi iyi kavrayarak uygulamak; sizlere zamandan tasarruf sağlayacağı gibi, daha hızlı geliştirme yapmanıza da olanak sağlayacaktır.
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.
in these slides i have explained the Abstract Factory Design pattern. slides includes definition, explanation and then implementation by code examples.
Travel insurance is insurance that is intended to cover medical expenses for buy: http://www.insuringindia.com/general-insurance/travel/travel-home.aspx
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 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 nedir, neden solid ilkelerine uymak gerekir, temel olarak solid prensipleri bizler için neyi ifade eder sorularını cevaplıyoruz.
Daha temiz, güzel kodları nasıl yazabileceğimizi, uygulamalarımızı uzun vadede daha rahat geliştirmeniz için gerekli olan bu yöntemi iyi kavrayarak uygulamak; sizlere zamandan tasarruf sağlayacağı gibi, daha hızlı geliştirme yapmanıza da olanak sağlayacaktır.
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.
in these slides i have explained the Abstract Factory Design pattern. slides includes definition, explanation and then implementation by code examples.
Travel insurance is insurance that is intended to cover medical expenses for buy: http://www.insuringindia.com/general-insurance/travel/travel-home.aspx
The Role of Retention Time in Untargeted MetabolomicsJan Stanstrup
This presentation is about why retention time is important in untargeted metabolomics and how it can be used to identify compounds without having access to standards.
We will be talking about the single responsibility principle.
We are taught in various courses and books that SRP is important and it's the first thing that you have to do when you want to write good quality code. Despite this, nobody seems to agree on what a piece of code that respects the single responsibility principle should look like.
This is what we will be discussing today, how to recognize clean code, and how to bring our code in line (with examples).
bahan ini disediakan sendiri oleh pelajar sebagai bahan pembentangan di dalam kuliah. semoga bahan ini bermanfaat untuk kegunaan semua. boleh dijadikan sebagai bahan rujukan dan nota ringkas
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.
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...Iakiv Kramarenko
***VIDEO***: view in SD at http://youtu.be/HPHKeBakulQ or download in HD at http://bit.ly/1nyvA67
Often we have lack of automation resources. If we just would involve less experienced juniors to implement test model and even Manual QA to write DSL like tests…
In this talk I want to present the simplified approach to write PageObjects for your test model as it would be like playing “three chords” song on a guitar. And also share the experience of pacifying the LoadableComponent pattern, rather hard in implementation but making your tests much more DRY and easy to use in context of loading pages.
So S.O.L.I.D Fu - Designing Better CodeNeil Crookes
A chat about some of the most important principles in software development. Discover or get a refresher on these tried and tested techniques for designing better code.
Code: https://github.com/neilcrookes/SoSOLIDFu/
In software engineering, a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design
Patterns are formalized best practices that the programmer must implement in the application.
In the ever-evolving landscape of technology, enterprise software development is undergoing a significant transformation. Traditional coding methods are being challenged by innovative no-code solutions, which promise to streamline and democratize the software development process.
This shift is particularly impactful for enterprises, which require robust, scalable, and efficient software to manage their operations. In this article, we will explore the various facets of enterprise software development with no-code solutions, examining their benefits, challenges, and the future potential they hold.
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...Juraj Vysvader
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I didn't get rich from it but it did have 63K downloads (powered possible tens of thousands of websites).
Mobile App Development Company In Noida | Drona InfotechDrona Infotech
Looking for a reliable mobile app development company in Noida? Look no further than Drona Infotech. We specialize in creating customized apps for your business needs.
Visit Us For : https://www.dronainfotech.com/mobile-application-development/
Understanding Nidhi Software Pricing: A Quick Guide 🌟
Choosing the right software is vital for Nidhi companies to streamline operations. Our latest presentation covers Nidhi software pricing, key factors, costs, and negotiation tips.
📊 What You’ll Learn:
Key factors influencing Nidhi software price
Understanding the true cost beyond the initial price
Tips for negotiating the best deal
Affordable and customizable pricing options with Vector Nidhi Software
🔗 Learn more at: www.vectornidhisoftware.com/software-for-nidhi-company/
#NidhiSoftwarePrice #NidhiSoftware #VectorNidhi
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteGoogle
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
👉👉 Click Here To Get More Info 👇👇
https://sumonreview.com/ai-pilot-review/
AI Pilot Review: Key Features
✅Deploy AI expert bots in Any Niche With Just A Click
✅With one keyword, generate complete funnels, websites, landing pages, and more.
✅More than 85 AI features are included in the AI pilot.
✅No setup or configuration; use your voice (like Siri) to do whatever you want.
✅You Can Use AI Pilot To Create your version of AI Pilot And Charge People For It…
✅ZERO Manual Work With AI Pilot. Never write, Design, Or Code Again.
✅ZERO Limits On Features Or Usages
✅Use Our AI-powered Traffic To Get Hundreds Of Customers
✅No Complicated Setup: Get Up And Running In 2 Minutes
✅99.99% Up-Time Guaranteed
✅30 Days Money-Back Guarantee
✅ZERO Upfront Cost
See My Other Reviews Article:
(1) TubeTrivia AI Review: https://sumonreview.com/tubetrivia-ai-review
(2) SocioWave Review: https://sumonreview.com/sociowave-review
(3) AI Partner & Profit Review: https://sumonreview.com/ai-partner-profit-review
(4) AI Ebook Suite Review: https://sumonreview.com/ai-ebook-suite-review
May Marketo Masterclass, London MUG May 22 2024.pdfAdele Miller
Can't make Adobe Summit in Vegas? No sweat because the EMEA Marketo Engage Champions are coming to London to share their Summit sessions, insights and more!
This is a MUG with a twist you don't want to miss.
Check out the webinar slides to learn more about how XfilesPro transforms Salesforce document management by leveraging its world-class applications. For more details, please connect with sales@xfilespro.com
If you want to watch the on-demand webinar, please click here: https://www.xfilespro.com/webinars/salesforce-document-management-2-0-smarter-faster-better/
Software Engineering, Software Consulting, Tech Lead, Spring Boot, Spring Cloud, Spring Core, Spring JDBC, Spring Transaction, Spring MVC, OpenShift Cloud Platform, Kafka, REST, SOAP, LLD & HLD.
Graspan: A Big Data System for Big Code AnalysisAftab Hussain
We built a disk-based parallel graph system, Graspan, that uses a novel edge-pair centric computation model to compute dynamic transitive closures on very large program graphs.
We implement context-sensitive pointer/alias and dataflow analyses on Graspan. An evaluation of these analyses on large codebases such as Linux shows that their Graspan implementations scale to millions of lines of code and are much simpler than their original implementations.
These analyses were used to augment the existing checkers; these augmented checkers found 132 new NULL pointer bugs and 1308 unnecessary NULL tests in Linux 4.4.0-rc5, PostgreSQL 8.3.9, and Apache httpd 2.2.18.
- Accepted in ASPLOS ‘17, Xi’an, China.
- Featured in the tutorial, Systemized Program Analyses: A Big Data Perspective on Static Analysis Scalability, ASPLOS ‘17.
- Invited for presentation at SoCal PLS ‘16.
- Invited for poster presentation at PLDI SRC ‘16.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
Large Language Models and the End of ProgrammingMatt Welsh
Talk by Matt Welsh at Craft Conference 2024 on the impact that Large Language Models will have on the future of software development. In this talk, I discuss the ways in which LLMs will impact the software industry, from replacing human software developers with AI, to replacing conventional software with models that perform reasoning, computation, and problem-solving.
OpenMetadata Community Meeting - 5th June 2024OpenMetadata
The OpenMetadata Community Meeting was held on June 5th, 2024. In this meeting, we discussed about the data quality capabilities that are integrated with the Incident Manager, providing a complete solution to handle your data observability needs. Watch the end-to-end demo of the data quality features.
* How to run your own data quality framework
* What is the performance impact of running data quality frameworks
* How to run the test cases in your own ETL pipelines
* How the Incident Manager is integrated
* Get notified with alerts when test cases fail
Watch the meeting recording here - https://www.youtube.com/watch?v=UbNOje0kf6E
AI Genie Review: World’s First Open AI WordPress Website CreatorGoogle
AI Genie Review: World’s First Open AI WordPress Website Creator
👉👉 Click Here To Get More Info 👇👇
https://sumonreview.com/ai-genie-review
AI Genie Review: Key Features
✅Creates Limitless Real-Time Unique Content, auto-publishing Posts, Pages & Images directly from Chat GPT & Open AI on WordPress in any Niche
✅First & Only Google Bard Approved Software That Publishes 100% Original, SEO Friendly Content using Open AI
✅Publish Automated Posts and Pages using AI Genie directly on Your website
✅50 DFY Websites Included Without Adding Any Images, Content Or Doing Anything Yourself
✅Integrated Chat GPT Bot gives Instant Answers on Your Website to Visitors
✅Just Enter the title, and your Content for Pages and Posts will be ready on your website
✅Automatically insert visually appealing images into posts based on keywords and titles.
✅Choose the temperature of the content and control its randomness.
✅Control the length of the content to be generated.
✅Never Worry About Paying Huge Money Monthly To Top Content Creation Platforms
✅100% Easy-to-Use, Newbie-Friendly Technology
✅30-Days Money-Back Guarantee
See My Other Reviews Article:
(1) TubeTrivia AI Review: https://sumonreview.com/tubetrivia-ai-review
(2) SocioWave Review: https://sumonreview.com/sociowave-review
(3) AI Partner & Profit Review: https://sumonreview.com/ai-partner-profit-review
(4) AI Ebook Suite Review: https://sumonreview.com/ai-ebook-suite-review
#AIGenieApp #AIGenieBonus #AIGenieBonuses #AIGenieDemo #AIGenieDownload #AIGenieLegit #AIGenieLiveDemo #AIGenieOTO #AIGeniePreview #AIGenieReview #AIGenieReviewandBonus #AIGenieScamorLegit #AIGenieSoftware #AIGenieUpgrades #AIGenieUpsells #HowDoesAlGenie #HowtoBuyAIGenie #HowtoMakeMoneywithAIGenie #MakeMoneyOnline #MakeMoneywithAIGenie
2. Why SOLID?
SOLID is a set of five guiding principles that help developers design objects that
are easy to maintain and use.
Like many similar sets of principles in OO, SOLID is a guide not the goal.
9. “One work at a time”
● A class or module should have ONLY ONE
reason to change. Several reasons of change
may lead to several (and unwanted)
redeployments.
● Several responsibilities become coupled.
Coupled design is fragile.
SRP
Single
Responsibility
Principle
10. Example - Single Responsibility Principle
public class UserService
{
public void Register(string email, string password)
{
if (!ValidateEmail(email))
throw new ValidationException("Email is not an email");
var user = new User(email, password);
SendEmail(new MailMessage("mysite@nowhere.com", email) { Subject="HEllo foo" });
}
public virtual bool ValidateEmail(string email)
{
return email.Contains("@");
}
public bool SendEmail(MailMessage message)
{
_smtpClient.Send(message);
}
}
11. Example - Single Responsibility Principle
public class UserService
{
EmailService _emailService;
DbContext _dbContext;
public UserService(EmailService aEmailService,
DbContext aDbContext)
{
_emailService = aEmailService;
_dbContext = aDbContext;
}
public void Register(string email, string password)
{
if (!_emailService.ValidateEmail(email))
throw new ValidationException("Email is
not an email");
var user = new User(email, password);
_dbContext.Save(user);
emailService.SendEmail(new
MailMessage("myname@mydomain.com",
email)
{Subject="Hi. How are you!"});
}
}
public class EmailService
{
SmtpClient _smtpClient;
public EmailService(SmtpClient aSmtpClient)
{
_smtpClient = aSmtpClient;
}
public bool virtual ValidateEmail(string email)
{
return email.Contains("@");
}
public bool SendEmail(MailMessage message)
{
_smtpClient.Send(message);
}
}
read: http://www.objectmentor.com/resources/articles/srp.pdf
13. Software entities (classes, modules,
functions, etc.) should be open for
extension, but closed for modification:
● A module is open if it is available for extension. For
example, it should be possible to add fields to the
data structures it contains, or new elements to the
set of functions it performs.
● A module is closed if it is available for use by other
modules. This assumes that the module has been
given a well-defined, stable description (the interface
in the sense of information hiding)
OCP
Open/
Closed
Principle
14. Example - Open/Closed Principle
public class ProductFilter
{
public IEnumerable<Product> ByColor(IList<Product> products, ProductColor
productColor)
{
foreach (var product in products)
{
if (product.Color == productColor)
yield return product;
}
}
public IEnumerable<Product> ByColorAndSize(IList<Product> products,
ProductColor productColor, ProductSize productSize)
{
foreach (var product in products)
{
if ((product.Color == productColor) && (product.Size == productSize))
yield return product;
}
}
public IEnumerable<Product> BySize(IList<Product> products, ProductSize productSize)
{
foreach (var product in products)
{
if ((product.Size == productSize))
yield return product;
}
}
}
15. Example - Open/Closed Principle
public abstract class ProductFilterSpecification
{
public IEnumerable<Product> Filter(IList<Product> products)
{
return ApplyFilter(products);
}
protected abstract IEnumerable<Product> ApplyFilter
(IList<Product> products);
}
public class ColorFilterSpecification : ProductFilterSpecification
{
private readonly ProductColor productColor;
public ColorFilterSpecification(ProductColor productColor)
{
this.productColor = productColor;
}
protected override IEnumerable<Product> ApplyFilter
(IList<Product> products)
{
foreach (var product in products)
{
if (product.Color == productColor)
yield return product;
}
}
}
public class ProductFilter
{
public IEnumerable<Product> By(IList<Product>
products, ProductFilterSpecification
filterSpecification)
{
return filterSpecification.Filter(products);
}
}
OCP using the Template Design Pattern
read: http://www.objectmentor.com/resources/articles/ocp.pdf
17. ● Child classes should never break the parent
class' type definitions
● The parent class should easily replace the
child class
LSP
Liskov
Substitution
Principle
18. Example - Liskov Substitution Principle
public interface IDuck
{
void Swim();
bool IsSwimming { get; }
}
public class OrganicDuck : IDuck
{
public void Swim()
{
//do something to swim
}
bool IsSwimming { get { /* return if the duck is
swimming */ } }
}
public class ElectricDuck : IDuck
{
bool _isSwimming;
public void Swim()
{
if (!IsTurnedOn)
throw new Exception("Duck sink!");
_isSwimming = true;
//swim logic
}
bool IsSwimming { get { return _isSwimming; } }
}
void MakeDuckSwim(IDuck duck)
{
duck.Swim(); //exception if duck is ElectricDuck
}
void MakeDuckSwim(IDuck duck)
{
if (duck is ElectricDuck)
((ElectricDuck)duck).TurnOn();
duck.Swim();
}
19. Example - Liskov Substitution Principle
public class Account
{
public Account(int AccountId)
{
this.Id = AccountId;
}
public virtual int Id { get; set; }
public virtual void Withdraw(int accountId, int
amount)
{
Console.WriteLine("In base withdraw");
}
}
public class SavingAccount : Account
{
public SavingAccount(int savingAccountId):
base(savingAccountId)
{
}
public override void Withdraw(int accountId,
int amount)
{
Console.WriteLine("In SavingAccount
withdraw");
}
}
public class CurrentAccount : Account
{
public CurrentAccount(int currentAccountId) :
base(currentAccountId)
{
}
public override void Withdraw(int accountId, int
amount)
{
Console.WriteLine("In CurrentAccount withdraw");
}
}
Account account = new Account(1);
account.Withdraw(acc, 100);
Account saving = new SavingAccount(2);
saving.Withdraw(saving, 100);
read:http://www.objectmentor.com/resources/articles/lsp.pdf
21. ● no client should be forced to implement methods it
does not use
● split large interfaces into smaller and more specific
so the clients will know about the methods that are
interested in
● keep components focused in order to achieve low
coupling and high cohesion
● ISP is similar to SRP: one purpose => one interface!
ISP
Interface
Segregation
Principle
22. Example - Interface Segregation Principle
public abstract class Animal
{
public abstract void Feed();
public abstract void Groom();
}
public class Dog : Animal
{
public override void Feed()
{
//do something
}
public override void Groom()
{
// do something
}
}
public class Rattlesnake : Animal
{
public override void Feed()
{
// do something
}
public override void Groom()
{
throw new Exception("Not Implemented
yet or better Ignore!");
}
}
public interface IPet
{
void Groom();
}
public abstract class Animal
{
public abstract void Feed();
}
public class Dog : Animal, IPet
{
public override void Feed()
{
// do something
}
public void Groom()
{
// do something
}
}
public class Rattlesnake : Animal
{
public override void Feed()
{
// do something
}
}
read: http://www.objectmentor.com/resources/articles/isp.pdf
24. ● Abstractions should not depend upon details;
● Details should depend upon abstraction
● High-level modules implement business logic in a
system (application). Low-level modules deal with
more detailed operations, in other words they may
deal with writing information to databases or passing
messages to the operating system or services.
DIP
Dependency
Inversion
Principle
25. Example - Dependency Inversion Principle
class Customer
{
private FileLogger obj = new FileLogger();
public virtual void Add()
{
try
{
// Database code goes here
}
catch (Exception ex)
{
obj.Handle(ex.ToString());
}
}
}
26. Example - Dependency Inversion Principle
interface ILogger
{
void Handle(string error);
}
class FileLogger : ILogger
{
public void Handle(string error)
{
System.IO.File.WriteAllText(@"c:Error.txt",
error);
}
}
class EverViewerLogger : ILogger
{
public void Handle(string error)
{
// log errors to event viewer
}
}
class EmailLogger : ILogger
{
public void Handle(string error)
{
// send errors in email
}
}
class Customer : IDiscount, IDatabase
{
private Ilogger obj;
public Customer(ILogger i)
{
obj = i;
}
}
read: http://www.objectmentor.com/resources/articles/dip.pdf
27. SOLID (review)
● S for SRP (Single responsibility principle)
A class should take care of only one responsibility.
● O for OCP (Open closed principle)
Extension should be possible without modification.
● L for LSP (Liskov substitution principle)
A parent class object should be able to refer child objects seamlessly during runtime polymorphism.
● I for ISP (Interface segregation principle)
Client should not be forced to use a interface if it does not need it.
● D for DIP (Dependency inversion principle)
High level modules should not depend on low level modules but should depend on abstraction.