SlideShare a Scribd company logo
it.ciroppina
Are Code Katas always Agile?
a brief analysis of a Kata solution(*) to the famous
TW’s Merchant’s Guide to the Galaxy problem
* find code here:
https://github.com/sudarshan89/merchant-galaxy
they believe code-katas design is always Agile,
here U are a Java-1.8 implementation of the
Roman-Numerals validation:
it.ciroppina
sorry, there(jump) is a lot of
magic names in the code
now here U are another (my) implementation of the
same validation, googleing a suitable regEx:
it.ciroppina
sorry, I dont know how to fill the slide
not wanting to mention the time it needs to code
the Kata solution, when compared with mine, here U
are the execution times (almost the same):
Kata Solution my Solution
it.ciroppina
validation functions are static in both codes
the «Merchant’s Guide» problems is a money
conversion one, where RareMetals (decimal) credits
are to be calculated from galactic (roman) strange
currencies’ expressions such as:
- glob (roman I)
- prok (roman V)
- pish (roman X)
- tegj (roman L)
the problem questions «how much»(s) and «how
many»(s) the solution must answer, producing a
well-defined and ordered console output
it.ciroppina
how to parse galactic (roman) strange currencies’
expressions (given as input to the solution)?
the code kata-er identified three kinds of expressions, in the input
lines (a plain-text lines’ file):
1) Galactic Currency Expression Transactions: i.e. how much is pish tegj glob glob ?
2) Per unit RareMetal value transactions: i.e. glob glob Silver is 34 Credits
3) Total credit evaluation transactions: i.e. how many Credits is glob prok Silver ?
1) and 3) are acknowledgeable by char ‘?’ and string «how»
2) is acknowledgeable by the absence of string «how»
Actually, the full input is composed of:
- 4 initialization sentences, followed by
- 3 RareMetal configuration sentences, followed by
- 5 questions to be answered (the last of them being unanswerable)
it.ciroppina
they believe code-katas design is always Agile,
here U are a Java-1.8 implementation of the
galactic expressions’ parsing problem – page 1
it.ciroppina
overall McCabe metrics here is: 6
max method metric is: 3
they believe code-katas design is always Agile,
here U are a Java-1.8 implementation of the
galactic expressions’ parsing problem – page 2
it.ciroppina
overall McCabe metrics here is: 10
max method metric is: 3
they believe code-katas design is always Agile,
here U are a Java-1.8 implementation of the
galactic expressions’ parsing problem – page 3
it.ciroppina
no enough room on this slide to
show all the code
they believe code-katas design is always Agile,
here U are a Java-1.8 implementation of the
galactic expressions’ parsing problem – page 4
it.ciroppina
nonetheless Kata’s methods are short (vertically);
only they suffer a little bit excessive horizontal
lenght: U can count till 8 inline methods’
invocations !
now here U are another (my) implementation of the
galactic expressions’ parsing problem – page 1
First of all:
- Configure NUMERALS
(Roman symbols)
- Configure UNITS
(Rare Metal units)
and compute their
unitary value
it.ciroppina
now here U are another (my) implementation of the
galactic expressions’ parsing problem – page 2
by the Help of a
simple Enum of
Symbols
it.ciroppina
now here U are another (my) implementation of the
galactic expressions’ parsing problem – page 3
and, in the end,
provide a method
that «decimalize»
the strange
galactic
expressions
it.ciroppina
both solutions, Kata-er’s and mine, provide tests
and main classes for execution
Kata App body My App body
it.ciroppina
difficult to read config, compute, answer
what about the Code Kata design ?
according to the Kata-er:
Some of the key concepts fundamental to my approach are:
- Use OO principles to drive the solution
- Use language used in the problem statement to drive class name's in the solution
- Divide the input into transaction types
a) Galactic Currency Expression Transaction :- how much is pish tegj glob glob ?
b) Per unit Rare metal value transaction :- glob glob Silver is 34 Credits
c) Total credit evaluation transaction :- how many Credits is glob prok Silver ?
- Once the Galactic Currency Expression Transaction can be evaluated then it can be re-used to evaluate Per unit
Rare metal value transaction and after you have a) and b) then they can be used to evaluate c)
but those do not look like design issues
it.ciroppina
what about the other (my) design ?
statically I read a regEx useful to validate
galactic-roman expression’s correctness. A proper
reader does the job for me:
public static String ROMANS_REGEX = null;
static {
ROMANS_REGEX = InputReader.loadThis("roman.regex");
}
…then, statically I ask an InputProcessor to load
the input lines for me:
public TheApp() {
InputProcessor.config();
}
now all-the-things ‘re ready to work……………………>
it.ciroppina
what about the other (my) design ?
finally all the input lines with a question-mark
are answered, one after the other, in the given
input order:
for (String q : lines) {
if (q.indexOf('?') > -1) {
System.out.println(answerThis(q) ); //console print
}
}
answerThis(q) template method:
- parses q
- compute credits
- prints the proper answer to
the console
it.ciroppina
what about the DESIGN ?
- nor Kata Code neither mine did use of
factory/builder/composition/chain-of-resp
- both solution are mainly based over string’s
parse
- my solution separates resources Loader/Processor
from the functional code
- both solutions make use of Maps/Lists (J1.8
immutables) or Enumeration of symbols
- both solutions separatedly tests the «parts» of
the code
it.ciroppina
METRICS
Kata Code: my Code:
it.ciroppina
it.ciroppina
So, why TW people fired me before hiring
after having evaluted my code for the famous
Merchant’s Guide to the Galaxy
problem ?
nonetheless,
I stay:

More Related Content

Similar to are Code Katas always Agile ?

Drilling the Async Library
Drilling the Async LibraryDrilling the Async Library
Drilling the Async Library
Knoldus Inc.
 
Let's Get to the Rapids
Let's Get to the RapidsLet's Get to the Rapids
Let's Get to the Rapids
Maurice Naftalin
 
What`s New in Java 8
What`s New in Java 8What`s New in Java 8
What`s New in Java 8
Mohsen Zainalpour
 
Polyglot and Functional Programming (OSCON 2012)
Polyglot and Functional Programming (OSCON 2012)Polyglot and Functional Programming (OSCON 2012)
Polyglot and Functional Programming (OSCON 2012)
Martijn Verburg
 
An Experiment with Checking the glibc Library
An Experiment with Checking the glibc LibraryAn Experiment with Checking the glibc Library
An Experiment with Checking the glibc Library
Andrey Karpov
 
C++ Tail Recursion Using 64-bit variables
C++ Tail Recursion Using 64-bit variablesC++ Tail Recursion Using 64-bit variables
C++ Tail Recursion Using 64-bit variables
PVS-Studio
 
Know your platform. 7 things every scala developer should know about jvm
Know your platform. 7 things every scala developer should know about jvmKnow your platform. 7 things every scala developer should know about jvm
Know your platform. 7 things every scala developer should know about jvm
Pawel Szulc
 
Move from C to Go
Move from C to GoMove from C to Go
Move from C to Go
Yu-Shuan Hsieh
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
Marharyta Nedzelska
 
The Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and EverythingThe Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and Everything
Andrey Karpov
 
The Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and EverythingThe Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and Everything
PVS-Studio
 
JAVASCRIPT PPT [Autosaved].pptx
JAVASCRIPT PPT [Autosaved].pptxJAVASCRIPT PPT [Autosaved].pptx
JAVASCRIPT PPT [Autosaved].pptx
AchieversITAravind
 
Full Stack Online Course in Marathahalli| AchieversIT
Full Stack Online Course in Marathahalli| AchieversITFull Stack Online Course in Marathahalli| AchieversIT
Full Stack Online Course in Marathahalli| AchieversIT
AchieversITAravind
 
Large-scale Recommendation Systems on Just a PC
Large-scale Recommendation Systems on Just a PCLarge-scale Recommendation Systems on Just a PC
Large-scale Recommendation Systems on Just a PC
Aapo Kyrölä
 
The State of Lightweight Threads for the JVM
The State of Lightweight Threads for the JVMThe State of Lightweight Threads for the JVM
The State of Lightweight Threads for the JVM
Volkan Yazıcı
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Nayden Gochev
 
Java 8 Lambda
Java 8 LambdaJava 8 Lambda
Java 8 Lambda
François Sarradin
 
DAA Notes.pdf
DAA Notes.pdfDAA Notes.pdf
DAA Notes.pdf
SauravPawar14
 
Finding bugs in the code of LLVM project with the help of PVS-Studio
Finding bugs in the code of LLVM project with the help of PVS-StudioFinding bugs in the code of LLVM project with the help of PVS-Studio
Finding bugs in the code of LLVM project with the help of PVS-Studio
PVS-Studio
 
Data oriented design and c++
Data oriented design and c++Data oriented design and c++
Data oriented design and c++
Mike Acton
 

Similar to are Code Katas always Agile ? (20)

Drilling the Async Library
Drilling the Async LibraryDrilling the Async Library
Drilling the Async Library
 
Let's Get to the Rapids
Let's Get to the RapidsLet's Get to the Rapids
Let's Get to the Rapids
 
What`s New in Java 8
What`s New in Java 8What`s New in Java 8
What`s New in Java 8
 
Polyglot and Functional Programming (OSCON 2012)
Polyglot and Functional Programming (OSCON 2012)Polyglot and Functional Programming (OSCON 2012)
Polyglot and Functional Programming (OSCON 2012)
 
An Experiment with Checking the glibc Library
An Experiment with Checking the glibc LibraryAn Experiment with Checking the glibc Library
An Experiment with Checking the glibc Library
 
C++ Tail Recursion Using 64-bit variables
C++ Tail Recursion Using 64-bit variablesC++ Tail Recursion Using 64-bit variables
C++ Tail Recursion Using 64-bit variables
 
Know your platform. 7 things every scala developer should know about jvm
Know your platform. 7 things every scala developer should know about jvmKnow your platform. 7 things every scala developer should know about jvm
Know your platform. 7 things every scala developer should know about jvm
 
Move from C to Go
Move from C to GoMove from C to Go
Move from C to Go
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
The Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and EverythingThe Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and Everything
 
The Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and EverythingThe Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and Everything
 
JAVASCRIPT PPT [Autosaved].pptx
JAVASCRIPT PPT [Autosaved].pptxJAVASCRIPT PPT [Autosaved].pptx
JAVASCRIPT PPT [Autosaved].pptx
 
Full Stack Online Course in Marathahalli| AchieversIT
Full Stack Online Course in Marathahalli| AchieversITFull Stack Online Course in Marathahalli| AchieversIT
Full Stack Online Course in Marathahalli| AchieversIT
 
Large-scale Recommendation Systems on Just a PC
Large-scale Recommendation Systems on Just a PCLarge-scale Recommendation Systems on Just a PC
Large-scale Recommendation Systems on Just a PC
 
The State of Lightweight Threads for the JVM
The State of Lightweight Threads for the JVMThe State of Lightweight Threads for the JVM
The State of Lightweight Threads for the JVM
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
 
Java 8 Lambda
Java 8 LambdaJava 8 Lambda
Java 8 Lambda
 
DAA Notes.pdf
DAA Notes.pdfDAA Notes.pdf
DAA Notes.pdf
 
Finding bugs in the code of LLVM project with the help of PVS-Studio
Finding bugs in the code of LLVM project with the help of PVS-StudioFinding bugs in the code of LLVM project with the help of PVS-Studio
Finding bugs in the code of LLVM project with the help of PVS-Studio
 
Data oriented design and c++
Data oriented design and c++Data oriented design and c++
Data oriented design and c++
 

Recently uploaded

Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
dakas1
 
fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.
AnkitaPandya11
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
ShulagnaSarkar2
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
mz5nrf0n
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
Peter Muessig
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
GohKiangHock
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
dakas1
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
YAML crash COURSE how to write yaml file for adding configuring details
YAML crash COURSE how to write yaml file for adding configuring detailsYAML crash COURSE how to write yaml file for adding configuring details
YAML crash COURSE how to write yaml file for adding configuring details
NishanthaBulumulla1
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
Remote DBA Services
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
safelyiotech
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
Marcin Chrost
 

Recently uploaded (20)

Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
 
fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
YAML crash COURSE how to write yaml file for adding configuring details
YAML crash COURSE how to write yaml file for adding configuring detailsYAML crash COURSE how to write yaml file for adding configuring details
YAML crash COURSE how to write yaml file for adding configuring details
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
 

are Code Katas always Agile ?

  • 1. it.ciroppina Are Code Katas always Agile? a brief analysis of a Kata solution(*) to the famous TW’s Merchant’s Guide to the Galaxy problem * find code here: https://github.com/sudarshan89/merchant-galaxy
  • 2. they believe code-katas design is always Agile, here U are a Java-1.8 implementation of the Roman-Numerals validation: it.ciroppina sorry, there(jump) is a lot of magic names in the code
  • 3. now here U are another (my) implementation of the same validation, googleing a suitable regEx: it.ciroppina sorry, I dont know how to fill the slide
  • 4. not wanting to mention the time it needs to code the Kata solution, when compared with mine, here U are the execution times (almost the same): Kata Solution my Solution it.ciroppina validation functions are static in both codes
  • 5. the «Merchant’s Guide» problems is a money conversion one, where RareMetals (decimal) credits are to be calculated from galactic (roman) strange currencies’ expressions such as: - glob (roman I) - prok (roman V) - pish (roman X) - tegj (roman L) the problem questions «how much»(s) and «how many»(s) the solution must answer, producing a well-defined and ordered console output it.ciroppina
  • 6. how to parse galactic (roman) strange currencies’ expressions (given as input to the solution)? the code kata-er identified three kinds of expressions, in the input lines (a plain-text lines’ file): 1) Galactic Currency Expression Transactions: i.e. how much is pish tegj glob glob ? 2) Per unit RareMetal value transactions: i.e. glob glob Silver is 34 Credits 3) Total credit evaluation transactions: i.e. how many Credits is glob prok Silver ? 1) and 3) are acknowledgeable by char ‘?’ and string «how» 2) is acknowledgeable by the absence of string «how» Actually, the full input is composed of: - 4 initialization sentences, followed by - 3 RareMetal configuration sentences, followed by - 5 questions to be answered (the last of them being unanswerable) it.ciroppina
  • 7. they believe code-katas design is always Agile, here U are a Java-1.8 implementation of the galactic expressions’ parsing problem – page 1 it.ciroppina overall McCabe metrics here is: 6 max method metric is: 3
  • 8. they believe code-katas design is always Agile, here U are a Java-1.8 implementation of the galactic expressions’ parsing problem – page 2 it.ciroppina overall McCabe metrics here is: 10 max method metric is: 3
  • 9. they believe code-katas design is always Agile, here U are a Java-1.8 implementation of the galactic expressions’ parsing problem – page 3 it.ciroppina no enough room on this slide to show all the code
  • 10. they believe code-katas design is always Agile, here U are a Java-1.8 implementation of the galactic expressions’ parsing problem – page 4 it.ciroppina nonetheless Kata’s methods are short (vertically); only they suffer a little bit excessive horizontal lenght: U can count till 8 inline methods’ invocations !
  • 11. now here U are another (my) implementation of the galactic expressions’ parsing problem – page 1 First of all: - Configure NUMERALS (Roman symbols) - Configure UNITS (Rare Metal units) and compute their unitary value it.ciroppina
  • 12. now here U are another (my) implementation of the galactic expressions’ parsing problem – page 2 by the Help of a simple Enum of Symbols it.ciroppina
  • 13. now here U are another (my) implementation of the galactic expressions’ parsing problem – page 3 and, in the end, provide a method that «decimalize» the strange galactic expressions it.ciroppina
  • 14. both solutions, Kata-er’s and mine, provide tests and main classes for execution Kata App body My App body it.ciroppina difficult to read config, compute, answer
  • 15. what about the Code Kata design ? according to the Kata-er: Some of the key concepts fundamental to my approach are: - Use OO principles to drive the solution - Use language used in the problem statement to drive class name's in the solution - Divide the input into transaction types a) Galactic Currency Expression Transaction :- how much is pish tegj glob glob ? b) Per unit Rare metal value transaction :- glob glob Silver is 34 Credits c) Total credit evaluation transaction :- how many Credits is glob prok Silver ? - Once the Galactic Currency Expression Transaction can be evaluated then it can be re-used to evaluate Per unit Rare metal value transaction and after you have a) and b) then they can be used to evaluate c) but those do not look like design issues it.ciroppina
  • 16. what about the other (my) design ? statically I read a regEx useful to validate galactic-roman expression’s correctness. A proper reader does the job for me: public static String ROMANS_REGEX = null; static { ROMANS_REGEX = InputReader.loadThis("roman.regex"); } …then, statically I ask an InputProcessor to load the input lines for me: public TheApp() { InputProcessor.config(); } now all-the-things ‘re ready to work……………………> it.ciroppina
  • 17. what about the other (my) design ? finally all the input lines with a question-mark are answered, one after the other, in the given input order: for (String q : lines) { if (q.indexOf('?') > -1) { System.out.println(answerThis(q) ); //console print } } answerThis(q) template method: - parses q - compute credits - prints the proper answer to the console it.ciroppina
  • 18. what about the DESIGN ? - nor Kata Code neither mine did use of factory/builder/composition/chain-of-resp - both solution are mainly based over string’s parse - my solution separates resources Loader/Processor from the functional code - both solutions make use of Maps/Lists (J1.8 immutables) or Enumeration of symbols - both solutions separatedly tests the «parts» of the code it.ciroppina
  • 19. METRICS Kata Code: my Code: it.ciroppina
  • 20. it.ciroppina So, why TW people fired me before hiring after having evaluted my code for the famous Merchant’s Guide to the Galaxy problem ? nonetheless, I stay: