SlideShare a Scribd company logo
Developer Job in Practice
Clean code rules • Code review • Refactoring
Kamil Kowalski
kamil.kowalski@blstream.com
2	
  
Being a developer
!  You	
  need	
  to	
  follow	
  the	
  rules,	
  wheter	
  
they	
  are	
  
!  You should ask the questions –
especially in case of doubts
!  You should learn new things: all
the time, always and also from
others
!  ... till end (of time)
Developer’s job is not only about
developing the code
!  It	
  would	
  be	
  great	
  to	
  have	
  a	
  leader:	
  	
  
!  to	
  learn	
  from	
  
!  to	
  follow 	
  	
  
!  You	
  are	
  the	
  team	
  player	
  	
  
!  You	
  work	
  with	
  legacy	
  systems	
  
3	
  
Typical project setup
!  Waterfall,	
  Agile,	
  ...	
  
!  How project is run:
!  Scrum
!  Kanban
!  Programin Mother*ker
!  Developing the code
!  Code first
!  TDD
!  „Who needs unit tests” / „We don’t
test our code” ☺
There is no one!
Each single project has its own setup!
!  Tools:	
  	
  
!  IDE	
  –	
  Xcode,	
  VS,	
  IntelliJ,	
  ...	
  
!  Repository:	
  SVN,	
  Git,	
  ...	
  
!  CI	
  environment:	
  Hudson,	
  	
  Jenkins,	
  
CC.NET,...	
  
!  Scripts:	
  Python,	
  MsBuild,	
  ANT,	
  
NANT,	
  ...	
  
!  SupporQng	
  tools:	
  R#,	
  StyleCop 	
  	
  
!  Review	
  Tool	
  
!  Project	
  board,	
  back	
  trucking:	
  JIRA	
  
!  Code	
  guide	
  
!  DefiniQon	
  of	
  Done	
  /	
  DefiniQon	
  of	
  
Ready	
  
!  Build	
  in	
  one	
  step	
  &	
  daily	
  builds	
  
4	
  
Definition of Done / Definition of Ready
!  DoD / DoR says about the rules
you need to follow during daily
work
!  Each developer in team need to
follow DoD – no exceptions!
!  Each team member need to
follow DoR – no exceptions!
!  Each single project has its own
DoD / DoR
DoD / DoR is our contract! !  Sample DoD:
!  All unit tests passed
!  All integration tests passed
!  No warnings in code (also warnings
from StyleCop)
!  Code coverage over 91%
!  Max cyclomatic complexity below 12
!  Build passed on CI server
!  Sample DoR:
!  Functionality working (all AC’s met)
!  Unit test written
!  Code approved by 2 other developers
!  QA accepted
!  Functionality available on CI staging
environment
!  Documentation updated
5	
  
Code smells
!  Duplicated Code
!  Long Method
!  Large Class
!  Long Parameter List / too many
of them
!  Switch Statement
!  Temporary Field
!  Magic numbers
!  Naming
!  Complex Conditionals
!  Dead code
If it stinks, change it! !  High quality code is:
!  Easy	
  to	
  read	
  and	
  understand	
  
!  Impossible	
  to	
  hide	
  bugs	
  
!  Easy	
  to	
  extend	
  
!  Easy	
  to	
  change	
  
!  Has	
  unit	
  tests	
  
	
  
!  Always code as if the guy who
ends up maintaining your code
will be a violent psychopath who
knows where you live.
public	
  class	
  Record_Base	
  
{	
  
	
  	
  	
  	
  public	
  DateTime	
  RecordDateTime	
  
	
  	
  	
  	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  get	
  {	
  return	
  _recordDateTime;	
  }	
  
	
  	
  	
  	
  	
  	
  	
  	
  set	
  	
  	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  {	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  if	
  (this.GetType().Name	
  ==	
  "Record_PartRegister") 	
  	
  _recordDateTime	
  =	
  value;	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  else	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  throw	
  new	
  ExcepQon("Cannot	
  call	
  set	
  on	
  RecordDateTime	
  for	
  table	
  "	
  +	
  this.GetType().Name);	
  
	
  	
  	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  }	
  
}	
  
hp://thedailyw].com/ArQcles/Making-­‐Off-­‐With-­‐Your-­‐Inheritance.aspx	
  
This is not OOP!
KISS my DRY and SOLID code
7	
  
Simple rules for
developers – how to
write the code
!  Keep It Simple -
Stupid
!  Don’t Repeat
Yorself
!  Uncle Bob Clean
Code(r)
!  SOLID	
  principles:	
  	
  
!  Single	
  Responsibility	
  
Every	
  object	
  should	
  have	
  a	
  single	
  responsibility,	
  and	
  that	
  
responsibility	
  should	
  be	
  en7rely	
  encapsulated	
  by	
  the	
  class.	
  
!  Open	
  /	
  Closed	
  principle	
  
So:ware	
  en77es	
  (classes,	
  modules,	
  func7ons,	
  etc.)	
  should	
  be	
  open	
  
for	
  extension,	
  but	
  closed	
  for	
  modifica7on.	
  
!  Liskov	
  SubsQtuQon	
  
Objects	
  in	
  a	
  program	
  should	
  be	
  replaceable	
  with	
  instances	
  of	
  their	
  
subtypes	
  without	
  altering	
  the	
  correctness	
  of	
  that	
  program.	
  	
  
!  Interface	
  SegragaQon	
  
Clients	
  should	
  not	
  be	
  forced	
  to	
  depend	
  on	
  methods	
  they	
  do	
  not	
  use.	
  
!  Dependency	
  Inversion	
  
Abstrac7ons	
  should	
  not	
  depend	
  on	
  details.	
  	
  Details	
  should	
  depend	
  on	
  
abstrac7ons.	
  
8	
  
Code reviews
!  Can	
  catch	
  up	
  to	
  60%	
  of	
  defects	
  
!  EffecQve	
  code	
  reviews	
  are:	
  
!  Short	
  –	
  don’t	
  waste	
  Qme	
  
!  ConstrucQve	
  
!  Avoid	
  emoQonally	
  draining	
  arguments	
  	
  
!  Code	
  review	
  rules	
  depend	
  on	
  project	
  
you’re	
  working	
  on	
  -­‐	
  samples:	
  
!  Banking	
  system	
  	
  -­‐	
  SOLID,	
  security	
  	
  
!  NASA	
  	
  
!  Games	
  -­‐	
  opQmizaQon	
  ,	
  code	
  efficiency,	
  don’t	
  
care	
  about	
  excepQons	
  	
  
!  Mobile	
  applicaQon	
  –	
  SOLID,	
  but	
  efficiency	
  
	
  
Everybody reviews and everybody is
reviewed.
!  Rules:	
  
!  Syntax	
  !	
  
!  Code	
  Style	
  –	
  be	
  project	
  StyleCop	
  
(naming)	
  
!  Simplicity	
  
!  DRY	
  violaQons	
  
!  SOLID	
  violaQons	
  
!  Security	
  –	
  buffers,	
  stack	
  overflow,	
  input	
  
dfata	
  sanity	
  (trust	
  no	
  one),	
  cross	
  
boarders	
  (SQL	
  injecQon,	
  XSS)	
  
!  Memory	
  leaks	
  
!  OpQmizaQon	
  -­‐	
  code	
  efficiency	
  
!  Strings	
  !	
  
	
  
9	
  
Why should I refactor?
!  Technical	
  what?!	
  -­‐	
  is	
  a	
  metaphor:	
  
	
  
!  doing	
  things	
  the	
  quick	
  and	
  dirty	
  way	
  sets	
  us	
  up	
  
with	
  a	
  technical	
  debt,	
  which	
  is	
  similar	
  to	
  a	
  
financial	
  debt	
  
!  incurs	
  interest	
  payments,	
  which	
  come	
  in	
  the	
  
form	
  of	
  the	
  extra	
  effort	
  that	
  we	
  have	
  to	
  do	
  in	
  
future	
  development.	
  
!  Refactoring	
  is	
  changing	
  the	
  structure,	
  but	
  not	
  
the	
  funcQonality	
  of	
  your	
  applicaQon.	
  
	
  
Refactoring is our way of paying off
our “Technical Debt”
!  How	
  Should	
  I	
  Refactor:	
  
!  Ask	
  yourself	
  the	
  following	
  quesQons:	
  
!  Is	
  my	
  code	
  readable?	
  
!  Is	
  my	
  code	
  abstract?	
  
	
  
!  Anything	
  more	
  is	
  rearranging	
  the	
  deck	
  
chairs	
  on	
  the	
  Titanic:	
  
!  It	
  gives	
  you	
  a	
  sense	
  of	
  doing	
  something	
  
!  But	
  ulQmately	
  it’s	
  pointless	
  	
  #	
  
!  Follow	
  the	
  rules:	
  	
  
!  KISS	
  /	
  DRY	
  /	
  SOLID	
  
!  Clean	
  code	
  
!  Code	
  review	
  rules!	
  
	
  
•  Refactoring	
  catalogs:	
  
hp://www.refactoring.com/catalog/index.html	
  	
  
•  Refactoring	
  (book)	
  
hp://www.amazon.co.uk/Refactoring-­‐Improving-­‐Design-­‐
ExisQng-­‐Technology/dp/0201485672/ref=sr_1_1?
ie=UTF8&s=books&qid=1246371771&sr=8-­‐1	
  	
  
Resources

More Related Content

What's hot (20)

ODP
Behaviour Driven Development Hands-on
Hemmerling
 
PPTX
A walkthrough of JavaScript ES6 features
Michal Juhas
 
ODP
Test Driven Development (TDD) with Windows PowerShell
Hemmerling
 
PPTX
Vagrant and Docker
Nascenia IT
 
PDF
Sonarqube + Docker
Estefanía Fernández Muñoz
 
PPTX
Test your user interface using BDD (Swedish)
Evolve
 
PDF
TDC2016POA | Trilha DevOps - DevOps Anti-Patterns
tdc-globalcode
 
PPTX
Creating a reasonable project boilerplate
Stanislav Petrov
 
PPTX
Gozengo sauce presentation
Daniel Straus
 
PDF
Continuous operations in AWS
Aleksandr Maklakov
 
PPTX
Unit Testing TypeScript
Daniel Jimenez Garcia
 
ODP
Lighning Talk: PHP build process
Bryan Agee
 
PPT
Continuous Integration
Joseph Wang
 
PPTX
Advantages and disadvantages of a monorepo
IanDavidson56
 
PDF
Pipeline as code for your infrastructure as Code
Kris Buytaert
 
PDF
TDD with Spock @xpdays_ua
Izzet Mustafaiev
 
PPTX
Mono Repo
Zacky Pickholz
 
PDF
INTEGRATING DIFFERENT IDE’S WITH A COMMON SET OF DEVELOPER SERVICES WITH A C...
Willy Marroquin (WillyDevNET)
 
PPTX
Master the Monorepo
Roman Minchyn
 
PDF
Monorepo at Pinterest
Suman Karumuri
 
Behaviour Driven Development Hands-on
Hemmerling
 
A walkthrough of JavaScript ES6 features
Michal Juhas
 
Test Driven Development (TDD) with Windows PowerShell
Hemmerling
 
Vagrant and Docker
Nascenia IT
 
Sonarqube + Docker
Estefanía Fernández Muñoz
 
Test your user interface using BDD (Swedish)
Evolve
 
TDC2016POA | Trilha DevOps - DevOps Anti-Patterns
tdc-globalcode
 
Creating a reasonable project boilerplate
Stanislav Petrov
 
Gozengo sauce presentation
Daniel Straus
 
Continuous operations in AWS
Aleksandr Maklakov
 
Unit Testing TypeScript
Daniel Jimenez Garcia
 
Lighning Talk: PHP build process
Bryan Agee
 
Continuous Integration
Joseph Wang
 
Advantages and disadvantages of a monorepo
IanDavidson56
 
Pipeline as code for your infrastructure as Code
Kris Buytaert
 
TDD with Spock @xpdays_ua
Izzet Mustafaiev
 
Mono Repo
Zacky Pickholz
 
INTEGRATING DIFFERENT IDE’S WITH A COMMON SET OF DEVELOPER SERVICES WITH A C...
Willy Marroquin (WillyDevNET)
 
Master the Monorepo
Roman Minchyn
 
Monorepo at Pinterest
Suman Karumuri
 

Viewers also liked (11)

PPTX
Definition of ready
Adam Kędziora
 
PDF
Working effectively with user stories
Ken Power
 
PDF
Value Stream Manager concept applied to Software Product Development
Ken Power
 
PPTX
Definition of done training
Monica Yap
 
PDF
Lightening Talk: definition of ready
Agileee
 
PPTX
Db workshop - art of story splitting and writting
Phil van Dulm Consultancy
 
PDF
Jak technika user story & acceptance criteria pozwala definiować wymagania w ...
Rafal Stanczak »scrumdo(.)pl
 
PPT
Definition Of Done
Wei Zhu
 
PDF
Definition of Ready (XP2011)
Ken Power
 
PPTX
Zoom sur le Métier de Développeur
ANAPEC
 
PDF
Métiers de l'informatique
hatimydriss
 
Definition of ready
Adam Kędziora
 
Working effectively with user stories
Ken Power
 
Value Stream Manager concept applied to Software Product Development
Ken Power
 
Definition of done training
Monica Yap
 
Lightening Talk: definition of ready
Agileee
 
Db workshop - art of story splitting and writting
Phil van Dulm Consultancy
 
Jak technika user story & acceptance criteria pozwala definiować wymagania w ...
Rafal Stanczak »scrumdo(.)pl
 
Definition Of Done
Wei Zhu
 
Definition of Ready (XP2011)
Ken Power
 
Zoom sur le Métier de Développeur
ANAPEC
 
Métiers de l'informatique
hatimydriss
 
Ad

Similar to Developer Job in Practice (20)

PDF
20191116 DevFest 2019 The Legacy Code came to stay (El legacy vino para queda...
Antonio de la Torre Fernández
 
PPTX
Integreation
Sean Killeen
 
PDF
How to write good quality code
Hayden Bleasel
 
PDF
Code quality par Simone Civetta
CocoaHeads France
 
PDF
Test Driven Development - Workshop
Anjana Somathilake
 
PPTX
Clean Code Part III - Craftsmanship at SoCal Code Camp
Theo Jungeblut
 
PPTX
How I Learned to Stop Worrying and Love Legacy Code.....
Mike Harris
 
PDF
Test Essentials @mdevcon 2012
Maxim Zaks
 
PPT
Writing Good Code
Leo Liang
 
PDF
Developer Efficiency
Dmitri Nesteruk
 
PPTX
Writing clean code in C# and .NET
Dror Helper
 
PDF
Coder sans peur du changement avec la meme pas mal hexagonal architecture
Thomas Pierrain
 
PDF
Rapid Application Development with Docker
Niklas Heidloff
 
PDF
Polyglot and Poly-paradigm Programming for Better Agility
elliando dias
 
PDF
Letter to a Junior Developer: The Engineering Side of Programming
Lazar Kovacevic
 
PPTX
Build software like a bag of marbles, not a castle of LEGO®
Hannes Lowette
 
PDF
Bootstrapping iPhone Development
ThoughtWorks
 
PPTX
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
Mike Harris
 
PDF
Solvcon PyCon APAC 2014
weijr
 
20191116 DevFest 2019 The Legacy Code came to stay (El legacy vino para queda...
Antonio de la Torre Fernández
 
Integreation
Sean Killeen
 
How to write good quality code
Hayden Bleasel
 
Code quality par Simone Civetta
CocoaHeads France
 
Test Driven Development - Workshop
Anjana Somathilake
 
Clean Code Part III - Craftsmanship at SoCal Code Camp
Theo Jungeblut
 
How I Learned to Stop Worrying and Love Legacy Code.....
Mike Harris
 
Test Essentials @mdevcon 2012
Maxim Zaks
 
Writing Good Code
Leo Liang
 
Developer Efficiency
Dmitri Nesteruk
 
Writing clean code in C# and .NET
Dror Helper
 
Coder sans peur du changement avec la meme pas mal hexagonal architecture
Thomas Pierrain
 
Rapid Application Development with Docker
Niklas Heidloff
 
Polyglot and Poly-paradigm Programming for Better Agility
elliando dias
 
Letter to a Junior Developer: The Engineering Side of Programming
Lazar Kovacevic
 
Build software like a bag of marbles, not a castle of LEGO®
Hannes Lowette
 
Bootstrapping iPhone Development
ThoughtWorks
 
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
Mike Harris
 
Solvcon PyCon APAC 2014
weijr
 
Ad

More from intive (20)

PPTX
Rok z Android MVVM
intive
 
PDF
Don't Forget About the Layout
intive
 
PDF
You Don't Need Dependency Injection
intive
 
PPTX
OWASP Open SAMM
intive
 
PPTX
Porównanie architektur MVVM i MVC (iOS)
intive
 
PDF
Wprowadzenie do CoreBluetooth
intive
 
PDF
.Net anywhere
intive
 
PDF
Front end - advanced development for beginners
intive
 
PDF
Kotlin, Spek and tests
intive
 
PDF
Patronage 2016 Windows 10 Warsztaty
intive
 
PPTX
Techniczna organizacja zespołu cz 2
intive
 
PDF
Techniczna organizacja zespołu
intive
 
PDF
Organizacja zespołu
intive
 
PDF
Nie tylko C# - Ekosystem Microsoft dla programistów
intive
 
PDF
[PL] MVP do MVVM - separacja warstw w aplikacji androidowej
intive
 
PDF
Tips & Tricks Android
intive
 
PDF
Apple Watch - Getting Started
intive
 
PDF
Clean architecture: Android
intive
 
PDF
CoreLocation (iOS) in details
intive
 
PDF
Java Script - Object-Oriented Programming
intive
 
Rok z Android MVVM
intive
 
Don't Forget About the Layout
intive
 
You Don't Need Dependency Injection
intive
 
OWASP Open SAMM
intive
 
Porównanie architektur MVVM i MVC (iOS)
intive
 
Wprowadzenie do CoreBluetooth
intive
 
.Net anywhere
intive
 
Front end - advanced development for beginners
intive
 
Kotlin, Spek and tests
intive
 
Patronage 2016 Windows 10 Warsztaty
intive
 
Techniczna organizacja zespołu cz 2
intive
 
Techniczna organizacja zespołu
intive
 
Organizacja zespołu
intive
 
Nie tylko C# - Ekosystem Microsoft dla programistów
intive
 
[PL] MVP do MVVM - separacja warstw w aplikacji androidowej
intive
 
Tips & Tricks Android
intive
 
Apple Watch - Getting Started
intive
 
Clean architecture: Android
intive
 
CoreLocation (iOS) in details
intive
 
Java Script - Object-Oriented Programming
intive
 

Recently uploaded (20)

PDF
Market Wrap for 18th July 2025 by CIFDAQ
CIFDAQ
 
PDF
UiPath on Tour London Community Booth Deck
UiPathCommunity
 
PDF
UiPath vs Other Automation Tools Meeting Presentation.pdf
Tracy Dixon
 
PPTX
python advanced data structure dictionary with examples python advanced data ...
sprasanna11
 
PDF
Novus-Safe Pro: Brochure-What is Novus Safe Pro?.pdf
Novus Hi-Tech
 
PDF
OpenInfra ID 2025 - Are Containers Dying? Rethinking Isolation with MicroVMs.pdf
Muhammad Yuga Nugraha
 
PDF
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
PDF
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
PDF
Empowering Cloud Providers with Apache CloudStack and Stackbill
ShapeBlue
 
PDF
Lecture A - AI Workflows for Banking.pdf
Dr. LAM Yat-fai (林日辉)
 
PDF
Upskill to Agentic Automation 2025 - Kickoff Meeting
DianaGray10
 
PDF
2025-07-15 EMEA Volledig Inzicht Dutch Webinar
ThousandEyes
 
PDF
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
PDF
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
PDF
visibel.ai Company Profile – Real-Time AI Solution for CCTV
visibelaiproject
 
PDF
Market Insight : ETH Dominance Returns
CIFDAQ
 
PDF
The Past, Present & Future of Kenya's Digital Transformation
Moses Kemibaro
 
PPTX
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
PPTX
Earn Agentblazer Status with Slack Community Patna.pptx
SanjeetMishra29
 
PPTX
Simplifying End-to-End Apache CloudStack Deployment with a Web-Based Automati...
ShapeBlue
 
Market Wrap for 18th July 2025 by CIFDAQ
CIFDAQ
 
UiPath on Tour London Community Booth Deck
UiPathCommunity
 
UiPath vs Other Automation Tools Meeting Presentation.pdf
Tracy Dixon
 
python advanced data structure dictionary with examples python advanced data ...
sprasanna11
 
Novus-Safe Pro: Brochure-What is Novus Safe Pro?.pdf
Novus Hi-Tech
 
OpenInfra ID 2025 - Are Containers Dying? Rethinking Isolation with MicroVMs.pdf
Muhammad Yuga Nugraha
 
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
Empowering Cloud Providers with Apache CloudStack and Stackbill
ShapeBlue
 
Lecture A - AI Workflows for Banking.pdf
Dr. LAM Yat-fai (林日辉)
 
Upskill to Agentic Automation 2025 - Kickoff Meeting
DianaGray10
 
2025-07-15 EMEA Volledig Inzicht Dutch Webinar
ThousandEyes
 
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
visibel.ai Company Profile – Real-Time AI Solution for CCTV
visibelaiproject
 
Market Insight : ETH Dominance Returns
CIFDAQ
 
The Past, Present & Future of Kenya's Digital Transformation
Moses Kemibaro
 
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
Earn Agentblazer Status with Slack Community Patna.pptx
SanjeetMishra29
 
Simplifying End-to-End Apache CloudStack Deployment with a Web-Based Automati...
ShapeBlue
 

Developer Job in Practice

  • 1. Developer Job in Practice Clean code rules • Code review • Refactoring Kamil Kowalski [email protected]
  • 2. 2   Being a developer !  You  need  to  follow  the  rules,  wheter   they  are   !  You should ask the questions – especially in case of doubts !  You should learn new things: all the time, always and also from others !  ... till end (of time) Developer’s job is not only about developing the code !  It  would  be  great  to  have  a  leader:     !  to  learn  from   !  to  follow     !  You  are  the  team  player     !  You  work  with  legacy  systems  
  • 3. 3   Typical project setup !  Waterfall,  Agile,  ...   !  How project is run: !  Scrum !  Kanban !  Programin Mother*ker !  Developing the code !  Code first !  TDD !  „Who needs unit tests” / „We don’t test our code” ☺ There is no one! Each single project has its own setup! !  Tools:     !  IDE  –  Xcode,  VS,  IntelliJ,  ...   !  Repository:  SVN,  Git,  ...   !  CI  environment:  Hudson,    Jenkins,   CC.NET,...   !  Scripts:  Python,  MsBuild,  ANT,   NANT,  ...   !  SupporQng  tools:  R#,  StyleCop     !  Review  Tool   !  Project  board,  back  trucking:  JIRA   !  Code  guide   !  DefiniQon  of  Done  /  DefiniQon  of   Ready   !  Build  in  one  step  &  daily  builds  
  • 4. 4   Definition of Done / Definition of Ready !  DoD / DoR says about the rules you need to follow during daily work !  Each developer in team need to follow DoD – no exceptions! !  Each team member need to follow DoR – no exceptions! !  Each single project has its own DoD / DoR DoD / DoR is our contract! !  Sample DoD: !  All unit tests passed !  All integration tests passed !  No warnings in code (also warnings from StyleCop) !  Code coverage over 91% !  Max cyclomatic complexity below 12 !  Build passed on CI server !  Sample DoR: !  Functionality working (all AC’s met) !  Unit test written !  Code approved by 2 other developers !  QA accepted !  Functionality available on CI staging environment !  Documentation updated
  • 5. 5   Code smells !  Duplicated Code !  Long Method !  Large Class !  Long Parameter List / too many of them !  Switch Statement !  Temporary Field !  Magic numbers !  Naming !  Complex Conditionals !  Dead code If it stinks, change it! !  High quality code is: !  Easy  to  read  and  understand   !  Impossible  to  hide  bugs   !  Easy  to  extend   !  Easy  to  change   !  Has  unit  tests     !  Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
  • 6. public  class  Record_Base   {          public  DateTime  RecordDateTime          {                  get  {  return  _recordDateTime;  }                  set                        {                            if  (this.GetType().Name  ==  "Record_PartRegister")    _recordDateTime  =  value;                        else                                      throw  new  ExcepQon("Cannot  call  set  on  RecordDateTime  for  table  "  +  this.GetType().Name);                  }          }   }   hp://thedailyw].com/ArQcles/Making-­‐Off-­‐With-­‐Your-­‐Inheritance.aspx   This is not OOP!
  • 7. KISS my DRY and SOLID code 7   Simple rules for developers – how to write the code !  Keep It Simple - Stupid !  Don’t Repeat Yorself !  Uncle Bob Clean Code(r) !  SOLID  principles:     !  Single  Responsibility   Every  object  should  have  a  single  responsibility,  and  that   responsibility  should  be  en7rely  encapsulated  by  the  class.   !  Open  /  Closed  principle   So:ware  en77es  (classes,  modules,  func7ons,  etc.)  should  be  open   for  extension,  but  closed  for  modifica7on.   !  Liskov  SubsQtuQon   Objects  in  a  program  should  be  replaceable  with  instances  of  their   subtypes  without  altering  the  correctness  of  that  program.     !  Interface  SegragaQon   Clients  should  not  be  forced  to  depend  on  methods  they  do  not  use.   !  Dependency  Inversion   Abstrac7ons  should  not  depend  on  details.    Details  should  depend  on   abstrac7ons.  
  • 8. 8   Code reviews !  Can  catch  up  to  60%  of  defects   !  EffecQve  code  reviews  are:   !  Short  –  don’t  waste  Qme   !  ConstrucQve   !  Avoid  emoQonally  draining  arguments     !  Code  review  rules  depend  on  project   you’re  working  on  -­‐  samples:   !  Banking  system    -­‐  SOLID,  security     !  NASA     !  Games  -­‐  opQmizaQon  ,  code  efficiency,  don’t   care  about  excepQons     !  Mobile  applicaQon  –  SOLID,  but  efficiency     Everybody reviews and everybody is reviewed. !  Rules:   !  Syntax  !   !  Code  Style  –  be  project  StyleCop   (naming)   !  Simplicity   !  DRY  violaQons   !  SOLID  violaQons   !  Security  –  buffers,  stack  overflow,  input   dfata  sanity  (trust  no  one),  cross   boarders  (SQL  injecQon,  XSS)   !  Memory  leaks   !  OpQmizaQon  -­‐  code  efficiency   !  Strings  !    
  • 9. 9   Why should I refactor? !  Technical  what?!  -­‐  is  a  metaphor:     !  doing  things  the  quick  and  dirty  way  sets  us  up   with  a  technical  debt,  which  is  similar  to  a   financial  debt   !  incurs  interest  payments,  which  come  in  the   form  of  the  extra  effort  that  we  have  to  do  in   future  development.   !  Refactoring  is  changing  the  structure,  but  not   the  funcQonality  of  your  applicaQon.     Refactoring is our way of paying off our “Technical Debt” !  How  Should  I  Refactor:   !  Ask  yourself  the  following  quesQons:   !  Is  my  code  readable?   !  Is  my  code  abstract?     !  Anything  more  is  rearranging  the  deck   chairs  on  the  Titanic:   !  It  gives  you  a  sense  of  doing  something   !  But  ulQmately  it’s  pointless    #   !  Follow  the  rules:     !  KISS  /  DRY  /  SOLID   !  Clean  code   !  Code  review  rules!    
  • 10. •  Refactoring  catalogs:   hp://www.refactoring.com/catalog/index.html     •  Refactoring  (book)   hp://www.amazon.co.uk/Refactoring-­‐Improving-­‐Design-­‐ ExisQng-­‐Technology/dp/0201485672/ref=sr_1_1? ie=UTF8&s=books&qid=1246371771&sr=8-­‐1     Resources