SlideShare a Scribd company logo
CHAPTER 6
WHILE YOU ARE CODING
Zeynep DÜZYURT
i2i Systems – Summer Intern
zeynep.duzyurt@ext.i2i-systems.com
While You Are Coding
This chapter includes «While You Are Coding» approach in five
sections:
• Programming by Coincidence
• Algorithm Speed
•Refactoring
•Code that’s Easy to Test
•Evil Wizards
Programming by Coincidence
We should avoid programming by
coincidence—relying on luck and accidental
successes— in favor of programming
deliberately.
Tip 1: Don't Program by Coincidence
How to Program Deliberately
Always be aware of what you are doing.
How to Program Deliberately
•Don't code blindfolded.
How to Program Deliberately
Proceed from a plan !
How to Program Deliberately
Rely only on reliable things.
How to Program Deliberately
Document your assumptions.
How to Program Deliberately
Don’t just test your code, but test your assumptions as well.
How to Program Deliberately
Prioritize your effort. Spend time on the important aspects; more
than likely, these are the hard parts.
How to Program Deliberately
Don't be a slave to history. Don't let existing code dictate future code
Algorithm Speed
Pragmatic Programmers estimate the resources that algorithms use—time,
processor, memory, and so on.
Use: Big O Notation
O(1): Constant (access element in array, simple statements)
O(n): Linear: Sequential search
O(n²): Square law (selection and insertion sorts)
O(logn): Logarithmic (binary search) lg(n) = lg2(n)
Algorithm Speed
Algorithm Speed
Algorithm Speed
Algorithm Speed
Algorithm Speed
Common Sense Estimation
Simple loops: O(n)
Nested loops: O(n²)
Binary chop: O(log(n))
Divide and conquer: O(n lg(n)). Algorithms that partition their input, work on the two halves
independently, and then combine the result.
•Tip 3 : Test your estimates•Tip 2: Estimate the Order
of Your Algorithms
Refactoring
.Code needs to evolve; it's not a static thing.
When You Should Refactor ?
Duplication. You've discovered a violation of the DRY principle (The Evils of
Duplication).
Nonorthogonal design. You've discovered some code or design that could be
made more orthogonal (Orthogonality).
Outdated knowledge. Things change, requirements drift, and your knowledge
of the problem increases. Code needs to keep up.
Performance. You need to move functionality from one area of the system to
another to improve performance.
Tip 4: Refactor Early,
Refactor Often
How Do You Refactor?
Don't try to refactor and add functionality at the same time.
Make sure you have good tests before you begin refactoring.
Take short, deliberate steps.
Code That's Easy to Test
Build testability into the software from the very beginning, and test each piece
thoroughly before trying to wire them together.
Testing Against Contract
This will tell us two things:
Whether the code meet the contract
Whether the contract means what we think it means.
Tip 5: Design to Test
Writing Unit Tests
Examples of how to use all the functionality of your module
Make easier to validate any future changes to the code
By making the test code readily accessible, you are providing developers who
may use your code with two invaluable resources:
A Culture of Testing
Test your software or users do it
Evil Wizards
Tip 6: Don't Use Wizard
Code You Don't
Understand
If you do use a wizard, and you don't understand all the code that it
produces, you won't be in control of your own application.

More Related Content

What's hot

Pair Programming: overview and concepts
Pair Programming: overview and conceptsPair Programming: overview and concepts
Pair Programming: overview and concepts
Lior Kirshner-Shalom
 
Tdd - Test Driven Development
Tdd - Test Driven DevelopmentTdd - Test Driven Development
Tdd - Test Driven Development
David Paluy
 
Improve your TDD skills
Improve your TDD skillsImprove your TDD skills
Improve your TDD skills
XPeppers
 
Agile and test driven development
Agile and test driven developmentAgile and test driven development
Agile and test driven development
Ahmed El-Deeb
 
Pair programming demystified
Pair programming demystifiedPair programming demystified
Pair programming demystified
Marek Kirejczyk
 
Five steps towards your testing dream
Five steps towards your testing dreamFive steps towards your testing dream
Five steps towards your testing dream
Lisa Gagarina
 
5 reasons you'll love to hate Agile Development
5 reasons you'll love to hate Agile Development5 reasons you'll love to hate Agile Development
5 reasons you'll love to hate Agile Development
Arin Sime
 
Agile Software Development for Non-Developers
Agile Software Development for Non-DevelopersAgile Software Development for Non-Developers
Agile Software Development for Non-Developers
hamvocke
 
How to Deliver the Right Software (Specification by example)
How to Deliver the Right Software (Specification by example)How to Deliver the Right Software (Specification by example)
How to Deliver the Right Software (Specification by example)
Asier Barrenetxea
 
Software Development in the Brave New world
Software Development in the Brave New worldSoftware Development in the Brave New world
Software Development in the Brave New world
David Leip
 
Code Review Matters and Manners
Code Review Matters and MannersCode Review Matters and Manners
Code Review Matters and Manners
Trisha Gee
 
Working effectively with legacy codes
Working effectively with legacy codesWorking effectively with legacy codes
Working effectively with legacy codes
Ali Shariat
 
Specification by example and agile acceptance testing
Specification by example and agile acceptance testingSpecification by example and agile acceptance testing
Specification by example and agile acceptance testing
gojkoadzic
 
Adopting Agile
Adopting AgileAdopting Agile
Adopting Agile
Coverity
 
Introducing Pair Programming
Introducing Pair ProgrammingIntroducing Pair Programming
Introducing Pair Programming
Steven Smith
 
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh EastmanBehavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
QA or the Highway
 
[Quang nguyen] Continuous Integration XP Day 2015 Vietnam Danang
[Quang nguyen] Continuous Integration XP Day 2015 Vietnam Danang[Quang nguyen] Continuous Integration XP Day 2015 Vietnam Danang
[Quang nguyen] Continuous Integration XP Day 2015 Vietnam Danang
Agile đây Vietnam
 
Software Development Essential Skills
Software Development Essential SkillsSoftware Development Essential Skills
Software Development Essential Skills
John Choi
 
Alexa, what's next?
Alexa, what's next?Alexa, what's next?
Alexa, what's next?
Ralf Eggert
 
Spec by-example
Spec by-exampleSpec by-example
Spec by-example
David Navarro Alvarez
 

What's hot (20)

Pair Programming: overview and concepts
Pair Programming: overview and conceptsPair Programming: overview and concepts
Pair Programming: overview and concepts
 
Tdd - Test Driven Development
Tdd - Test Driven DevelopmentTdd - Test Driven Development
Tdd - Test Driven Development
 
Improve your TDD skills
Improve your TDD skillsImprove your TDD skills
Improve your TDD skills
 
Agile and test driven development
Agile and test driven developmentAgile and test driven development
Agile and test driven development
 
Pair programming demystified
Pair programming demystifiedPair programming demystified
Pair programming demystified
 
Five steps towards your testing dream
Five steps towards your testing dreamFive steps towards your testing dream
Five steps towards your testing dream
 
5 reasons you'll love to hate Agile Development
5 reasons you'll love to hate Agile Development5 reasons you'll love to hate Agile Development
5 reasons you'll love to hate Agile Development
 
Agile Software Development for Non-Developers
Agile Software Development for Non-DevelopersAgile Software Development for Non-Developers
Agile Software Development for Non-Developers
 
How to Deliver the Right Software (Specification by example)
How to Deliver the Right Software (Specification by example)How to Deliver the Right Software (Specification by example)
How to Deliver the Right Software (Specification by example)
 
Software Development in the Brave New world
Software Development in the Brave New worldSoftware Development in the Brave New world
Software Development in the Brave New world
 
Code Review Matters and Manners
Code Review Matters and MannersCode Review Matters and Manners
Code Review Matters and Manners
 
Working effectively with legacy codes
Working effectively with legacy codesWorking effectively with legacy codes
Working effectively with legacy codes
 
Specification by example and agile acceptance testing
Specification by example and agile acceptance testingSpecification by example and agile acceptance testing
Specification by example and agile acceptance testing
 
Adopting Agile
Adopting AgileAdopting Agile
Adopting Agile
 
Introducing Pair Programming
Introducing Pair ProgrammingIntroducing Pair Programming
Introducing Pair Programming
 
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh EastmanBehavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
 
[Quang nguyen] Continuous Integration XP Day 2015 Vietnam Danang
[Quang nguyen] Continuous Integration XP Day 2015 Vietnam Danang[Quang nguyen] Continuous Integration XP Day 2015 Vietnam Danang
[Quang nguyen] Continuous Integration XP Day 2015 Vietnam Danang
 
Software Development Essential Skills
Software Development Essential SkillsSoftware Development Essential Skills
Software Development Essential Skills
 
Alexa, what's next?
Alexa, what's next?Alexa, what's next?
Alexa, what's next?
 
Spec by-example
Spec by-exampleSpec by-example
Spec by-example
 

Similar to While You Are Coding

Code review guidelines
Code review guidelinesCode review guidelines
Code review guidelines
Lalit Kale
 
Should you be your own judge?
Should you be your own judge?Should you be your own judge?
Should you be your own judge?
Achyut Pokhrel
 
Arch factory - Agile Design: Best Practices
Arch factory - Agile Design: Best PracticesArch factory - Agile Design: Best Practices
Arch factory - Agile Design: Best Practices
Igor Moochnick
 
Best pratice
Best praticeBest pratice
Best pratice
Eugenio Romano
 
Test-Driven Development Reference Card
Test-Driven Development Reference CardTest-Driven Development Reference Card
Test-Driven Development Reference Card
Seapine Software
 
Test Drive Development
Test Drive DevelopmentTest Drive Development
Test Drive Development
satya sudheer
 
The View - 30 proven Lotuscript tips
The View - 30 proven Lotuscript tipsThe View - 30 proven Lotuscript tips
The View - 30 proven Lotuscript tips
Bill Buchan
 
Test driven development
Test driven developmentTest driven development
Test driven development
Sunil Prasad
 
Unit Test Lab - Why Write Unit Tests?
Unit Test Lab - Why Write Unit Tests?Unit Test Lab - Why Write Unit Tests?
Unit Test Lab - Why Write Unit Tests?
Danny van Kasteel
 
Twelve practices of XP_Se lect5 btech
Twelve practices of XP_Se lect5 btechTwelve practices of XP_Se lect5 btech
Twelve practices of XP_Se lect5 btech
IIITA
 
Principles that Guide Practice
Principles that Guide PracticePrinciples that Guide Practice
Principles that Guide Practice
Islamia Univeristy Bahawalpur Bahawalnagar
 
Test driven development
Test driven developmentTest driven development
Test driven development
namkha87
 
Topic production code
Topic production codeTopic production code
Topic production code
Kavi Kumar
 
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
Svetlin Nakov
 
Driving application development through behavior driven development
Driving application development through behavior driven developmentDriving application development through behavior driven development
Driving application development through behavior driven development
Einar Ingebrigtsen
 
Testing & should i do it
Testing & should i do itTesting & should i do it
Testing & should i do it
Martin Sykora
 
Put to the Test
Put to the TestPut to the Test
Put to the Test
Kevlin Henney
 
TxJS 2011
TxJS 2011TxJS 2011
TxJS 2011
Brian LeRoux
 
Unit testing
Unit testingUnit testing
Unit testing
PiXeL16
 
Cinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patternsCinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patterns
Steven Smith
 

Similar to While You Are Coding (20)

Code review guidelines
Code review guidelinesCode review guidelines
Code review guidelines
 
Should you be your own judge?
Should you be your own judge?Should you be your own judge?
Should you be your own judge?
 
Arch factory - Agile Design: Best Practices
Arch factory - Agile Design: Best PracticesArch factory - Agile Design: Best Practices
Arch factory - Agile Design: Best Practices
 
Best pratice
Best praticeBest pratice
Best pratice
 
Test-Driven Development Reference Card
Test-Driven Development Reference CardTest-Driven Development Reference Card
Test-Driven Development Reference Card
 
Test Drive Development
Test Drive DevelopmentTest Drive Development
Test Drive Development
 
The View - 30 proven Lotuscript tips
The View - 30 proven Lotuscript tipsThe View - 30 proven Lotuscript tips
The View - 30 proven Lotuscript tips
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Unit Test Lab - Why Write Unit Tests?
Unit Test Lab - Why Write Unit Tests?Unit Test Lab - Why Write Unit Tests?
Unit Test Lab - Why Write Unit Tests?
 
Twelve practices of XP_Se lect5 btech
Twelve practices of XP_Se lect5 btechTwelve practices of XP_Se lect5 btech
Twelve practices of XP_Se lect5 btech
 
Principles that Guide Practice
Principles that Guide PracticePrinciples that Guide Practice
Principles that Guide Practice
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Topic production code
Topic production codeTopic production code
Topic production code
 
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
 
Driving application development through behavior driven development
Driving application development through behavior driven developmentDriving application development through behavior driven development
Driving application development through behavior driven development
 
Testing & should i do it
Testing & should i do itTesting & should i do it
Testing & should i do it
 
Put to the Test
Put to the TestPut to the Test
Put to the Test
 
TxJS 2011
TxJS 2011TxJS 2011
TxJS 2011
 
Unit testing
Unit testingUnit testing
Unit testing
 
Cinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patternsCinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patterns
 

Recently uploaded

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
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
Yara Milbes
 
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
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
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
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
Gerardo Pardo-Castellote
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
lorraineandreiamcidl
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Undress Baby
 
What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
aymanquadri279
 
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
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
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
 

Recently uploaded (20)

Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
 
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
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
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)
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
 
What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
 
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
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
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
 

While You Are Coding

  • 1. CHAPTER 6 WHILE YOU ARE CODING
  • 2. Zeynep DÜZYURT i2i Systems – Summer Intern zeynep.duzyurt@ext.i2i-systems.com
  • 3. While You Are Coding This chapter includes «While You Are Coding» approach in five sections: • Programming by Coincidence • Algorithm Speed •Refactoring •Code that’s Easy to Test •Evil Wizards
  • 4. Programming by Coincidence We should avoid programming by coincidence—relying on luck and accidental successes— in favor of programming deliberately. Tip 1: Don't Program by Coincidence
  • 5. How to Program Deliberately Always be aware of what you are doing.
  • 6. How to Program Deliberately •Don't code blindfolded.
  • 7. How to Program Deliberately Proceed from a plan !
  • 8. How to Program Deliberately Rely only on reliable things.
  • 9. How to Program Deliberately Document your assumptions.
  • 10. How to Program Deliberately Don’t just test your code, but test your assumptions as well.
  • 11. How to Program Deliberately Prioritize your effort. Spend time on the important aspects; more than likely, these are the hard parts.
  • 12. How to Program Deliberately Don't be a slave to history. Don't let existing code dictate future code
  • 13. Algorithm Speed Pragmatic Programmers estimate the resources that algorithms use—time, processor, memory, and so on. Use: Big O Notation O(1): Constant (access element in array, simple statements) O(n): Linear: Sequential search O(n²): Square law (selection and insertion sorts) O(logn): Logarithmic (binary search) lg(n) = lg2(n)
  • 19. Common Sense Estimation Simple loops: O(n) Nested loops: O(n²) Binary chop: O(log(n)) Divide and conquer: O(n lg(n)). Algorithms that partition their input, work on the two halves independently, and then combine the result. •Tip 3 : Test your estimates•Tip 2: Estimate the Order of Your Algorithms
  • 20. Refactoring .Code needs to evolve; it's not a static thing.
  • 21. When You Should Refactor ? Duplication. You've discovered a violation of the DRY principle (The Evils of Duplication). Nonorthogonal design. You've discovered some code or design that could be made more orthogonal (Orthogonality). Outdated knowledge. Things change, requirements drift, and your knowledge of the problem increases. Code needs to keep up. Performance. You need to move functionality from one area of the system to another to improve performance. Tip 4: Refactor Early, Refactor Often
  • 22. How Do You Refactor? Don't try to refactor and add functionality at the same time. Make sure you have good tests before you begin refactoring. Take short, deliberate steps.
  • 23.
  • 24. Code That's Easy to Test Build testability into the software from the very beginning, and test each piece thoroughly before trying to wire them together.
  • 25. Testing Against Contract This will tell us two things: Whether the code meet the contract Whether the contract means what we think it means. Tip 5: Design to Test
  • 26. Writing Unit Tests Examples of how to use all the functionality of your module Make easier to validate any future changes to the code By making the test code readily accessible, you are providing developers who may use your code with two invaluable resources:
  • 27. A Culture of Testing Test your software or users do it
  • 28. Evil Wizards Tip 6: Don't Use Wizard Code You Don't Understand If you do use a wizard, and you don't understand all the code that it produces, you won't be in control of your own application.