SlideShare une entreprise Scribd logo
1  sur  29
Télécharger pour lire hors ligne
Quick intro to Clean Coding
Aleksey Drobnych
Java Trainer
● What is bad code
● What is good code
● Code smells
● Tests
● Refactoring
What this all about?
I knew one sales guy who predicted that programming languages and
programmers will disappear some time because of power of next gen
smart business wizards.
What is programm? This is just set of business receipts written with
maximal level of precision and detalisation. It's impossible to do using
human language. It's too flexible. We need to invent specific DSL for the
system. And OOP is one of possible ways for this purpose.
Foreword
Bad code
if (this == null)
{
// Logic here
}
switch (number)
{
case 0: printf("0"); break;
case 1: printf("1"); break;
case 2: printf("2"); break;
case 3: printf("3"); break;
case 4: printf("4"); break;
case 5: printf("5"); break;
case 6: printf("6"); break;
case 7: printf("7"); break;
case 8: printf("8"); break;
case 9: printf("9"); break;
}
public int m_otCalc() {
return iThsWkd * iThsRte +
(int) Math.round(0.5 * iThsRte *
Math.max(0, iThsWkd - 400)
);
}
https://gist.github.com/adrobnych/5183752
Path one
● Code that just works (that's easy, man!)
● More Code that just works (huh, we'll survive!)
● Mmmooorrreee CCoodeee thaaat j juust wooork s
● MMMmmmmmmmmmmm mmmmmmmmm
● Great Technical Debt
Two ways of Code
Path two
● Code that just works
● Tests
● Refinement (finally we've done this spike)
● Test
● More Code just enough for Test
● Refactoring
● Test
● More Code just enough for Test
● Refactoring
● look mum no hands!
Two ways of Code
Good Code
● Code needs to work today just
once
Simplisity
● Code needs to be easy for
change forever
Ability to grow
● Big Upfront Design
● We have no time for tests
● Just do so as you did before
● Don't touch it until it works
Know your daemons
● Any code can be rewritten
● Tests are your safety belt
● Leave the campground cleaner
than you found it
Know your angels
Transparent: The consequence of change are visible and
predictable
Reasonable: The cost of adding a new feature is
proportional to its value
Usable: if you already wrote the code, you can reuse it
Exemplary: More code like this would be good for your
app
How to judge the goodness
of code
● Object Oriented Design Patterns
● Object Oriented Design Principles
● Knowledge of language and Libs
● Code Smells
● Tests
● Code Reviews
Clean Code Toolset
● Object Oriented Design Patterns
In software engineering, a design pattern is a general reusable solution to
a commonly occurring problem within a given context in software design. A
design pattern is not a finished design that can be transformed directly into
source or machine code. It is a description or template for how to solve a
problem that can be used in many different situations. Patterns are
formalized best practices that the programmer must implement themselves
in the application.Object-oriented design patterns typically show
relationships and interactions between classes or objects, without
specifying the final application classes or objects that are involved.
Clean Code Toolset
● Object Oriented Design Principles
In computer programming, SOLID (Single responsibility, Open-closed,
Liskov substitution, Interface segregation and Dependency inversion)
is a mnemonic acronym introduced by Michael Feathers for the "first five
principles" identified by Robert C. Martin in the early 2000s that stands for
five basic principles of object-oriented programming and design. The
principles when applied together intend to make it more likely that
aprogrammer will create a system that is easy to maintain and extend over
time.The principles of SOLID are guidelines that can be applied while
working on software to remove code smells by causing the programmer to
refactor the software's source code until it is both legible and extensible. It
is typically used with test-driven development, and is part of an overall
strategy of agile and adaptive programming.
Clean Code Toolset
● Knowledge of language and Libs
List of Efective Java units
Clean Code Toolset
● Code Smells
In computer programming, code smell is any symptom in the source code
of a program that possibly indicates a deeper problem. Code smells are
usually not bugs—they are not technically incorrect and don't currently
prevent the program from functioning. Instead, they indicate weaknesses in
design that may be slowing down development or increasing the risk of
bugs or failures in the future.
Clean Code Toolset
● Tests
Test-driven development (TDD) is a software development process that
relies on the repetition of a very short development cycle: first the
developer writes an (initially failing) automated test case that defines a
desired improvement or new function, then produces the minimum amount
of code to pass that test, and finally refactors the new code to acceptable
standards. Kent Beck, who is credited with having developed or
'rediscovered' the technique, stated in 2003 that TDD encourages simple
designs and inspires confidence.
Clean Code Toolset
● Code Reviews and refactorings
Code refactoring is a "disciplined technique for restructuring an existing
body of code, altering its internal structure without changing its external
behavior", undertaken in order to improve some of the nonfunctional
attributes of the software. Advantages include improved code readability
and reduced complexity to improve the maintainability of the source code,
as well as a more expressive internal architecture or object model to
improve extensibility.
Clean Code Toolset
Small refactorings way:
https://github.com/adrobnych/CleanCalc
Live refactoring session
Quick way: Patterns
Live refactoring session
Write tests.
If your Classes and Methods are just DSL of the
system, then tests is your first and most
important way to start talk with silent system.
Finally both your tests and the system will talk
Perfect Language.
Keep your tests as a grammar for your DSL.
From where I shall start?
Don't write comments.
85% of developer job is reading of existing code.
Keep your code readable, self-explanatory,
intentional. Comments are poor deodorant for
your code. If you will find yourself writing
comment then you can't express your intent in
code. This is smell. Refactor.
From where I shall start?
What's next?
Object Oriented Design
Effective Java
Clean Code, Code Smells, Refactorings
OOD Patterns
TDD
Crossroad
Quick Intro to Clean Coding

Contenu connexe

Tendances

Measuring Code Quality in WTF/min.
Measuring Code Quality in WTF/min. Measuring Code Quality in WTF/min.
Measuring Code Quality in WTF/min. David Gómez García
 
Software Engineering Culture - Improve Code Quality
Software Engineering Culture - Improve Code QualitySoftware Engineering Culture - Improve Code Quality
Software Engineering Culture - Improve Code QualityDmytro Patserkovskyi
 
Agile development with Ruby
Agile development with RubyAgile development with Ruby
Agile development with Rubykhelll
 
Tdd in php a brief example
Tdd in php   a brief exampleTdd in php   a brief example
Tdd in php a brief exampleJeremy Kendall
 
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...VincitOy
 
Unwritten Manual for Pair Programming
Unwritten Manual for Pair ProgrammingUnwritten Manual for Pair Programming
Unwritten Manual for Pair ProgrammingLemi Orhan Ergin
 
Quality metrics and angular js applications
Quality metrics and angular js applicationsQuality metrics and angular js applications
Quality metrics and angular js applicationsnadeembtech
 
Code quality
Code qualityCode quality
Code qualityProvectus
 
Design concerns for concrete syntax
Design concerns for concrete syntaxDesign concerns for concrete syntax
Design concerns for concrete syntaxMikhail Barash
 
More than Programming!
More than Programming!More than Programming!
More than Programming!Sophy Eung
 
Clean Software Design - DevNot Summit Istanbul 2017
Clean Software Design - DevNot Summit Istanbul 2017Clean Software Design - DevNot Summit Istanbul 2017
Clean Software Design - DevNot Summit Istanbul 2017Lemi Orhan Ergin
 
Algorithm pseudocode flowchart program notes
Algorithm pseudocode flowchart program notesAlgorithm pseudocode flowchart program notes
Algorithm pseudocode flowchart program notesArghodeepPaul
 
Six Steps to Conversation Driven Development
Six Steps to Conversation Driven DevelopmentSix Steps to Conversation Driven Development
Six Steps to Conversation Driven DevelopmentRasa Technologies
 
TDD in PHP - Memphis PHP 2011-08-25
TDD in PHP - Memphis PHP 2011-08-25TDD in PHP - Memphis PHP 2011-08-25
TDD in PHP - Memphis PHP 2011-08-25Jeremy Kendall
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentbhochhi
 
Code quality as a built-in process
Code quality as a built-in processCode quality as a built-in process
Code quality as a built-in processElad Maimon
 
10 Faulty Behaviors of Code Review - Developer Summit Istanbul 2018
10 Faulty Behaviors of Code Review - Developer Summit Istanbul 201810 Faulty Behaviors of Code Review - Developer Summit Istanbul 2018
10 Faulty Behaviors of Code Review - Developer Summit Istanbul 2018Lemi Orhan Ergin
 

Tendances (20)

Measuring Code Quality in WTF/min.
Measuring Code Quality in WTF/min. Measuring Code Quality in WTF/min.
Measuring Code Quality in WTF/min.
 
Software Engineering Culture - Improve Code Quality
Software Engineering Culture - Improve Code QualitySoftware Engineering Culture - Improve Code Quality
Software Engineering Culture - Improve Code Quality
 
Agile development with Ruby
Agile development with RubyAgile development with Ruby
Agile development with Ruby
 
Tdd in php a brief example
Tdd in php   a brief exampleTdd in php   a brief example
Tdd in php a brief example
 
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
 
Code Quality Assurance
Code Quality AssuranceCode Quality Assurance
Code Quality Assurance
 
Unwritten Manual for Pair Programming
Unwritten Manual for Pair ProgrammingUnwritten Manual for Pair Programming
Unwritten Manual for Pair Programming
 
Quality metrics and angular js applications
Quality metrics and angular js applicationsQuality metrics and angular js applications
Quality metrics and angular js applications
 
Code quality
Code qualityCode quality
Code quality
 
Codesmells for AspectJ
Codesmells for AspectJCodesmells for AspectJ
Codesmells for AspectJ
 
Design concerns for concrete syntax
Design concerns for concrete syntaxDesign concerns for concrete syntax
Design concerns for concrete syntax
 
More than Programming!
More than Programming!More than Programming!
More than Programming!
 
Clean Software Design - DevNot Summit Istanbul 2017
Clean Software Design - DevNot Summit Istanbul 2017Clean Software Design - DevNot Summit Istanbul 2017
Clean Software Design - DevNot Summit Istanbul 2017
 
Algorithm pseudocode flowchart program notes
Algorithm pseudocode flowchart program notesAlgorithm pseudocode flowchart program notes
Algorithm pseudocode flowchart program notes
 
Six Steps to Conversation Driven Development
Six Steps to Conversation Driven DevelopmentSix Steps to Conversation Driven Development
Six Steps to Conversation Driven Development
 
TDD in PHP - Memphis PHP 2011-08-25
TDD in PHP - Memphis PHP 2011-08-25TDD in PHP - Memphis PHP 2011-08-25
TDD in PHP - Memphis PHP 2011-08-25
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Code quality as a built-in process
Code quality as a built-in processCode quality as a built-in process
Code quality as a built-in process
 
10 Faulty Behaviors of Code Review - Developer Summit Istanbul 2018
10 Faulty Behaviors of Code Review - Developer Summit Istanbul 201810 Faulty Behaviors of Code Review - Developer Summit Istanbul 2018
10 Faulty Behaviors of Code Review - Developer Summit Istanbul 2018
 
Design Smells
Design SmellsDesign Smells
Design Smells
 

En vedette

Правила хорошего SEO тона в Frontend разработке
Правила хорошего SEO тона в Frontend разработкеПравила хорошего SEO тона в Frontend разработке
Правила хорошего SEO тона в Frontend разработкеEcommerce Solution Provider SysIQ
 
Гибкость и Структурированность Oбъектно Oриентированноя CSS
Гибкость и Структурированность Oбъектно Oриентированноя CSSГибкость и Структурированность Oбъектно Oриентированноя CSS
Гибкость и Структурированность Oбъектно Oриентированноя CSSEcommerce Solution Provider SysIQ
 
Модульные сетки в реальном мире - IQLab Frontend Fusion 2012
Модульные сетки в реальном мире - IQLab Frontend Fusion 2012Модульные сетки в реальном мире - IQLab Frontend Fusion 2012
Модульные сетки в реальном мире - IQLab Frontend Fusion 2012Ecommerce Solution Provider SysIQ
 
Эффективный JavaScript - IQLab Frontend Fusion 2012
Эффективный  JavaScript - IQLab Frontend Fusion 2012Эффективный  JavaScript - IQLab Frontend Fusion 2012
Эффективный JavaScript - IQLab Frontend Fusion 2012Ecommerce Solution Provider SysIQ
 
Психология восприятия и UX дизайн
Психология восприятия и UX дизайнПсихология восприятия и UX дизайн
Психология восприятия и UX дизайнEcommerce Solution Provider SysIQ
 
Доступность веб-сайтов: WWW для всех?
Доступность веб-сайтов: WWW для всех?Доступность веб-сайтов: WWW для всех?
Доступность веб-сайтов: WWW для всех?Ecommerce Solution Provider SysIQ
 

En vedette (20)

Seo and Marketing Requirements in Web Architecture
Seo and Marketing Requirements in Web ArchitectureSeo and Marketing Requirements in Web Architecture
Seo and Marketing Requirements in Web Architecture
 
Правила хорошего SEO тона в Frontend разработке
Правила хорошего SEO тона в Frontend разработкеПравила хорошего SEO тона в Frontend разработке
Правила хорошего SEO тона в Frontend разработке
 
Гибкость и Структурированность Oбъектно Oриентированноя CSS
Гибкость и Структурированность Oбъектно Oриентированноя CSSГибкость и Структурированность Oбъектно Oриентированноя CSS
Гибкость и Структурированность Oбъектно Oриентированноя CSS
 
QA evolution, in pictures
QA evolution, in picturesQA evolution, in pictures
QA evolution, in pictures
 
IGears: Template Architecture and Principles
IGears: Template Architecture and PrinciplesIGears: Template Architecture and Principles
IGears: Template Architecture and Principles
 
All things php
All things phpAll things php
All things php
 
Java serialization
Java serializationJava serialization
Java serialization
 
User focused design
User focused designUser focused design
User focused design
 
Speed Up Your Website
Speed Up Your WebsiteSpeed Up Your Website
Speed Up Your Website
 
Модульные сетки в реальном мире - IQLab Frontend Fusion 2012
Модульные сетки в реальном мире - IQLab Frontend Fusion 2012Модульные сетки в реальном мире - IQLab Frontend Fusion 2012
Модульные сетки в реальном мире - IQLab Frontend Fusion 2012
 
QA evolution to the present day
QA evolution to the present dayQA evolution to the present day
QA evolution to the present day
 
Databases on Client Side
Databases on Client SideDatabases on Client Side
Databases on Client Side
 
Эффективный JavaScript - IQLab Frontend Fusion 2012
Эффективный  JavaScript - IQLab Frontend Fusion 2012Эффективный  JavaScript - IQLab Frontend Fusion 2012
Эффективный JavaScript - IQLab Frontend Fusion 2012
 
Психология восприятия и UX дизайн
Психология восприятия и UX дизайнПсихология восприятия и UX дизайн
Психология восприятия и UX дизайн
 
Доступность веб-сайтов: WWW для всех?
Доступность веб-сайтов: WWW для всех?Доступность веб-сайтов: WWW для всех?
Доступность веб-сайтов: WWW для всех?
 
User Behavior: Interacting With Important Website Elements
User Behavior: Interacting With Important Website ElementsUser Behavior: Interacting With Important Website Elements
User Behavior: Interacting With Important Website Elements
 
Manifest of modern engineers
Manifest of modern engineersManifest of modern engineers
Manifest of modern engineers
 
Management and Communications (IPAA)
Management and Communications (IPAA)Management and Communications (IPAA)
Management and Communications (IPAA)
 
Frontend Servers and NGINX: What, Where and How
Frontend Servers and NGINX: What, Where and HowFrontend Servers and NGINX: What, Where and How
Frontend Servers and NGINX: What, Where and How
 
Unexpected achievements 2013
Unexpected achievements 2013Unexpected achievements 2013
Unexpected achievements 2013
 

Similaire à Quick Intro to Clean Coding

Software Development Standard Operating Procedure
Software Development Standard Operating Procedure Software Development Standard Operating Procedure
Software Development Standard Operating Procedure rupeshchanchal
 
Code Craftsmanship Checklist
Code Craftsmanship ChecklistCode Craftsmanship Checklist
Code Craftsmanship ChecklistRyan Polk
 
Agile Methodologies And Extreme Programming
Agile Methodologies And Extreme ProgrammingAgile Methodologies And Extreme Programming
Agile Methodologies And Extreme ProgrammingUtkarsh Khare
 
Agile Methodologies And Extreme Programming - Svetlin Nakov
Agile Methodologies And Extreme Programming - Svetlin NakovAgile Methodologies And Extreme Programming - Svetlin Nakov
Agile Methodologies And Extreme Programming - Svetlin NakovSvetlin Nakov
 
Top Object-Oriented Programming Languages To Follow In December 2022.pdf
Top Object-Oriented Programming Languages To Follow In December 2022.pdfTop Object-Oriented Programming Languages To Follow In December 2022.pdf
Top Object-Oriented Programming Languages To Follow In December 2022.pdfJamesEddie2
 
Programming vs Coding: Unveiling The Key Differences
Programming vs Coding: Unveiling The Key DifferencesProgramming vs Coding: Unveiling The Key Differences
Programming vs Coding: Unveiling The Key DifferencesFredReynolds2
 
DevOps interview questions and answers
DevOps interview questions and answersDevOps interview questions and answers
DevOps interview questions and answersHopeTutors1
 
Writing Clean Code
Writing Clean CodeWriting Clean Code
Writing Clean CodeNascenia IT
 
Agile Values, Principles and Practices
Agile Values, Principles and PracticesAgile Values, Principles and Practices
Agile Values, Principles and Practicesjackcrews
 
The pragmatic programmer
The pragmatic programmerThe pragmatic programmer
The pragmatic programmerLeylimYaln
 
Java And Community Support
Java And Community SupportJava And Community Support
Java And Community SupportWilliam Grosso
 
Qualidade de Software em zOS usando IBM Debug Tool e RDz
Qualidade de Software em zOS usando IBM Debug Tool e RDzQualidade de Software em zOS usando IBM Debug Tool e RDz
Qualidade de Software em zOS usando IBM Debug Tool e RDzPaulo Batuta
 
Best Practices For Writing Super Readable Code
Best Practices For Writing Super Readable CodeBest Practices For Writing Super Readable Code
Best Practices For Writing Super Readable CodeAnsviaLab
 

Similaire à Quick Intro to Clean Coding (20)

Put to the Test
Put to the TestPut to the Test
Put to the Test
 
Software Development Standard Operating Procedure
Software Development Standard Operating Procedure Software Development Standard Operating Procedure
Software Development Standard Operating Procedure
 
Code Craftsmanship Checklist
Code Craftsmanship ChecklistCode Craftsmanship Checklist
Code Craftsmanship Checklist
 
Agile Methodologies And Extreme Programming
Agile Methodologies And Extreme ProgrammingAgile Methodologies And Extreme Programming
Agile Methodologies And Extreme Programming
 
Agile Methodologies And Extreme Programming - Svetlin Nakov
Agile Methodologies And Extreme Programming - Svetlin NakovAgile Methodologies And Extreme Programming - Svetlin Nakov
Agile Methodologies And Extreme Programming - Svetlin Nakov
 
Top Object-Oriented Programming Languages To Follow In December 2022.pdf
Top Object-Oriented Programming Languages To Follow In December 2022.pdfTop Object-Oriented Programming Languages To Follow In December 2022.pdf
Top Object-Oriented Programming Languages To Follow In December 2022.pdf
 
Programming
ProgrammingProgramming
Programming
 
Programming vs Coding: Unveiling The Key Differences
Programming vs Coding: Unveiling The Key DifferencesProgramming vs Coding: Unveiling The Key Differences
Programming vs Coding: Unveiling The Key Differences
 
DevOps interview questions and answers
DevOps interview questions and answersDevOps interview questions and answers
DevOps interview questions and answers
 
Writing Clean Code
Writing Clean CodeWriting Clean Code
Writing Clean Code
 
9-Coding.ppt
9-Coding.ppt9-Coding.ppt
9-Coding.ppt
 
Agile Values, Principles and Practices
Agile Values, Principles and PracticesAgile Values, Principles and Practices
Agile Values, Principles and Practices
 
The pragmatic programmer
The pragmatic programmerThe pragmatic programmer
The pragmatic programmer
 
Java
JavaJava
Java
 
PROGRAMMING LANGUAGE AND TYPES
PROGRAMMING LANGUAGE AND TYPESPROGRAMMING LANGUAGE AND TYPES
PROGRAMMING LANGUAGE AND TYPES
 
Best pratice
Best praticeBest pratice
Best pratice
 
Java And Community Support
Java And Community SupportJava And Community Support
Java And Community Support
 
Refactoring 2 The Max
Refactoring 2 The MaxRefactoring 2 The Max
Refactoring 2 The Max
 
Qualidade de Software em zOS usando IBM Debug Tool e RDz
Qualidade de Software em zOS usando IBM Debug Tool e RDzQualidade de Software em zOS usando IBM Debug Tool e RDz
Qualidade de Software em zOS usando IBM Debug Tool e RDz
 
Best Practices For Writing Super Readable Code
Best Practices For Writing Super Readable CodeBest Practices For Writing Super Readable Code
Best Practices For Writing Super Readable Code
 

Plus de Ecommerce Solution Provider SysIQ (15)

Developing for e commerce is important
Developing for e commerce is importantDeveloping for e commerce is important
Developing for e commerce is important
 
Getting to know magento
Getting to know magentoGetting to know magento
Getting to know magento
 
Developing for e commerce is important
Developing for e commerce is importantDeveloping for e commerce is important
Developing for e commerce is important
 
Magento code audit
Magento code auditMagento code audit
Magento code audit
 
Scalability and performance for e commerce
Scalability and performance for e commerceScalability and performance for e commerce
Scalability and performance for e commerce
 
Lupan big enterprise ecommerce fusion 2013
Lupan   big enterprise ecommerce fusion 2013Lupan   big enterprise ecommerce fusion 2013
Lupan big enterprise ecommerce fusion 2013
 
non-blocking java script
non-blocking java scriptnon-blocking java script
non-blocking java script
 
Going global
Going globalGoing global
Going global
 
Going Global
Going GlobalGoing Global
Going Global
 
Testing schools overview
Testing schools overviewTesting schools overview
Testing schools overview
 
Interactive web prototyping
Interactive web prototypingInteractive web prototyping
Interactive web prototyping
 
Модульные сетки в реальном мире
Модульные сетки в реальном миреМодульные сетки в реальном мире
Модульные сетки в реальном мире
 
External Widgets Performance
External Widgets PerformanceExternal Widgets Performance
External Widgets Performance
 
Understanding Annotations in Java
Understanding Annotations in JavaUnderstanding Annotations in Java
Understanding Annotations in Java
 
Mastering Java ByteCode
Mastering Java ByteCodeMastering Java ByteCode
Mastering Java ByteCode
 

Quick Intro to Clean Coding

  • 1. Quick intro to Clean Coding Aleksey Drobnych Java Trainer
  • 2. ● What is bad code ● What is good code ● Code smells ● Tests ● Refactoring What this all about?
  • 3. I knew one sales guy who predicted that programming languages and programmers will disappear some time because of power of next gen smart business wizards. What is programm? This is just set of business receipts written with maximal level of precision and detalisation. It's impossible to do using human language. It's too flexible. We need to invent specific DSL for the system. And OOP is one of possible ways for this purpose. Foreword
  • 5. if (this == null) { // Logic here }
  • 6. switch (number) { case 0: printf("0"); break; case 1: printf("1"); break; case 2: printf("2"); break; case 3: printf("3"); break; case 4: printf("4"); break; case 5: printf("5"); break; case 6: printf("6"); break; case 7: printf("7"); break; case 8: printf("8"); break; case 9: printf("9"); break; }
  • 7. public int m_otCalc() { return iThsWkd * iThsRte + (int) Math.round(0.5 * iThsRte * Math.max(0, iThsWkd - 400) ); }
  • 9. Path one ● Code that just works (that's easy, man!) ● More Code that just works (huh, we'll survive!) ● Mmmooorrreee CCoodeee thaaat j juust wooork s ● MMMmmmmmmmmmmm mmmmmmmmm ● Great Technical Debt Two ways of Code
  • 10. Path two ● Code that just works ● Tests ● Refinement (finally we've done this spike) ● Test ● More Code just enough for Test ● Refactoring ● Test ● More Code just enough for Test ● Refactoring ● look mum no hands! Two ways of Code
  • 12. ● Code needs to work today just once Simplisity
  • 13. ● Code needs to be easy for change forever Ability to grow
  • 14. ● Big Upfront Design ● We have no time for tests ● Just do so as you did before ● Don't touch it until it works Know your daemons
  • 15. ● Any code can be rewritten ● Tests are your safety belt ● Leave the campground cleaner than you found it Know your angels
  • 16. Transparent: The consequence of change are visible and predictable Reasonable: The cost of adding a new feature is proportional to its value Usable: if you already wrote the code, you can reuse it Exemplary: More code like this would be good for your app How to judge the goodness of code
  • 17. ● Object Oriented Design Patterns ● Object Oriented Design Principles ● Knowledge of language and Libs ● Code Smells ● Tests ● Code Reviews Clean Code Toolset
  • 18. ● Object Oriented Design Patterns In software engineering, a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. A design pattern is not a finished design that can be transformed directly into source or machine code. It is a description or template for how to solve a problem that can be used in many different situations. Patterns are formalized best practices that the programmer must implement themselves in the application.Object-oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved. Clean Code Toolset
  • 19. ● Object Oriented Design Principles In computer programming, SOLID (Single responsibility, Open-closed, Liskov substitution, Interface segregation and Dependency inversion) is a mnemonic acronym introduced by Michael Feathers for the "first five principles" identified by Robert C. Martin in the early 2000s that stands for five basic principles of object-oriented programming and design. The principles when applied together intend to make it more likely that aprogrammer will create a system that is easy to maintain and extend over time.The principles of SOLID are guidelines that can be applied while working on software to remove code smells by causing the programmer to refactor the software's source code until it is both legible and extensible. It is typically used with test-driven development, and is part of an overall strategy of agile and adaptive programming. Clean Code Toolset
  • 20. ● Knowledge of language and Libs List of Efective Java units Clean Code Toolset
  • 21. ● Code Smells In computer programming, code smell is any symptom in the source code of a program that possibly indicates a deeper problem. Code smells are usually not bugs—they are not technically incorrect and don't currently prevent the program from functioning. Instead, they indicate weaknesses in design that may be slowing down development or increasing the risk of bugs or failures in the future. Clean Code Toolset
  • 22. ● Tests Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: first the developer writes an (initially failing) automated test case that defines a desired improvement or new function, then produces the minimum amount of code to pass that test, and finally refactors the new code to acceptable standards. Kent Beck, who is credited with having developed or 'rediscovered' the technique, stated in 2003 that TDD encourages simple designs and inspires confidence. Clean Code Toolset
  • 23. ● Code Reviews and refactorings Code refactoring is a "disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior", undertaken in order to improve some of the nonfunctional attributes of the software. Advantages include improved code readability and reduced complexity to improve the maintainability of the source code, as well as a more expressive internal architecture or object model to improve extensibility. Clean Code Toolset
  • 25. Quick way: Patterns Live refactoring session
  • 26. Write tests. If your Classes and Methods are just DSL of the system, then tests is your first and most important way to start talk with silent system. Finally both your tests and the system will talk Perfect Language. Keep your tests as a grammar for your DSL. From where I shall start?
  • 27. Don't write comments. 85% of developer job is reading of existing code. Keep your code readable, self-explanatory, intentional. Comments are poor deodorant for your code. If you will find yourself writing comment then you can't express your intent in code. This is smell. Refactor. From where I shall start?
  • 28. What's next? Object Oriented Design Effective Java Clean Code, Code Smells, Refactorings OOD Patterns TDD Crossroad