SlideShare a Scribd company logo
/20@yegor256 1
How Immutability

Helps in OOP?
Yegor Bugayenko
/20@yegor256 2
what is an object?
/20@yegor256 3
“Each object looks
quite a bit like a
little computer — it
has a state, and it
has operations that
you can ask it to
perform”
- page 16
/20@yegor256 4
“An object is some
memory that holds a
value of some type”
- page 40
/20@yegor256 5
“A class is a
collection of data
fields that hold
values and methods
that operate on those
values”
- page 98
/20@yegor256 6
“Objects may contain
data, in the form of
fields, often known
as attributes; and
code, in the form of
procedures, often
known as methods”
/20@yegor256 7
/20@yegor256 8
class Calculator {
private int[] array;
public void calculate(int a, int b) {
this.array = new int[b - a];
for (int i = 0; i < this.array.length; ++i) {
this.array[i] = a + i;
}
}
public int[] numbers() {
return this.array;
}
}
/20@yegor256 9
Calculator c = new Calculator();
c.calculate(5, 15);
int[] x = c.numbers();
/20@yegor256 10
“who I am?”
vs.
“what I do?”
/20@yegor256 11
class Range {
private final int a;
private final int b;
Range(int start, int finish) {
this.a = start;
this.b = finish;
}
public int[] numbers() {
int[] array = new int[this.b - this.a];
for (int i = 0; i < array.length; ++i) {
array[i] = this.a + i;
}
return array;
}
}
/20@yegor256 12
Range r = new Range(5, 15);
int[] x = r.numbers();
/20@yegor256 13
R range = new Range(5, 15);
int[] x = range.numbers();
Calculator c = new Calculator();
c.calculate(5, 15);
int[] x = c.numbers();
/20@yegor256 14
R range = new OddOnly(
new Range(5, 15)
);
int[] x = range.numbers();
Calculator c = new Calculator();
c.setOddOnly(true);
c.calculate(5, 15);
int[] x = c.numbers();
/20@yegor256 15
R range = new SquareAll(
new OddOnly(
new Range(5, 15)
)
);
int[] x = range.numbers();
Calculator c = new Calculator();
c.setOddOnly(true);
c.setSquareAll(true);
c.calculate(5, 15);
int[] x = c.numbers();
/20@yegor256 16
R range = new Incremented(
new Squared(
new OddOnly(
new Range(5, 15)
)
),
100
);
int[] x = range.numbers();
Calculator c = new Calculator();
c.setOddOnly(true);
c.setSquared(true);
c.setIncremented(100);
c.calculate(5, 15);
int[] x = c.numbers();
/20@yegor256 17
R range = new Logged(
new Incremented(
new Squared(
new OddOnly(
new Range(5, 15)
)
),
100
)
);
int[] x = range.numbers();
Calculator c = new Calculator();
c.setOddOnly(true);
c.setSquared(true);
c.setIncremented(100);
c.setLogged(true);
c.calculate(5, 15);
int[] x = c.numbers();
/20@yegor256 18
R range = new Logged(
new Incremented(
new Squared(
new OddOnly(
new RangeFromFile(
new File(“a.txt”)
)
)
),
100
)
);
int[] x = range.numbers();
Calculator c = new Calculator();
c.setFromFile(“a.txt”); //???
c.setOddOnly(true);
c.setSquared(true);
c.setIncremented(100);
c.setLogged(true);
c.calculate(5, 15);
int[] x = c.numbers();
/20@yegor256 19
what is an object?
/20@yegor256 20
www.yegor256.com

More Related Content

What's hot

Excel - Vloopup, Averageif , Countif, Index and Sumif
Excel - Vloopup, Averageif , Countif, Index and SumifExcel - Vloopup, Averageif , Countif, Index and Sumif
Excel - Vloopup, Averageif , Countif, Index and Sumif
VIVEKRAJ546946
 
Array stack-queue1
Array stack-queue1Array stack-queue1
Array stack-queue1
Rajendran
 
12 - Scala. Empty and unit types
12 - Scala. Empty and unit types12 - Scala. Empty and unit types
12 - Scala. Empty and unit types
Roman Brovko
 
Roots With Calc2
Roots With Calc2Roots With Calc2
Roots With Calc2
bwlomas
 
4 5 Exponential Growth And Decay
4 5 Exponential Growth And Decay4 5 Exponential Growth And Decay
4 5 Exponential Growth And Decay
silvia
 
Sequential multiplication
Sequential multiplicationSequential multiplication
Sequential multiplication
Taqwa It Center
 
Functional Approach to Software Engineering
Functional Approach to Software EngineeringFunctional Approach to Software Engineering
Functional Approach to Software Engineering
Pasindu Perera
 
Isometries Orientation
Isometries OrientationIsometries Orientation
Isometries Orientation
bwlomas
 
Database assignment
Database assignmentDatabase assignment
Database assignment
epidemicaa
 

What's hot (9)

Excel - Vloopup, Averageif , Countif, Index and Sumif
Excel - Vloopup, Averageif , Countif, Index and SumifExcel - Vloopup, Averageif , Countif, Index and Sumif
Excel - Vloopup, Averageif , Countif, Index and Sumif
 
Array stack-queue1
Array stack-queue1Array stack-queue1
Array stack-queue1
 
12 - Scala. Empty and unit types
12 - Scala. Empty and unit types12 - Scala. Empty and unit types
12 - Scala. Empty and unit types
 
Roots With Calc2
Roots With Calc2Roots With Calc2
Roots With Calc2
 
4 5 Exponential Growth And Decay
4 5 Exponential Growth And Decay4 5 Exponential Growth And Decay
4 5 Exponential Growth And Decay
 
Sequential multiplication
Sequential multiplicationSequential multiplication
Sequential multiplication
 
Functional Approach to Software Engineering
Functional Approach to Software EngineeringFunctional Approach to Software Engineering
Functional Approach to Software Engineering
 
Isometries Orientation
Isometries OrientationIsometries Orientation
Isometries Orientation
 
Database assignment
Database assignmentDatabase assignment
Database assignment
 

Viewers also liked

Java 8 puzzlers
Java 8 puzzlersJava 8 puzzlers
Java 8 puzzlers
Evgeny Borisov
 
Need It Robust? Make It Fragile!
Need It Robust? Make It Fragile!Need It Robust? Make It Fragile!
Need It Robust? Make It Fragile!
Yegor Bugayenko
 
How Anemic Objects Kill OOP
How Anemic Objects Kill OOPHow Anemic Objects Kill OOP
How Anemic Objects Kill OOP
Yegor Bugayenko
 
Object Oriented Lies
Object Oriented LiesObject Oriented Lies
Object Oriented Lies
Yegor Bugayenko
 
Java vs OOP
Java vs OOPJava vs OOP
Java vs OOP
Yegor Bugayenko
 
ORM is a perfect anti-pattern
ORM is a perfect anti-patternORM is a perfect anti-pattern
ORM is a perfect anti-pattern
Yegor Bugayenko
 
Continuous Integration is Dead
Continuous Integration is DeadContinuous Integration is Dead
Continuous Integration is Dead
Yegor Bugayenko
 
OOP Is Dead? Not Yet!
OOP Is Dead? Not Yet!OOP Is Dead? Not Yet!
OOP Is Dead? Not Yet!
Yegor Bugayenko
 
Meetings Or Discipline
Meetings Or DisciplineMeetings Or Discipline
Meetings Or Discipline
Yegor Bugayenko
 
How Do You Know When Your Product is Ready to be Shipped?
How Do You Know When Your Product is Ready to be Shipped?How Do You Know When Your Product is Ready to be Shipped?
How Do You Know When Your Product is Ready to be Shipped?
Yegor Bugayenko
 
How Much Immutability Is Enough?
How Much Immutability Is Enough?How Much Immutability Is Enough?
How Much Immutability Is Enough?
Yegor Bugayenko
 
Who Manages Who?
Who Manages Who?Who Manages Who?
Who Manages Who?
Yegor Bugayenko
 
Fail Fast. Into User's Face.
Fail Fast. Into User's Face.Fail Fast. Into User's Face.
Fail Fast. Into User's Face.
Yegor Bugayenko
 
Practical Example of AOP with AspectJ
Practical Example of AOP with AspectJPractical Example of AOP with AspectJ
Practical Example of AOP with AspectJ
Yegor Bugayenko
 
Problems With Chat Bots
Problems With Chat BotsProblems With Chat Bots
Problems With Chat Bots
Yegor Bugayenko
 
Who Is a Software Architect?
Who Is a Software Architect?Who Is a Software Architect?
Who Is a Software Architect?
Yegor Bugayenko
 
Built-in Fake Objects
Built-in Fake ObjectsBuilt-in Fake Objects
Built-in Fake Objects
Yegor Bugayenko
 
Management without managers
Management without managersManagement without managers
Management without managers
Yegor Bugayenko
 
мифы о спарке
мифы о спарке мифы о спарке
мифы о спарке
Evgeny Borisov
 
ORM is offensive
ORM is offensiveORM is offensive
ORM is offensive
Yegor Bugayenko
 

Viewers also liked (20)

Java 8 puzzlers
Java 8 puzzlersJava 8 puzzlers
Java 8 puzzlers
 
Need It Robust? Make It Fragile!
Need It Robust? Make It Fragile!Need It Robust? Make It Fragile!
Need It Robust? Make It Fragile!
 
How Anemic Objects Kill OOP
How Anemic Objects Kill OOPHow Anemic Objects Kill OOP
How Anemic Objects Kill OOP
 
Object Oriented Lies
Object Oriented LiesObject Oriented Lies
Object Oriented Lies
 
Java vs OOP
Java vs OOPJava vs OOP
Java vs OOP
 
ORM is a perfect anti-pattern
ORM is a perfect anti-patternORM is a perfect anti-pattern
ORM is a perfect anti-pattern
 
Continuous Integration is Dead
Continuous Integration is DeadContinuous Integration is Dead
Continuous Integration is Dead
 
OOP Is Dead? Not Yet!
OOP Is Dead? Not Yet!OOP Is Dead? Not Yet!
OOP Is Dead? Not Yet!
 
Meetings Or Discipline
Meetings Or DisciplineMeetings Or Discipline
Meetings Or Discipline
 
How Do You Know When Your Product is Ready to be Shipped?
How Do You Know When Your Product is Ready to be Shipped?How Do You Know When Your Product is Ready to be Shipped?
How Do You Know When Your Product is Ready to be Shipped?
 
How Much Immutability Is Enough?
How Much Immutability Is Enough?How Much Immutability Is Enough?
How Much Immutability Is Enough?
 
Who Manages Who?
Who Manages Who?Who Manages Who?
Who Manages Who?
 
Fail Fast. Into User's Face.
Fail Fast. Into User's Face.Fail Fast. Into User's Face.
Fail Fast. Into User's Face.
 
Practical Example of AOP with AspectJ
Practical Example of AOP with AspectJPractical Example of AOP with AspectJ
Practical Example of AOP with AspectJ
 
Problems With Chat Bots
Problems With Chat BotsProblems With Chat Bots
Problems With Chat Bots
 
Who Is a Software Architect?
Who Is a Software Architect?Who Is a Software Architect?
Who Is a Software Architect?
 
Built-in Fake Objects
Built-in Fake ObjectsBuilt-in Fake Objects
Built-in Fake Objects
 
Management without managers
Management without managersManagement without managers
Management without managers
 
мифы о спарке
мифы о спарке мифы о спарке
мифы о спарке
 
ORM is offensive
ORM is offensiveORM is offensive
ORM is offensive
 

Similar to How Immutability Helps in OOP

Arrays
ArraysArrays
Functional DDD
Functional DDDFunctional DDD
Functional DDD
Alessandro Melchiori
 
Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?
Andrey Akinshin
 
An object of class StatCalc can be used to compute several simp.pdf
 An object of class StatCalc can be used to compute several simp.pdf An object of class StatCalc can be used to compute several simp.pdf
An object of class StatCalc can be used to compute several simp.pdf
aravlitraders2012
 
Arrays basics
Arrays basicsArrays basics
Arrays basics
sudhirvegad
 
Stratosphere Intro (Java and Scala Interface)
Stratosphere Intro (Java and Scala Interface)Stratosphere Intro (Java and Scala Interface)
Stratosphere Intro (Java and Scala Interface)
Robert Metzger
 
The STL
The STLThe STL
The STL
adil raja
 
Part 1 - Written AnswersDownload the GridWriter.zip file and exami.pdf
Part 1 - Written AnswersDownload the GridWriter.zip file and exami.pdfPart 1 - Written AnswersDownload the GridWriter.zip file and exami.pdf
Part 1 - Written AnswersDownload the GridWriter.zip file and exami.pdf
kamdinrossihoungma74
 
PyData Paris 2015 - Track 1.2 Gilles Louppe
PyData Paris 2015 - Track 1.2 Gilles LouppePyData Paris 2015 - Track 1.2 Gilles Louppe
PyData Paris 2015 - Track 1.2 Gilles Louppe
Pôle Systematic Paris-Region
 
DATA STRUCTURE CLASS 12 COMPUTER SCIENCE
DATA STRUCTURE CLASS 12 COMPUTER SCIENCEDATA STRUCTURE CLASS 12 COMPUTER SCIENCE
DATA STRUCTURE CLASS 12 COMPUTER SCIENCE
Dev Chauhan
 
Lecture06 computer applicationsie1_dratifshahzad
Lecture06 computer applicationsie1_dratifshahzadLecture06 computer applicationsie1_dratifshahzad
Lecture06 computer applicationsie1_dratifshahzad
Atif Shahzad
 
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Roel Hartman
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4
Abed Bukhari
 
Operators in Kotlin
Operators in KotlinOperators in Kotlin
Operators in Kotlin
Sagar Modi
 
ch03-parameters-objects.ppt
ch03-parameters-objects.pptch03-parameters-objects.ppt
ch03-parameters-objects.ppt
Mahyuddin8
 
Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy code
ShriKant Vashishtha
 
Unit 3
Unit 3Unit 3
Oops lab manual2
Oops lab manual2Oops lab manual2
Oops lab manual2
Mouna Guru
 
C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0
Yaser Zhian
 
C++ lab assignment
C++ lab assignmentC++ lab assignment
C++ lab assignment
Saket Pathak
 

Similar to How Immutability Helps in OOP (20)

Arrays
ArraysArrays
Arrays
 
Functional DDD
Functional DDDFunctional DDD
Functional DDD
 
Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?
 
An object of class StatCalc can be used to compute several simp.pdf
 An object of class StatCalc can be used to compute several simp.pdf An object of class StatCalc can be used to compute several simp.pdf
An object of class StatCalc can be used to compute several simp.pdf
 
Arrays basics
Arrays basicsArrays basics
Arrays basics
 
Stratosphere Intro (Java and Scala Interface)
Stratosphere Intro (Java and Scala Interface)Stratosphere Intro (Java and Scala Interface)
Stratosphere Intro (Java and Scala Interface)
 
The STL
The STLThe STL
The STL
 
Part 1 - Written AnswersDownload the GridWriter.zip file and exami.pdf
Part 1 - Written AnswersDownload the GridWriter.zip file and exami.pdfPart 1 - Written AnswersDownload the GridWriter.zip file and exami.pdf
Part 1 - Written AnswersDownload the GridWriter.zip file and exami.pdf
 
PyData Paris 2015 - Track 1.2 Gilles Louppe
PyData Paris 2015 - Track 1.2 Gilles LouppePyData Paris 2015 - Track 1.2 Gilles Louppe
PyData Paris 2015 - Track 1.2 Gilles Louppe
 
DATA STRUCTURE CLASS 12 COMPUTER SCIENCE
DATA STRUCTURE CLASS 12 COMPUTER SCIENCEDATA STRUCTURE CLASS 12 COMPUTER SCIENCE
DATA STRUCTURE CLASS 12 COMPUTER SCIENCE
 
Lecture06 computer applicationsie1_dratifshahzad
Lecture06 computer applicationsie1_dratifshahzadLecture06 computer applicationsie1_dratifshahzad
Lecture06 computer applicationsie1_dratifshahzad
 
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4
 
Operators in Kotlin
Operators in KotlinOperators in Kotlin
Operators in Kotlin
 
ch03-parameters-objects.ppt
ch03-parameters-objects.pptch03-parameters-objects.ppt
ch03-parameters-objects.ppt
 
Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy code
 
Unit 3
Unit 3Unit 3
Unit 3
 
Oops lab manual2
Oops lab manual2Oops lab manual2
Oops lab manual2
 
C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0
 
C++ lab assignment
C++ lab assignmentC++ lab assignment
C++ lab assignment
 

More from Yegor Bugayenko

Can Distributed Teams Deliver Quality?
Can Distributed Teams Deliver Quality?Can Distributed Teams Deliver Quality?
Can Distributed Teams Deliver Quality?
Yegor Bugayenko
 
Are You Sure You Are Not a Micromanager?
Are You Sure You Are Not a Micromanager?Are You Sure You Are Not a Micromanager?
Are You Sure You Are Not a Micromanager?
Yegor Bugayenko
 
On Requirements Management (Demotivate Them Right)
On Requirements Management (Demotivate Them Right)On Requirements Management (Demotivate Them Right)
On Requirements Management (Demotivate Them Right)
Yegor Bugayenko
 
My Experience of 1000 Interviews
My Experience of 1000 InterviewsMy Experience of 1000 Interviews
My Experience of 1000 Interviews
Yegor Bugayenko
 
Are you sure you are not a micromanager?
Are you sure you are not a micromanager?Are you sure you are not a micromanager?
Are you sure you are not a micromanager?
Yegor Bugayenko
 
Quality Assurance vs. Testing
Quality Assurance vs. TestingQuality Assurance vs. Testing
Quality Assurance vs. Testing
Yegor Bugayenko
 
Is Java Getting Better?
Is Java Getting Better?Is Java Getting Better?
Is Java Getting Better?
Yegor Bugayenko
 
Typical Pitfalls in Testing
Typical Pitfalls in TestingTypical Pitfalls in Testing
Typical Pitfalls in Testing
Yegor Bugayenko
 
Software Testing Pitfalls
Software Testing PitfallsSoftware Testing Pitfalls
Software Testing Pitfalls
Yegor Bugayenko
 
Five Trends We Are Afraid Of
Five Trends We Are Afraid OfFive Trends We Are Afraid Of
Five Trends We Are Afraid Of
Yegor Bugayenko
 
Experts vs Expertise
Experts vs ExpertiseExperts vs Expertise
Experts vs Expertise
Yegor Bugayenko
 
Who Cares About Quality?
Who Cares About Quality?Who Cares About Quality?
Who Cares About Quality?
Yegor Bugayenko
 
Quantity vs. Quality
Quantity vs. QualityQuantity vs. Quality
Quantity vs. Quality
Yegor Bugayenko
 
Experts vs Expertise
Experts vs ExpertiseExperts vs Expertise
Experts vs Expertise
Yegor Bugayenko
 
Zold: a cryptocurrency without Blockchain
Zold: a cryptocurrency without BlockchainZold: a cryptocurrency without Blockchain
Zold: a cryptocurrency without Blockchain
Yegor Bugayenko
 
Life Without Blockchain
Life Without BlockchainLife Without Blockchain
Life Without Blockchain
Yegor Bugayenko
 
How to Cut Corners and Stay Cool
How to Cut Corners and Stay CoolHow to Cut Corners and Stay Cool
How to Cut Corners and Stay Cool
Yegor Bugayenko
 
Math or Love?
Math or Love?Math or Love?
Math or Love?
Yegor Bugayenko
 
How much do you cost?
How much do you cost?How much do you cost?
How much do you cost?
Yegor Bugayenko
 
Java Annotations Are a Bad Idea
Java Annotations Are a Bad IdeaJava Annotations Are a Bad Idea
Java Annotations Are a Bad Idea
Yegor Bugayenko
 

More from Yegor Bugayenko (20)

Can Distributed Teams Deliver Quality?
Can Distributed Teams Deliver Quality?Can Distributed Teams Deliver Quality?
Can Distributed Teams Deliver Quality?
 
Are You Sure You Are Not a Micromanager?
Are You Sure You Are Not a Micromanager?Are You Sure You Are Not a Micromanager?
Are You Sure You Are Not a Micromanager?
 
On Requirements Management (Demotivate Them Right)
On Requirements Management (Demotivate Them Right)On Requirements Management (Demotivate Them Right)
On Requirements Management (Demotivate Them Right)
 
My Experience of 1000 Interviews
My Experience of 1000 InterviewsMy Experience of 1000 Interviews
My Experience of 1000 Interviews
 
Are you sure you are not a micromanager?
Are you sure you are not a micromanager?Are you sure you are not a micromanager?
Are you sure you are not a micromanager?
 
Quality Assurance vs. Testing
Quality Assurance vs. TestingQuality Assurance vs. Testing
Quality Assurance vs. Testing
 
Is Java Getting Better?
Is Java Getting Better?Is Java Getting Better?
Is Java Getting Better?
 
Typical Pitfalls in Testing
Typical Pitfalls in TestingTypical Pitfalls in Testing
Typical Pitfalls in Testing
 
Software Testing Pitfalls
Software Testing PitfallsSoftware Testing Pitfalls
Software Testing Pitfalls
 
Five Trends We Are Afraid Of
Five Trends We Are Afraid OfFive Trends We Are Afraid Of
Five Trends We Are Afraid Of
 
Experts vs Expertise
Experts vs ExpertiseExperts vs Expertise
Experts vs Expertise
 
Who Cares About Quality?
Who Cares About Quality?Who Cares About Quality?
Who Cares About Quality?
 
Quantity vs. Quality
Quantity vs. QualityQuantity vs. Quality
Quantity vs. Quality
 
Experts vs Expertise
Experts vs ExpertiseExperts vs Expertise
Experts vs Expertise
 
Zold: a cryptocurrency without Blockchain
Zold: a cryptocurrency without BlockchainZold: a cryptocurrency without Blockchain
Zold: a cryptocurrency without Blockchain
 
Life Without Blockchain
Life Without BlockchainLife Without Blockchain
Life Without Blockchain
 
How to Cut Corners and Stay Cool
How to Cut Corners and Stay CoolHow to Cut Corners and Stay Cool
How to Cut Corners and Stay Cool
 
Math or Love?
Math or Love?Math or Love?
Math or Love?
 
How much do you cost?
How much do you cost?How much do you cost?
How much do you cost?
 
Java Annotations Are a Bad Idea
Java Annotations Are a Bad IdeaJava Annotations Are a Bad Idea
Java Annotations Are a Bad Idea
 

Recently uploaded

What is Continuous Testing in DevOps - A Definitive Guide.pdf
What is Continuous Testing in DevOps - A Definitive Guide.pdfWhat is Continuous Testing in DevOps - A Definitive Guide.pdf
What is Continuous Testing in DevOps - A Definitive Guide.pdf
kalichargn70th171
 
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA ComplianceSecure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
ICS
 
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Paul Brebner
 
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
The Third Creative Media
 
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
widenerjobeyrl638
 
Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)
alowpalsadig
 
Boost Your Savings with These Money Management Apps
Boost Your Savings with These Money Management AppsBoost Your Savings with These Money Management Apps
Boost Your Savings with These Money Management Apps
Jhone kinadey
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio, Inc.
 
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
campbellclarkson
 
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical OperationsEnsuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
OnePlan Solutions
 
The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024
Yara Milbes
 
Streamlining End-to-End Testing Automation
Streamlining End-to-End Testing AutomationStreamlining End-to-End Testing Automation
Streamlining End-to-End Testing Automation
Anand Bagmar
 
Microsoft-Power-Platform-Adoption-Planning.pptx
Microsoft-Power-Platform-Adoption-Planning.pptxMicrosoft-Power-Platform-Adoption-Planning.pptx
Microsoft-Power-Platform-Adoption-Planning.pptx
jrodriguezq3110
 
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
dhavalvaghelanectarb
 
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
kalichargn70th171
 
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
manji sharman06
 
Penify - Let AI do the Documentation, you write the Code.
Penify - Let AI do the Documentation, you write the Code.Penify - Let AI do the Documentation, you write the Code.
Penify - Let AI do the Documentation, you write the Code.
KrishnaveniMohan1
 
Refactoring legacy systems using events commands and bubble contexts
Refactoring legacy systems using events commands and bubble contextsRefactoring legacy systems using events commands and bubble contexts
Refactoring legacy systems using events commands and bubble contexts
Michał Kurzeja
 
How GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdfHow GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdf
Zycus
 

Recently uploaded (20)

What is Continuous Testing in DevOps - A Definitive Guide.pdf
What is Continuous Testing in DevOps - A Definitive Guide.pdfWhat is Continuous Testing in DevOps - A Definitive Guide.pdf
What is Continuous Testing in DevOps - A Definitive Guide.pdf
 
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA ComplianceSecure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
 
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
 
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
 
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
 
Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)
 
Boost Your Savings with These Money Management Apps
Boost Your Savings with These Money Management AppsBoost Your Savings with These Money Management Apps
Boost Your Savings with These Money Management Apps
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
 
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
 
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical OperationsEnsuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
 
The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024
 
Streamlining End-to-End Testing Automation
Streamlining End-to-End Testing AutomationStreamlining End-to-End Testing Automation
Streamlining End-to-End Testing Automation
 
Microsoft-Power-Platform-Adoption-Planning.pptx
Microsoft-Power-Platform-Adoption-Planning.pptxMicrosoft-Power-Platform-Adoption-Planning.pptx
Microsoft-Power-Platform-Adoption-Planning.pptx
 
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
 
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
 
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
 
Penify - Let AI do the Documentation, you write the Code.
Penify - Let AI do the Documentation, you write the Code.Penify - Let AI do the Documentation, you write the Code.
Penify - Let AI do the Documentation, you write the Code.
 
bgiolcb
bgiolcbbgiolcb
bgiolcb
 
Refactoring legacy systems using events commands and bubble contexts
Refactoring legacy systems using events commands and bubble contextsRefactoring legacy systems using events commands and bubble contexts
Refactoring legacy systems using events commands and bubble contexts
 
How GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdfHow GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdf
 

How Immutability Helps in OOP

  • 3. /20@yegor256 3 “Each object looks quite a bit like a little computer — it has a state, and it has operations that you can ask it to perform” - page 16
  • 4. /20@yegor256 4 “An object is some memory that holds a value of some type” - page 40
  • 5. /20@yegor256 5 “A class is a collection of data fields that hold values and methods that operate on those values” - page 98
  • 6. /20@yegor256 6 “Objects may contain data, in the form of fields, often known as attributes; and code, in the form of procedures, often known as methods”
  • 8. /20@yegor256 8 class Calculator { private int[] array; public void calculate(int a, int b) { this.array = new int[b - a]; for (int i = 0; i < this.array.length; ++i) { this.array[i] = a + i; } } public int[] numbers() { return this.array; } }
  • 9. /20@yegor256 9 Calculator c = new Calculator(); c.calculate(5, 15); int[] x = c.numbers();
  • 10. /20@yegor256 10 “who I am?” vs. “what I do?”
  • 11. /20@yegor256 11 class Range { private final int a; private final int b; Range(int start, int finish) { this.a = start; this.b = finish; } public int[] numbers() { int[] array = new int[this.b - this.a]; for (int i = 0; i < array.length; ++i) { array[i] = this.a + i; } return array; } }
  • 12. /20@yegor256 12 Range r = new Range(5, 15); int[] x = r.numbers();
  • 13. /20@yegor256 13 R range = new Range(5, 15); int[] x = range.numbers(); Calculator c = new Calculator(); c.calculate(5, 15); int[] x = c.numbers();
  • 14. /20@yegor256 14 R range = new OddOnly( new Range(5, 15) ); int[] x = range.numbers(); Calculator c = new Calculator(); c.setOddOnly(true); c.calculate(5, 15); int[] x = c.numbers();
  • 15. /20@yegor256 15 R range = new SquareAll( new OddOnly( new Range(5, 15) ) ); int[] x = range.numbers(); Calculator c = new Calculator(); c.setOddOnly(true); c.setSquareAll(true); c.calculate(5, 15); int[] x = c.numbers();
  • 16. /20@yegor256 16 R range = new Incremented( new Squared( new OddOnly( new Range(5, 15) ) ), 100 ); int[] x = range.numbers(); Calculator c = new Calculator(); c.setOddOnly(true); c.setSquared(true); c.setIncremented(100); c.calculate(5, 15); int[] x = c.numbers();
  • 17. /20@yegor256 17 R range = new Logged( new Incremented( new Squared( new OddOnly( new Range(5, 15) ) ), 100 ) ); int[] x = range.numbers(); Calculator c = new Calculator(); c.setOddOnly(true); c.setSquared(true); c.setIncremented(100); c.setLogged(true); c.calculate(5, 15); int[] x = c.numbers();
  • 18. /20@yegor256 18 R range = new Logged( new Incremented( new Squared( new OddOnly( new RangeFromFile( new File(“a.txt”) ) ) ), 100 ) ); int[] x = range.numbers(); Calculator c = new Calculator(); c.setFromFile(“a.txt”); //??? c.setOddOnly(true); c.setSquared(true); c.setIncremented(100); c.setLogged(true); c.calculate(5, 15); int[] x = c.numbers();