SlideShare uma empresa Scribd logo
1 de 40
Baixar para ler offline
Problem Solving Techniques
For Evolutionary Design
Distilling Down Any Problem to Its Crux
Naresh Jain
naresh@xnsio.com
@nashjain
https://xnsio.com
Rounding Up to the
Closest 5 Cents
• In my billing application
• Given the price of an item comes up to $20.23
after tax
• I want to round up 23 cents to the closest 5
cents denomination .i.e. 25 cents
• So I can charge $20.25
• https://github.com/nashjain/rounding_logic
• https://help.github.com/categories/54/articles
Tests
@Test
public void shouldLeaveAsIsIfAlreadyInDenominationsOf5Cents() {
assertEquals(20.25, round(20.25), 0.01);
}
@Test
public void shouldRoundUpToNext5Cents() {
assertEquals(20.25, round(20.24), 0.01);
}
@Test
public void shouldRoundUpEvenIfAmountIsLessThanPoint023() {
assertEquals(20.25, round(20.21), 0.01);
}
https://github.com/nashjain/rounding_logic
Rounding Up - Answer
• var price = 20.23;
• var rounded_price = ceil(price / 0.05) * 0.05;
or
• var rounded_price = ceil(price * 20) / 20;
Hotel Room Charge
• Calculate the bill amount based on the number of hotel nights
the guest has stayed in the hotel.
• Per hotel night is charged at 4999 INR for single occupancy and
5499 INR for double occupancy.
• Hotels have a standard 12:00 noon checkin and checkout.
• Early Checkin: Guest can request to checkin early (before
12:00 noon.) If they checkin between 9 and 12, they are
charged 50% extra. If they checkin before 9 AM, then they are
charged full night charge.
• Late Checkout: Guest can request a late checkout. If they
checkout after 12 noon and before 3, they are charged 50%
extra and if they checkout after 3:00 PM, they have to pay one
whole night's extra charge.
function calculate_hotel_charge(occupancy, hotel_checkin, hotel_checkout) {
var per_night_rate = occupancy == ‘Single’ ? 4999 : 5499;
return per_night_rate * total_nights(hotel_checkin, hotel_checkout);
}
function total_nights(hotel_checkin, hotel_checkout) {
return max(actual_nights(hotel_checkin, hotel_checkout)
+ early_checkin_nights(hotel_checkin)
+ late_checkout_nights(hotel_checkout), 1);
}
function actual_nights(hotel_checkin, hotel_checkout) {
return floor((hotel_checkout - hotel_checkin) / (24 * 60 * 60 * 1000));
}
functional early_checkin_nights(hotel_checkin) {
if(hotel_checkin.getHours() > 12) return 0;
if(hotel_checkin.getHours() > 9) return 0.5;
return 1;
}
Hotel Room Charge Solution
functional late_checkout_nights(hotel_checkout) {
if(hotel_checkin.getHours() < 12) return 0;
if(hotel_checkin.getHours() < 3) return 0.5;
return 1;
}
High-level Approach
Eliminate Noise Divide & Conquer
Test Data
Constraints Simple Design
Manual Debug
Refactor
Throw Away
Create
Add
Come
up with
Simplify the Problem
Prioritise
Remove
constrains
Works?
More Constraints Exit?
Yes
No
Problem-Solving Strategies
• Sandboxing: solving the problem in a model of the system before
applying it to the real system
• Metaphor: using a solution that solves an analogous problem
• Brainstorming: exploring a large number of solutions or ideas
and combining and developing them until an optimum solution is
found
• Divide and conquer: breaking down a large, complex problem
into smaller, solvable problems
• Hypothesis testing: assuming a possible explanation to the
problem and trying to prove (or disprove) the assumption
• Reduction: transforming the problem into another problem for
which solutions exist
• Trial-and-error: testing possible solutions until the right one’s
Adapted from: http://en.wikipedia.org/wiki/Problem_solving#Problem-solving_strategies
Commercial Break!
Copyright Š
2012,
Mumbai
Tech Talks!
IP Address Range
• Each country has blocks of IPv4 address
range assigned to it
• Given I have an IP address I want to figure
out which country it belong to
Start End Total IPs Country
1.6.0.0 1.7.255.255 131072 India
1.22.0.0 1.23.255.255 131072 India
1.186.0.0 1.186.255.255 65536 India
1.0.32.0 1.0.63.255 8192 China
1.1.16.0 1.1.31.255 4096 China
1.4.16.0 1.4.31.255 4096 Japan
• https://github.com/nashjain/ip2country
• 196 countries with 100s of such blocks
public long convertToNumericIp(String ip) {
long numericIp = 0;
String[] octets = ip.split(“.");
for (int i = 0; i < 4; ++i)
numericIp += parseInt(octets[i]) * Math.pow(256, 3 - i);
return numericIp;
}
243.131.122.231
243*256*256*256 + 131*256*256 + 122*256 + 231
= 4085480167
Snakes and Ladders
• One or more players can play the game
• Typical board size is 10 x10, but user can specify
different board size
• User can decide the game mode (Easy = 5 snakes and
ladders, Medium = 10 snakes and ladders, Hard = 20
snakes and ladders.) Default to easy mode.
• After each move, snakes and ladders could move, but
at least after each game, they should move.
• Game takes the names of all the players and reports
the name of the winner.
• Random player gets to start
def move(players, player_turn)
new_position = players[player_turn] + throw_dice
new_position = @snakes_ladders[new_position]
if @snakes_ladders.has_key?(new_position)
return player_turn if new_position >= @board_size
players[player_turn] = new_position
next_player = (player_turn + 1) % players.length
move(players, next_player)
end
https://github.com/nashjain/snakes_n_ladders
Medical Age Printer
Age Reported in
Greater than 1Year <Patient Name> is #Years old
> 1 Month & < 1Year <Patient Name> is # Months old
> 1 Day & < 1 Month <Patient Name> is # Days old
> 1 Hr & < 1 Day <Patient Name> is # Hours old
Doctors and Nurses might like to add and remove new Durations.
For Ex: If they add Decade, and Patient’s age is greater than 10 years,
then age should be reported as <Patient Name> is # Decades old.
Similarly: If they add Week, and Patient’s age is greater than 7 Day, but less than
a month, then age should be reported as <Patient Name> is # Weeks old.
https://github.com/nashjain/map
private static nal long MILLIS_IN_MIN = 60 * 1000L;
private static nal long MILLIS_IN_HOUR = MILLIS_IN_MIN * 60;
private static nal long MILLIS_IN_DAY = MILLIS_IN_HOUR * 24;
private static nal long MILLIS_IN_MONTH = MILLIS_IN_DAY * 30;
private static nal long MILLIS_IN_YEAR = MILLIS_IN_DAY * 365;
private nal TreeMap<Long, String> millisPerUnit = new TreeMap<Long, String>() {
{
put(MILLIS_IN_HOUR, "Hours");
put(MILLIS_IN_DAY, "Days");
put(MILLIS_IN_MONTH, "Months");
put(MILLIS_IN_YEAR, "Year");
}
};
public String since(Date dob) {
long deltaInMillis = differenceInMillisFromNow(dob);
Entry<Long, String> duration = millisPerUnit.floorEntry(deltaInMillis);
if (duration == null)
return "0 Hours";
return deltaInMillis / duration.getKey() + " " + duration.getValue();
}
private long differenceInMillisFromNow(Date date) {
return clock.now() - date.getTime();
}
Recap
Eliminate Noise Divide & Conquer
Test Data
Constraints Simple Design
Manual Debug
Refactor
Throw Away
Create
Add
Come
up with
Simplify the Problem
Prioritise
Remove
constrains
Works?
More Constraints Exit?
Yes
No
Important Advice
Pick a Solution after Trying
at least 3 Approaches
"Perfection (in design) is achieved not when there is nothing more to add,
but rather when there is nothing more to take away." – Eric S Raymond
Quit Multitasking
Deliberate Practice
Next Steps?
Practice An Hour Each Day
Participate
ThankYou!
Questions?
Naresh Jain
@nashjain
https://xnsio.com

Mais conteĂşdo relacionado

Mais procurados

The Ring programming language version 1.3 book - Part 43 of 88
The Ring programming language version 1.3 book - Part 43 of 88The Ring programming language version 1.3 book - Part 43 of 88
The Ring programming language version 1.3 book - Part 43 of 88Mahmoud Samir Fayed
 
ゼロから始めるScala文法
ゼロから始めるScala文法ゼロから始めるScala文法
ゼロから始めるScala文法Ryuichi ITO
 
Numerical Methods with Computer Programming
Numerical Methods with Computer ProgrammingNumerical Methods with Computer Programming
Numerical Methods with Computer ProgrammingUtsav Patel
 
The Ring programming language version 1.5.2 book - Part 52 of 181
The Ring programming language version 1.5.2 book - Part 52 of 181The Ring programming language version 1.5.2 book - Part 52 of 181
The Ring programming language version 1.5.2 book - Part 52 of 181Mahmoud Samir Fayed
 
統計的学習の基礎 4章 前半
統計的学習の基礎 4章 前半統計的学習の基礎 4章 前半
統計的学習の基礎 4章 前半Ken'ichi Matsui
 
[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2Kevin Chun-Hsien Hsu
 
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」Ken'ichi Matsui
 
とある断片の超動的言語
とある断片の超動的言語とある断片の超動的言語
とある断片の超動的言語Kiyotaka Oku
 
Accelerating Local Search with PostgreSQL (KNN-Search)
Accelerating Local Search with PostgreSQL (KNN-Search)Accelerating Local Search with PostgreSQL (KNN-Search)
Accelerating Local Search with PostgreSQL (KNN-Search)Jonathan Katz
 
The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.5.4 book - Part 59 of 185The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.5.4 book - Part 59 of 185Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 62 of 189
The Ring programming language version 1.6 book - Part 62 of 189The Ring programming language version 1.6 book - Part 62 of 189
The Ring programming language version 1.6 book - Part 62 of 189Mahmoud Samir Fayed
 
Entity System Architecture with Unity - Unite Europe 2015
Entity System Architecture with Unity - Unite Europe 2015Entity System Architecture with Unity - Unite Europe 2015
Entity System Architecture with Unity - Unite Europe 2015Simon Schmid
 
Ee 3122 numerical methods and statistics sessional credit
Ee 3122 numerical methods and statistics sessional  creditEe 3122 numerical methods and statistics sessional  credit
Ee 3122 numerical methods and statistics sessional creditRaihan Bin-Mofidul
 
Pymongo for the Clueless
Pymongo for the CluelessPymongo for the Clueless
Pymongo for the CluelessChee Leong Chow
 
The Ring programming language version 1.5.3 book - Part 40 of 184
The Ring programming language version 1.5.3 book - Part 40 of 184The Ring programming language version 1.5.3 book - Part 40 of 184
The Ring programming language version 1.5.3 book - Part 40 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 81 of 212
The Ring programming language version 1.10 book - Part 81 of 212The Ring programming language version 1.10 book - Part 81 of 212
The Ring programming language version 1.10 book - Part 81 of 212Mahmoud Samir Fayed
 
What Have The Properties Ever Done For Us
What Have The Properties Ever Done For UsWhat Have The Properties Ever Done For Us
What Have The Properties Ever Done For UsMiklĂłs Martin
 
Weather of the Century: Design and Performance
Weather of the Century: Design and PerformanceWeather of the Century: Design and Performance
Weather of the Century: Design and PerformanceMongoDB
 

Mais procurados (20)

The Ring programming language version 1.3 book - Part 43 of 88
The Ring programming language version 1.3 book - Part 43 of 88The Ring programming language version 1.3 book - Part 43 of 88
The Ring programming language version 1.3 book - Part 43 of 88
 
ゼロから始めるScala文法
ゼロから始めるScala文法ゼロから始めるScala文法
ゼロから始めるScala文法
 
Numerical Methods with Computer Programming
Numerical Methods with Computer ProgrammingNumerical Methods with Computer Programming
Numerical Methods with Computer Programming
 
The Ring programming language version 1.5.2 book - Part 52 of 181
The Ring programming language version 1.5.2 book - Part 52 of 181The Ring programming language version 1.5.2 book - Part 52 of 181
The Ring programming language version 1.5.2 book - Part 52 of 181
 
統計的学習の基礎 4章 前半
統計的学習の基礎 4章 前半統計的学習の基礎 4章 前半
統計的学習の基礎 4章 前半
 
[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2
 
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
 
とある断片の超動的言語
とある断片の超動的言語とある断片の超動的言語
とある断片の超動的言語
 
C++ TUTORIAL 7
C++ TUTORIAL 7C++ TUTORIAL 7
C++ TUTORIAL 7
 
Accelerating Local Search with PostgreSQL (KNN-Search)
Accelerating Local Search with PostgreSQL (KNN-Search)Accelerating Local Search with PostgreSQL (KNN-Search)
Accelerating Local Search with PostgreSQL (KNN-Search)
 
The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.5.4 book - Part 59 of 185The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.5.4 book - Part 59 of 185
 
The Ring programming language version 1.6 book - Part 62 of 189
The Ring programming language version 1.6 book - Part 62 of 189The Ring programming language version 1.6 book - Part 62 of 189
The Ring programming language version 1.6 book - Part 62 of 189
 
Entity System Architecture with Unity - Unite Europe 2015
Entity System Architecture with Unity - Unite Europe 2015Entity System Architecture with Unity - Unite Europe 2015
Entity System Architecture with Unity - Unite Europe 2015
 
Ee 3122 numerical methods and statistics sessional credit
Ee 3122 numerical methods and statistics sessional  creditEe 3122 numerical methods and statistics sessional  credit
Ee 3122 numerical methods and statistics sessional credit
 
Pymongo for the Clueless
Pymongo for the CluelessPymongo for the Clueless
Pymongo for the Clueless
 
The Ring programming language version 1.5.3 book - Part 40 of 184
The Ring programming language version 1.5.3 book - Part 40 of 184The Ring programming language version 1.5.3 book - Part 40 of 184
The Ring programming language version 1.5.3 book - Part 40 of 184
 
PMED Undergraduate Workshop - R Tutorial for PMED Undegraduate Workshop - Xi...
PMED Undergraduate Workshop - R Tutorial for PMED Undegraduate Workshop  - Xi...PMED Undergraduate Workshop - R Tutorial for PMED Undegraduate Workshop  - Xi...
PMED Undergraduate Workshop - R Tutorial for PMED Undegraduate Workshop - Xi...
 
The Ring programming language version 1.10 book - Part 81 of 212
The Ring programming language version 1.10 book - Part 81 of 212The Ring programming language version 1.10 book - Part 81 of 212
The Ring programming language version 1.10 book - Part 81 of 212
 
What Have The Properties Ever Done For Us
What Have The Properties Ever Done For UsWhat Have The Properties Ever Done For Us
What Have The Properties Ever Done For Us
 
Weather of the Century: Design and Performance
Weather of the Century: Design and PerformanceWeather of the Century: Design and Performance
Weather of the Century: Design and Performance
 

Semelhante a Problem Solving Techniques For Evolutionary Design

20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstractionIntro C# Book
 
PVS-Studio in 2019
PVS-Studio in 2019PVS-Studio in 2019
PVS-Studio in 2019Andrey Karpov
 
How Data Flow analysis works in a static code analyzer
How Data Flow analysis works in a static code analyzerHow Data Flow analysis works in a static code analyzer
How Data Flow analysis works in a static code analyzerAndrey Karpov
 
From Trill to Quill: Pushing the Envelope of Functionality and Scale
From Trill to Quill: Pushing the Envelope of Functionality and ScaleFrom Trill to Quill: Pushing the Envelope of Functionality and Scale
From Trill to Quill: Pushing the Envelope of Functionality and ScaleBadrish Chandramouli
 
New Java Date/Time API
New Java Date/Time APINew Java Date/Time API
New Java Date/Time APIJuliet Nkwor
 
Build tic tac toe with javascript (3:28)
Build tic tac toe with javascript (3:28)Build tic tac toe with javascript (3:28)
Build tic tac toe with javascript (3:28)Thinkful
 
Implement a function in c++ which takes in a vector of integers and .pdf
Implement a function in c++ which takes in a vector of integers and .pdfImplement a function in c++ which takes in a vector of integers and .pdf
Implement a function in c++ which takes in a vector of integers and .pdffeelingspaldi
 
Mutation Testing with PIT
Mutation Testing with PITMutation Testing with PIT
Mutation Testing with PITRafał Leszko
 
Hypercritical C++ Code Review
Hypercritical C++ Code ReviewHypercritical C++ Code Review
Hypercritical C++ Code ReviewAndrey Karpov
 
Programming exercises
Programming exercisesProgramming exercises
Programming exercisesTerry Yin
 
Lyon jug-how-to-fail-at-benchmarking
Lyon jug-how-to-fail-at-benchmarkingLyon jug-how-to-fail-at-benchmarking
Lyon jug-how-to-fail-at-benchmarkingPierre Laporte
 
Java beginners meetup: Introduction to class and application design
Java beginners meetup: Introduction to class and application designJava beginners meetup: Introduction to class and application design
Java beginners meetup: Introduction to class and application designPatrick Kostjens
 
Planet-HTML5-Game-Engine Javascript Performance Enhancement
Planet-HTML5-Game-Engine Javascript Performance EnhancementPlanet-HTML5-Game-Engine Javascript Performance Enhancement
Planet-HTML5-Game-Engine Javascript Performance Enhancementup2soul
 
C++ L03-Control Structure
C++ L03-Control StructureC++ L03-Control Structure
C++ L03-Control StructureMohammad Shaker
 
MySQL 8.0 Preview: What Is Coming?
MySQL 8.0 Preview: What Is Coming?MySQL 8.0 Preview: What Is Coming?
MySQL 8.0 Preview: What Is Coming?Gabriela Ferrara
 
Mutation testing with PIT
Mutation testing with PITMutation testing with PIT
Mutation testing with PITRafał Leszko
 
FITC '14 Toronto - Technology, a means to an end
FITC '14 Toronto - Technology, a means to an endFITC '14 Toronto - Technology, a means to an end
FITC '14 Toronto - Technology, a means to an endThibault Imbert
 

Semelhante a Problem Solving Techniques For Evolutionary Design (20)

201801 CSE240 Lecture 15
201801 CSE240 Lecture 15201801 CSE240 Lecture 15
201801 CSE240 Lecture 15
 
JavaScript Refactoring
JavaScript RefactoringJavaScript Refactoring
JavaScript Refactoring
 
20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstraction
 
PVS-Studio in 2019
PVS-Studio in 2019PVS-Studio in 2019
PVS-Studio in 2019
 
JavaTalks: OOD principles
JavaTalks: OOD principlesJavaTalks: OOD principles
JavaTalks: OOD principles
 
How Data Flow analysis works in a static code analyzer
How Data Flow analysis works in a static code analyzerHow Data Flow analysis works in a static code analyzer
How Data Flow analysis works in a static code analyzer
 
From Trill to Quill: Pushing the Envelope of Functionality and Scale
From Trill to Quill: Pushing the Envelope of Functionality and ScaleFrom Trill to Quill: Pushing the Envelope of Functionality and Scale
From Trill to Quill: Pushing the Envelope of Functionality and Scale
 
New Java Date/Time API
New Java Date/Time APINew Java Date/Time API
New Java Date/Time API
 
Build tic tac toe with javascript (3:28)
Build tic tac toe with javascript (3:28)Build tic tac toe with javascript (3:28)
Build tic tac toe with javascript (3:28)
 
Implement a function in c++ which takes in a vector of integers and .pdf
Implement a function in c++ which takes in a vector of integers and .pdfImplement a function in c++ which takes in a vector of integers and .pdf
Implement a function in c++ which takes in a vector of integers and .pdf
 
Mutation Testing with PIT
Mutation Testing with PITMutation Testing with PIT
Mutation Testing with PIT
 
Hypercritical C++ Code Review
Hypercritical C++ Code ReviewHypercritical C++ Code Review
Hypercritical C++ Code Review
 
Programming exercises
Programming exercisesProgramming exercises
Programming exercises
 
Lyon jug-how-to-fail-at-benchmarking
Lyon jug-how-to-fail-at-benchmarkingLyon jug-how-to-fail-at-benchmarking
Lyon jug-how-to-fail-at-benchmarking
 
Java beginners meetup: Introduction to class and application design
Java beginners meetup: Introduction to class and application designJava beginners meetup: Introduction to class and application design
Java beginners meetup: Introduction to class and application design
 
Planet-HTML5-Game-Engine Javascript Performance Enhancement
Planet-HTML5-Game-Engine Javascript Performance EnhancementPlanet-HTML5-Game-Engine Javascript Performance Enhancement
Planet-HTML5-Game-Engine Javascript Performance Enhancement
 
C++ L03-Control Structure
C++ L03-Control StructureC++ L03-Control Structure
C++ L03-Control Structure
 
MySQL 8.0 Preview: What Is Coming?
MySQL 8.0 Preview: What Is Coming?MySQL 8.0 Preview: What Is Coming?
MySQL 8.0 Preview: What Is Coming?
 
Mutation testing with PIT
Mutation testing with PITMutation testing with PIT
Mutation testing with PIT
 
FITC '14 Toronto - Technology, a means to an end
FITC '14 Toronto - Technology, a means to an endFITC '14 Toronto - Technology, a means to an end
FITC '14 Toronto - Technology, a means to an end
 

Mais de Naresh Jain

Agile India 2019 Conference Welcome Note
Agile India 2019 Conference Welcome NoteAgile India 2019 Conference Welcome Note
Agile India 2019 Conference Welcome NoteNaresh Jain
 
Organizational Resilience
Organizational ResilienceOrganizational Resilience
Organizational ResilienceNaresh Jain
 
Improving the Quality of Incoming Code
Improving the Quality of Incoming CodeImproving the Quality of Incoming Code
Improving the Quality of Incoming CodeNaresh Jain
 
Agile India 2018 Conference Summary
Agile India 2018 Conference SummaryAgile India 2018 Conference Summary
Agile India 2018 Conference SummaryNaresh Jain
 
Agile India 2018 Conference
Agile India 2018 ConferenceAgile India 2018 Conference
Agile India 2018 ConferenceNaresh Jain
 
Agile India 2018 Conference
Agile India 2018 ConferenceAgile India 2018 Conference
Agile India 2018 ConferenceNaresh Jain
 
Agile India 2018 Conference
Agile India 2018 ConferenceAgile India 2018 Conference
Agile India 2018 ConferenceNaresh Jain
 
Pilgrim's Progress to the Promised Land by Robert Virding
Pilgrim's Progress to the Promised Land by Robert VirdingPilgrim's Progress to the Promised Land by Robert Virding
Pilgrim's Progress to the Promised Land by Robert VirdingNaresh Jain
 
Concurrent languages are Functional by Francesco Cesarini
Concurrent languages are Functional by Francesco CesariniConcurrent languages are Functional by Francesco Cesarini
Concurrent languages are Functional by Francesco CesariniNaresh Jain
 
Erlang from behing the trenches by Francesco Cesarini
Erlang from behing the trenches by Francesco CesariniErlang from behing the trenches by Francesco Cesarini
Erlang from behing the trenches by Francesco CesariniNaresh Jain
 
Anatomy of an eCommerce Search Engine by Mayur Datar
Anatomy of an eCommerce Search Engine by Mayur DatarAnatomy of an eCommerce Search Engine by Mayur Datar
Anatomy of an eCommerce Search Engine by Mayur DatarNaresh Jain
 
Setting up Continuous Delivery Culture for a Large Scale Mobile App
Setting up Continuous Delivery Culture for a Large Scale Mobile AppSetting up Continuous Delivery Culture for a Large Scale Mobile App
Setting up Continuous Delivery Culture for a Large Scale Mobile AppNaresh Jain
 
Towards FutureOps: Stable, Repeatable environments from Dev to Prod
Towards FutureOps: Stable, Repeatable environments from Dev to ProdTowards FutureOps: Stable, Repeatable environments from Dev to Prod
Towards FutureOps: Stable, Repeatable environments from Dev to ProdNaresh Jain
 
Value Driven Development by Dave Thomas
Value Driven Development by Dave Thomas Value Driven Development by Dave Thomas
Value Driven Development by Dave Thomas Naresh Jain
 
No Silver Bullets in Functional Programming by Brian McKenna
No Silver Bullets in Functional Programming by Brian McKennaNo Silver Bullets in Functional Programming by Brian McKenna
No Silver Bullets in Functional Programming by Brian McKennaNaresh Jain
 
Functional Programming Conference 2016
Functional Programming Conference 2016Functional Programming Conference 2016
Functional Programming Conference 2016Naresh Jain
 
Agile India 2017 Conference
Agile India 2017 ConferenceAgile India 2017 Conference
Agile India 2017 ConferenceNaresh Jain
 
The Eclipse Way
The Eclipse WayThe Eclipse Way
The Eclipse WayNaresh Jain
 
Unleashing the Power of Automated Refactoring with JDT
Unleashing the Power of Automated Refactoring with JDTUnleashing the Power of Automated Refactoring with JDT
Unleashing the Power of Automated Refactoring with JDTNaresh Jain
 
Getting2Alpha: Turbo-charge your product with Game Thinking by Amy Jo Kim
Getting2Alpha: Turbo-charge your product with Game Thinking by Amy Jo KimGetting2Alpha: Turbo-charge your product with Game Thinking by Amy Jo Kim
Getting2Alpha: Turbo-charge your product with Game Thinking by Amy Jo KimNaresh Jain
 

Mais de Naresh Jain (20)

Agile India 2019 Conference Welcome Note
Agile India 2019 Conference Welcome NoteAgile India 2019 Conference Welcome Note
Agile India 2019 Conference Welcome Note
 
Organizational Resilience
Organizational ResilienceOrganizational Resilience
Organizational Resilience
 
Improving the Quality of Incoming Code
Improving the Quality of Incoming CodeImproving the Quality of Incoming Code
Improving the Quality of Incoming Code
 
Agile India 2018 Conference Summary
Agile India 2018 Conference SummaryAgile India 2018 Conference Summary
Agile India 2018 Conference Summary
 
Agile India 2018 Conference
Agile India 2018 ConferenceAgile India 2018 Conference
Agile India 2018 Conference
 
Agile India 2018 Conference
Agile India 2018 ConferenceAgile India 2018 Conference
Agile India 2018 Conference
 
Agile India 2018 Conference
Agile India 2018 ConferenceAgile India 2018 Conference
Agile India 2018 Conference
 
Pilgrim's Progress to the Promised Land by Robert Virding
Pilgrim's Progress to the Promised Land by Robert VirdingPilgrim's Progress to the Promised Land by Robert Virding
Pilgrim's Progress to the Promised Land by Robert Virding
 
Concurrent languages are Functional by Francesco Cesarini
Concurrent languages are Functional by Francesco CesariniConcurrent languages are Functional by Francesco Cesarini
Concurrent languages are Functional by Francesco Cesarini
 
Erlang from behing the trenches by Francesco Cesarini
Erlang from behing the trenches by Francesco CesariniErlang from behing the trenches by Francesco Cesarini
Erlang from behing the trenches by Francesco Cesarini
 
Anatomy of an eCommerce Search Engine by Mayur Datar
Anatomy of an eCommerce Search Engine by Mayur DatarAnatomy of an eCommerce Search Engine by Mayur Datar
Anatomy of an eCommerce Search Engine by Mayur Datar
 
Setting up Continuous Delivery Culture for a Large Scale Mobile App
Setting up Continuous Delivery Culture for a Large Scale Mobile AppSetting up Continuous Delivery Culture for a Large Scale Mobile App
Setting up Continuous Delivery Culture for a Large Scale Mobile App
 
Towards FutureOps: Stable, Repeatable environments from Dev to Prod
Towards FutureOps: Stable, Repeatable environments from Dev to ProdTowards FutureOps: Stable, Repeatable environments from Dev to Prod
Towards FutureOps: Stable, Repeatable environments from Dev to Prod
 
Value Driven Development by Dave Thomas
Value Driven Development by Dave Thomas Value Driven Development by Dave Thomas
Value Driven Development by Dave Thomas
 
No Silver Bullets in Functional Programming by Brian McKenna
No Silver Bullets in Functional Programming by Brian McKennaNo Silver Bullets in Functional Programming by Brian McKenna
No Silver Bullets in Functional Programming by Brian McKenna
 
Functional Programming Conference 2016
Functional Programming Conference 2016Functional Programming Conference 2016
Functional Programming Conference 2016
 
Agile India 2017 Conference
Agile India 2017 ConferenceAgile India 2017 Conference
Agile India 2017 Conference
 
The Eclipse Way
The Eclipse WayThe Eclipse Way
The Eclipse Way
 
Unleashing the Power of Automated Refactoring with JDT
Unleashing the Power of Automated Refactoring with JDTUnleashing the Power of Automated Refactoring with JDT
Unleashing the Power of Automated Refactoring with JDT
 
Getting2Alpha: Turbo-charge your product with Game Thinking by Amy Jo Kim
Getting2Alpha: Turbo-charge your product with Game Thinking by Amy Jo KimGetting2Alpha: Turbo-charge your product with Game Thinking by Amy Jo Kim
Getting2Alpha: Turbo-charge your product with Game Thinking by Amy Jo Kim
 

Último

Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...soginsider
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 

Último (20)

Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 

Problem Solving Techniques For Evolutionary Design

  • 1. Problem Solving Techniques For Evolutionary Design Distilling Down Any Problem to Its Crux Naresh Jain naresh@xnsio.com @nashjain https://xnsio.com
  • 2. Rounding Up to the Closest 5 Cents • In my billing application • Given the price of an item comes up to $20.23 after tax • I want to round up 23 cents to the closest 5 cents denomination .i.e. 25 cents • So I can charge $20.25 • https://github.com/nashjain/rounding_logic • https://help.github.com/categories/54/articles
  • 3. Tests @Test public void shouldLeaveAsIsIfAlreadyInDenominationsOf5Cents() { assertEquals(20.25, round(20.25), 0.01); } @Test public void shouldRoundUpToNext5Cents() { assertEquals(20.25, round(20.24), 0.01); } @Test public void shouldRoundUpEvenIfAmountIsLessThanPoint023() { assertEquals(20.25, round(20.21), 0.01); } https://github.com/nashjain/rounding_logic
  • 4. Rounding Up - Answer • var price = 20.23; • var rounded_price = ceil(price / 0.05) * 0.05; or • var rounded_price = ceil(price * 20) / 20;
  • 5. Hotel Room Charge • Calculate the bill amount based on the number of hotel nights the guest has stayed in the hotel. • Per hotel night is charged at 4999 INR for single occupancy and 5499 INR for double occupancy. • Hotels have a standard 12:00 noon checkin and checkout. • Early Checkin: Guest can request to checkin early (before 12:00 noon.) If they checkin between 9 and 12, they are charged 50% extra. If they checkin before 9 AM, then they are charged full night charge. • Late Checkout: Guest can request a late checkout. If they checkout after 12 noon and before 3, they are charged 50% extra and if they checkout after 3:00 PM, they have to pay one whole night's extra charge.
  • 6. function calculate_hotel_charge(occupancy, hotel_checkin, hotel_checkout) { var per_night_rate = occupancy == ‘Single’ ? 4999 : 5499; return per_night_rate * total_nights(hotel_checkin, hotel_checkout); } function total_nights(hotel_checkin, hotel_checkout) { return max(actual_nights(hotel_checkin, hotel_checkout) + early_checkin_nights(hotel_checkin) + late_checkout_nights(hotel_checkout), 1); } function actual_nights(hotel_checkin, hotel_checkout) { return floor((hotel_checkout - hotel_checkin) / (24 * 60 * 60 * 1000)); } functional early_checkin_nights(hotel_checkin) { if(hotel_checkin.getHours() > 12) return 0; if(hotel_checkin.getHours() > 9) return 0.5; return 1; } Hotel Room Charge Solution functional late_checkout_nights(hotel_checkout) { if(hotel_checkin.getHours() < 12) return 0; if(hotel_checkin.getHours() < 3) return 0.5; return 1; }
  • 7. High-level Approach Eliminate Noise Divide & Conquer Test Data Constraints Simple Design Manual Debug Refactor Throw Away Create Add Come up with Simplify the Problem Prioritise Remove constrains Works? More Constraints Exit? Yes No
  • 8. Problem-Solving Strategies • Sandboxing: solving the problem in a model of the system before applying it to the real system • Metaphor: using a solution that solves an analogous problem • Brainstorming: exploring a large number of solutions or ideas and combining and developing them until an optimum solution is found • Divide and conquer: breaking down a large, complex problem into smaller, solvable problems • Hypothesis testing: assuming a possible explanation to the problem and trying to prove (or disprove) the assumption • Reduction: transforming the problem into another problem for which solutions exist • Trial-and-error: testing possible solutions until the right one’s Adapted from: http://en.wikipedia.org/wiki/Problem_solving#Problem-solving_strategies
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23. IP Address Range • Each country has blocks of IPv4 address range assigned to it • Given I have an IP address I want to gure out which country it belong to
  • 24. Start End Total IPs Country 1.6.0.0 1.7.255.255 131072 India 1.22.0.0 1.23.255.255 131072 India 1.186.0.0 1.186.255.255 65536 India 1.0.32.0 1.0.63.255 8192 China 1.1.16.0 1.1.31.255 4096 China 1.4.16.0 1.4.31.255 4096 Japan • https://github.com/nashjain/ip2country • 196 countries with 100s of such blocks
  • 25. public long convertToNumericIp(String ip) { long numericIp = 0; String[] octets = ip.split(“."); for (int i = 0; i < 4; ++i) numericIp += parseInt(octets[i]) * Math.pow(256, 3 - i); return numericIp; } 243.131.122.231 243*256*256*256 + 131*256*256 + 122*256 + 231 = 4085480167
  • 26.
  • 27. Snakes and Ladders • One or more players can play the game • Typical board size is 10 x10, but user can specify different board size • User can decide the game mode (Easy = 5 snakes and ladders, Medium = 10 snakes and ladders, Hard = 20 snakes and ladders.) Default to easy mode. • After each move, snakes and ladders could move, but at least after each game, they should move. • Game takes the names of all the players and reports the name of the winner. • Random player gets to start
  • 28. def move(players, player_turn) new_position = players[player_turn] + throw_dice new_position = @snakes_ladders[new_position] if @snakes_ladders.has_key?(new_position) return player_turn if new_position >= @board_size players[player_turn] = new_position next_player = (player_turn + 1) % players.length move(players, next_player) end https://github.com/nashjain/snakes_n_ladders
  • 29. Medical Age Printer Age Reported in Greater than 1Year <Patient Name> is #Years old > 1 Month & < 1Year <Patient Name> is # Months old > 1 Day & < 1 Month <Patient Name> is # Days old > 1 Hr & < 1 Day <Patient Name> is # Hours old Doctors and Nurses might like to add and remove new Durations. For Ex: If they add Decade, and Patient’s age is greater than 10 years, then age should be reported as <Patient Name> is # Decades old. Similarly: If they add Week, and Patient’s age is greater than 7 Day, but less than a month, then age should be reported as <Patient Name> is # Weeks old. https://github.com/nashjain/map
  • 30. private static nal long MILLIS_IN_MIN = 60 * 1000L; private static nal long MILLIS_IN_HOUR = MILLIS_IN_MIN * 60; private static nal long MILLIS_IN_DAY = MILLIS_IN_HOUR * 24; private static nal long MILLIS_IN_MONTH = MILLIS_IN_DAY * 30; private static nal long MILLIS_IN_YEAR = MILLIS_IN_DAY * 365; private nal TreeMap<Long, String> millisPerUnit = new TreeMap<Long, String>() { { put(MILLIS_IN_HOUR, "Hours"); put(MILLIS_IN_DAY, "Days"); put(MILLIS_IN_MONTH, "Months"); put(MILLIS_IN_YEAR, "Year"); } }; public String since(Date dob) { long deltaInMillis = differenceInMillisFromNow(dob); Entry<Long, String> duration = millisPerUnit.floorEntry(deltaInMillis); if (duration == null) return "0 Hours"; return deltaInMillis / duration.getKey() + " " + duration.getValue(); } private long differenceInMillisFromNow(Date date) { return clock.now() - date.getTime(); }
  • 31. Recap Eliminate Noise Divide & Conquer Test Data Constraints Simple Design Manual Debug Refactor Throw Away Create Add Come up with Simplify the Problem Prioritise Remove constrains Works? More Constraints Exit? Yes No
  • 33. Pick a Solution after Trying at least 3 Approaches
  • 34. "Perfection (in design) is achieved not when there is nothing more to add, but rather when there is nothing more to take away." – Eric S Raymond
  • 38. Practice An Hour Each Day