SlideShare a Scribd company logo
Welcome 
everybody
Comfortable Code 
Author: Remus Langu 
Date: 26.09.2013
Senior Developer 
Family Man | Orthodox Christian 
About Me
Agenda 
 Introduction 
 Code Qualities 
 Code Quality Practices 
 Conclusion
Introduction 
Why Do We 
Think about 
Code 
Quality?
Code Qualities 
 Testability 
 No Redundancy 
 Encapsulation 
 Strong Cohesion 
 Correct Coupling 
 Readability 
 Focus
Separate Use 
from Construction 
Demo
Separate Use 
from Construction 
 Promotes Testability – factories making all 
construction decisions can return ‘test 
versions’ of objects 
 Promotes Encapsulation of design 
 Promotes Cohesion – separate users by builders 
 Helps keep clients Decoupled from the specific 
classes they are using, since they do not have 
to build them 
 Aids Focus – the construction of objects 
are concentrated in one or more related 
places
Encapsulate by Convention, 
Reveal by Need 
 Ease Testing – encapsulated code needs no unit 
tests 
 Encapsulating Construction helps 
No Redundancy 
 Ensures the greatest level of Encapsulation 
possible 
 Leads to Correct Coupling – that which 
is hidden cannot possibly be 
coupled to
Encapsulate by Convention, 
Reveal by Need 
Demo
Write Tests First 
 Best way to ensure Testability 
 Helps avoid Redundancy – redundant test reveal redundant 
feature 
 Helps you determine what can and cannot be Encapsulated 
 Increases Cohesion - it is easier to write tests for classes 
with one responsibility 
 Promotes Decoupling naturally 
 Tends to improve Readability – code is written with a clear 
idea of what is supposed to do; refactoring 
 Testing all the variations of a concept, they will tend 
to be Focused, because it is easier to test them 
if they are 
Demo
Code by Intention 
Demo
Code by Intention 
 Improves Testability - a well-defined intention is 
easier to test 
 Eliminates Redundancies 
 Promotes Encapsulation - less-complex methods 
encapsulate their local variables from each other 
 Increases Cohesion - if the intention is about one 
thing 
 Assists Correct Coupling - the calling routine is 
written only to the interface 
 Improves Readability - methods are well-named
Write Clearly 
 Ensure that people understand what the 
method/class does 
 Use intention revealing names 
 Follow coding standards 
 Improves Testability – clearer code is 
easier to understand and will make 
clearer tests
Avoid Redundancy 
 Easier when considering Testability up front 
 Ensures No Redundancy, obviously 
 Keeps Focus from degrading
Redundant Relationships
Pull Out Things That Vary 
Demo
Pull Out Things That Vary 
 Promotes Encapsulation of type behind an 
interface 
 Increases Cohesion by eliminating varying 
function 
 Helps keep Correct Coupling – eliminates the 
opportunity to couple to state or private 
functions of the client class
Refactor Code as Needed 
 It is part of TDD 
 Often results in elimination of Redundancy of state or 
behavior – ‘Pull up Method’, ‘Pull up Field’, ‘Form 
Template Method’ 
 Often strengthens Encapsulation 
 Improves Cohesion – ‘Extract Method’, ‘Move Method’ 
 Improves Coupling – ‘Replace Conditional with 
Polymorphism’ 
 Tends to improve Readability – generally 
simplifies and beautifies code
Treat Conceptually Similar 
Things the Same Way
Treat Conceptually Similar 
Things the Same Way 
 Improves Testability – test individual pieces, how 
they react and how you decide which pieces 
you have 
 Improves Encapsulation – the different 
implementations of variations 
 Improves Correct Coupling – client is no longer 
coupled to the specific types 
 Improves Focus – it relates the different 
implementations together with their 
common interface
Favor Delegation 
over Class Inheritance
Favor Delegation 
over Class Inheritance
Favor Delegation 
over Class Inheritance 
 Improves Testability – separate classes can be 
tested apart from the client classes 
 Helps eliminate Redundancy – allows for 
reuse of pulled out objects 
 Promotes the Encapsulation of type – 
variations are hidden 
 Increase class Cohesion 
 Eliminates the possibility of 
inheritance Coupling
Other Best Practice 
 Do Not Do More Than You Need: 
 Save time to work on things you do need 
 Smarter to implement at the point in the future when it is 
needed 
 Allows you to focus on those things you do need to do 
 If do you need it later, more of the system will be built that 
should make writing the function easier
Conclusion 
 Testability could be achieved with: 
 Write Tests First 
 Code by Intention 
 Write Clearly 
 Encapsulate by Convention, Reveal by Need 
 Avoid Redundancy 
 Treat Conceptually Similar Things the Same Way 
 Favor Composition over Class Inheritance 
 Separate Use from Construction 
 Refactor Code as Needed
Conclusion 
 No Redundancy could be achieved with: 
 Write Tests First 
 Code by Intention 
 Encapsulate by Convention, Reveal by Need 
 Avoid Redundancy 
 Favor Composition over Class Inheritance 
 Refactor Code as Needed
Conclusion 
 Encapsulation could be achieved with: 
 Write Tests First 
 Code by Intention 
 Encapsulate by Convention, Reveal by Need 
 Pull Out Things That Vary 
 Treat Conceptually Similar Things the Same Way 
 Favor Composition over Class Inheritance 
 Separate Use from Construction 
 Refactor Code as Needed
Conclusion 
 Strong Cohesion could be achieved with: 
 Write Tests First 
 Code by Intention 
 Pull Out Things That Vary 
 Favor Composition over Class Inheritance 
 Separate Use from Construction 
 Refactor Code as Needed
Conclusion 
 Correct Coupling could be achieved with: 
 Write Tests First 
 Code by Intention 
 Encapsulate by Convention, Reveal by Need 
 Pull Out Things That Vary 
 Treat Conceptually Similar Things the Same Way 
 Favor Composition over Class Inheritance 
 Separate Use from Construction 
 Refactor Code as Needed
Conclusion 
 Readability could be achieved with: 
 Write Tests First 
 Code by Intention 
 Write Clearly 
 Refactor Code as Needed
Conclusion 
 Focus could be achieved with: 
 Write Tests First 
 Encapsulate by Convention, Reveal by Need 
 Avoid Redundancy 
 Treat Conceptually Similar Things the Same Way 
 Separate Use from Construction
Recommendation 
 Essential Skills for the Agile Developer: A Guide to Better 
Programming and Design (29 Aug 2011), 
by Alan Shalloway , Scott Bain, Ken Pugh, Amir Kolsky 
 Comfort Code: Another delicious presentation 
http://vimeo.com/49476115
ANY 
QUESTIONS ?
Remus-Constantin Langu | Senior Developer 
Email: remus.langu@touricoholidays.com 
Skype: remus.constantin.langu 
THANK YOU 

More Related Content

Viewers also liked

Mi lecturas complementarias_ok
Mi lecturas complementarias_okMi lecturas complementarias_ok
Mi lecturas complementarias_ok
Manuel Vargas
 
Client side modularization for modern web applications
Client side modularization for modern web applicationsClient side modularization for modern web applications
Client side modularization for modern web applications
Remus Langu
 
Presentacion keyline
Presentacion keylinePresentacion keyline
Presentacion keyline
JRGUACHIS
 
Las 7 regiones[1]
Las 7 regiones[1]Las 7 regiones[1]
Las 7 regiones[1]
carlosfloresarroyo
 
Validation Protocol
Validation ProtocolValidation Protocol
Validation Protocol
Sagar Savale
 

Viewers also liked (7)

Mi lecturas complementarias_ok
Mi lecturas complementarias_okMi lecturas complementarias_ok
Mi lecturas complementarias_ok
 
FinTechQ1 Trends_v2
FinTechQ1 Trends_v2FinTechQ1 Trends_v2
FinTechQ1 Trends_v2
 
Venture
VentureVenture
Venture
 
Client side modularization for modern web applications
Client side modularization for modern web applicationsClient side modularization for modern web applications
Client side modularization for modern web applications
 
Presentacion keyline
Presentacion keylinePresentacion keyline
Presentacion keyline
 
Las 7 regiones[1]
Las 7 regiones[1]Las 7 regiones[1]
Las 7 regiones[1]
 
Validation Protocol
Validation ProtocolValidation Protocol
Validation Protocol
 

Similar to Comfortable code

Writing Quality Code
Writing Quality CodeWriting Quality Code
Writing Quality Code
indikaMaligaspe
 
Testing the untestable
Testing the untestableTesting the untestable
Testing the untestable
RoyKlein
 
Selenium Design Patterns
Selenium Design PatternsSelenium Design Patterns
Selenium Design Patterns
Liraz Shay
 
Unit Testing, TDD and the Walking Skeleton
Unit Testing, TDD and the Walking SkeletonUnit Testing, TDD and the Walking Skeleton
Unit Testing, TDD and the Walking Skeleton
Seb Rose
 
Tdd and-design-draft
Tdd and-design-draftTdd and-design-draft
Tdd and-design-draft
PrabudhGupta1
 
Odd E验收测试驱动开发实战
Odd E验收测试驱动开发实战Odd E验收测试驱动开发实战
Odd E验收测试驱动开发实战George Ang
 
Software Development Practices in Practice
Software Development Practices in PracticeSoftware Development Practices in Practice
Software Development Practices in Practice
Dennis Doomen
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven Development
Michael Denomy
 
Products are a mess
Products are a messProducts are a mess
Products are a mess
Suman Mukherjee
 
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
DevDay.org
 
DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatterns
Basavaraj Patil
 
Reduce Reuse Refactor
Reduce Reuse RefactorReduce Reuse Refactor
Reduce Reuse Refactor
Alena Holligan
 
Test Driven Development - Overview and Adoption
Test Driven Development - Overview and AdoptionTest Driven Development - Overview and Adoption
Test Driven Development - Overview and Adoption
Pyxis Technologies
 
Unit Testing Full@
Unit Testing Full@Unit Testing Full@
Unit Testing Full@Alex Borsuk
 
Software presentation
Software presentationSoftware presentation
Software presentation
JennaPrengle
 
Design pattern
Design patternDesign pattern
Design pattern
Shreyance Jain
 
Trends in Agile Testing by Lisa Crispin
Trends in Agile Testing by Lisa CrispinTrends in Agile Testing by Lisa Crispin
Trends in Agile Testing by Lisa CrispinDirecti Group
 
Code Craftsmanship Checklist
Code Craftsmanship ChecklistCode Craftsmanship Checklist
Code Craftsmanship Checklist
Ryan Polk
 
Writting Better Software
Writting Better SoftwareWritting Better Software
Writting Better Softwaresvilen.ivanov
 

Similar to Comfortable code (20)

Writing Quality Code
Writing Quality CodeWriting Quality Code
Writing Quality Code
 
Testing the untestable
Testing the untestableTesting the untestable
Testing the untestable
 
Selenium Design Patterns
Selenium Design PatternsSelenium Design Patterns
Selenium Design Patterns
 
Unit Testing, TDD and the Walking Skeleton
Unit Testing, TDD and the Walking SkeletonUnit Testing, TDD and the Walking Skeleton
Unit Testing, TDD and the Walking Skeleton
 
Tdd and-design-draft
Tdd and-design-draftTdd and-design-draft
Tdd and-design-draft
 
Odd E验收测试驱动开发实战
Odd E验收测试驱动开发实战Odd E验收测试驱动开发实战
Odd E验收测试驱动开发实战
 
Software Development Practices in Practice
Software Development Practices in PracticeSoftware Development Practices in Practice
Software Development Practices in Practice
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven Development
 
Products are a mess
Products are a messProducts are a mess
Products are a mess
 
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
 
DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatterns
 
Reduce Reuse Refactor
Reduce Reuse RefactorReduce Reuse Refactor
Reduce Reuse Refactor
 
Test Driven Development - Overview and Adoption
Test Driven Development - Overview and AdoptionTest Driven Development - Overview and Adoption
Test Driven Development - Overview and Adoption
 
Unit Testing Full@
Unit Testing Full@Unit Testing Full@
Unit Testing Full@
 
Software presentation
Software presentationSoftware presentation
Software presentation
 
Design pattern
Design patternDesign pattern
Design pattern
 
Trends in Agile Testing by Lisa Crispin
Trends in Agile Testing by Lisa CrispinTrends in Agile Testing by Lisa Crispin
Trends in Agile Testing by Lisa Crispin
 
Code Craftsmanship Checklist
Code Craftsmanship ChecklistCode Craftsmanship Checklist
Code Craftsmanship Checklist
 
Writting Better Software
Writting Better SoftwareWritting Better Software
Writting Better Software
 
Code quality
Code quality Code quality
Code quality
 

More from Remus Langu

Front end architecture
Front end architectureFront end architecture
Front end architecture
Remus Langu
 
Handling variations in emerging designs
Handling variations in emerging designsHandling variations in emerging designs
Handling variations in emerging designs
Remus Langu
 
Training AngularJS & Ionic
Training AngularJS & IonicTraining AngularJS & Ionic
Training AngularJS & IonicRemus Langu
 
Single page applications with AngularJS
Single page applications with AngularJSSingle page applications with AngularJS
Single page applications with AngularJS
Remus Langu
 
Single page interface challenges in modern web applications
Single page interface challenges in modern web applicationsSingle page interface challenges in modern web applications
Single page interface challenges in modern web applications
Remus Langu
 
Behavior Driven Development with AngularJS & Jasmine
Behavior Driven Development with AngularJS & JasmineBehavior Driven Development with AngularJS & Jasmine
Behavior Driven Development with AngularJS & Jasmine
Remus Langu
 

More from Remus Langu (6)

Front end architecture
Front end architectureFront end architecture
Front end architecture
 
Handling variations in emerging designs
Handling variations in emerging designsHandling variations in emerging designs
Handling variations in emerging designs
 
Training AngularJS & Ionic
Training AngularJS & IonicTraining AngularJS & Ionic
Training AngularJS & Ionic
 
Single page applications with AngularJS
Single page applications with AngularJSSingle page applications with AngularJS
Single page applications with AngularJS
 
Single page interface challenges in modern web applications
Single page interface challenges in modern web applicationsSingle page interface challenges in modern web applications
Single page interface challenges in modern web applications
 
Behavior Driven Development with AngularJS & Jasmine
Behavior Driven Development with AngularJS & JasmineBehavior Driven Development with AngularJS & Jasmine
Behavior Driven Development with AngularJS & Jasmine
 

Recently uploaded

Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)
abdulrafaychaudhry
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 

Recently uploaded (20)

Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 

Comfortable code

  • 2. Comfortable Code Author: Remus Langu Date: 26.09.2013
  • 3. Senior Developer Family Man | Orthodox Christian About Me
  • 4. Agenda  Introduction  Code Qualities  Code Quality Practices  Conclusion
  • 5. Introduction Why Do We Think about Code Quality?
  • 6. Code Qualities  Testability  No Redundancy  Encapsulation  Strong Cohesion  Correct Coupling  Readability  Focus
  • 7. Separate Use from Construction Demo
  • 8. Separate Use from Construction  Promotes Testability – factories making all construction decisions can return ‘test versions’ of objects  Promotes Encapsulation of design  Promotes Cohesion – separate users by builders  Helps keep clients Decoupled from the specific classes they are using, since they do not have to build them  Aids Focus – the construction of objects are concentrated in one or more related places
  • 9. Encapsulate by Convention, Reveal by Need  Ease Testing – encapsulated code needs no unit tests  Encapsulating Construction helps No Redundancy  Ensures the greatest level of Encapsulation possible  Leads to Correct Coupling – that which is hidden cannot possibly be coupled to
  • 10. Encapsulate by Convention, Reveal by Need Demo
  • 11. Write Tests First  Best way to ensure Testability  Helps avoid Redundancy – redundant test reveal redundant feature  Helps you determine what can and cannot be Encapsulated  Increases Cohesion - it is easier to write tests for classes with one responsibility  Promotes Decoupling naturally  Tends to improve Readability – code is written with a clear idea of what is supposed to do; refactoring  Testing all the variations of a concept, they will tend to be Focused, because it is easier to test them if they are Demo
  • 13. Code by Intention  Improves Testability - a well-defined intention is easier to test  Eliminates Redundancies  Promotes Encapsulation - less-complex methods encapsulate their local variables from each other  Increases Cohesion - if the intention is about one thing  Assists Correct Coupling - the calling routine is written only to the interface  Improves Readability - methods are well-named
  • 14. Write Clearly  Ensure that people understand what the method/class does  Use intention revealing names  Follow coding standards  Improves Testability – clearer code is easier to understand and will make clearer tests
  • 15. Avoid Redundancy  Easier when considering Testability up front  Ensures No Redundancy, obviously  Keeps Focus from degrading
  • 17. Pull Out Things That Vary Demo
  • 18. Pull Out Things That Vary  Promotes Encapsulation of type behind an interface  Increases Cohesion by eliminating varying function  Helps keep Correct Coupling – eliminates the opportunity to couple to state or private functions of the client class
  • 19. Refactor Code as Needed  It is part of TDD  Often results in elimination of Redundancy of state or behavior – ‘Pull up Method’, ‘Pull up Field’, ‘Form Template Method’  Often strengthens Encapsulation  Improves Cohesion – ‘Extract Method’, ‘Move Method’  Improves Coupling – ‘Replace Conditional with Polymorphism’  Tends to improve Readability – generally simplifies and beautifies code
  • 20. Treat Conceptually Similar Things the Same Way
  • 21. Treat Conceptually Similar Things the Same Way  Improves Testability – test individual pieces, how they react and how you decide which pieces you have  Improves Encapsulation – the different implementations of variations  Improves Correct Coupling – client is no longer coupled to the specific types  Improves Focus – it relates the different implementations together with their common interface
  • 22. Favor Delegation over Class Inheritance
  • 23. Favor Delegation over Class Inheritance
  • 24. Favor Delegation over Class Inheritance  Improves Testability – separate classes can be tested apart from the client classes  Helps eliminate Redundancy – allows for reuse of pulled out objects  Promotes the Encapsulation of type – variations are hidden  Increase class Cohesion  Eliminates the possibility of inheritance Coupling
  • 25. Other Best Practice  Do Not Do More Than You Need:  Save time to work on things you do need  Smarter to implement at the point in the future when it is needed  Allows you to focus on those things you do need to do  If do you need it later, more of the system will be built that should make writing the function easier
  • 26. Conclusion  Testability could be achieved with:  Write Tests First  Code by Intention  Write Clearly  Encapsulate by Convention, Reveal by Need  Avoid Redundancy  Treat Conceptually Similar Things the Same Way  Favor Composition over Class Inheritance  Separate Use from Construction  Refactor Code as Needed
  • 27. Conclusion  No Redundancy could be achieved with:  Write Tests First  Code by Intention  Encapsulate by Convention, Reveal by Need  Avoid Redundancy  Favor Composition over Class Inheritance  Refactor Code as Needed
  • 28. Conclusion  Encapsulation could be achieved with:  Write Tests First  Code by Intention  Encapsulate by Convention, Reveal by Need  Pull Out Things That Vary  Treat Conceptually Similar Things the Same Way  Favor Composition over Class Inheritance  Separate Use from Construction  Refactor Code as Needed
  • 29. Conclusion  Strong Cohesion could be achieved with:  Write Tests First  Code by Intention  Pull Out Things That Vary  Favor Composition over Class Inheritance  Separate Use from Construction  Refactor Code as Needed
  • 30. Conclusion  Correct Coupling could be achieved with:  Write Tests First  Code by Intention  Encapsulate by Convention, Reveal by Need  Pull Out Things That Vary  Treat Conceptually Similar Things the Same Way  Favor Composition over Class Inheritance  Separate Use from Construction  Refactor Code as Needed
  • 31. Conclusion  Readability could be achieved with:  Write Tests First  Code by Intention  Write Clearly  Refactor Code as Needed
  • 32. Conclusion  Focus could be achieved with:  Write Tests First  Encapsulate by Convention, Reveal by Need  Avoid Redundancy  Treat Conceptually Similar Things the Same Way  Separate Use from Construction
  • 33. Recommendation  Essential Skills for the Agile Developer: A Guide to Better Programming and Design (29 Aug 2011), by Alan Shalloway , Scott Bain, Ken Pugh, Amir Kolsky  Comfort Code: Another delicious presentation http://vimeo.com/49476115
  • 35. Remus-Constantin Langu | Senior Developer Email: remus.langu@touricoholidays.com Skype: remus.constantin.langu THANK YOU 