SlideShare a Scribd company logo
1 of 12
Download to read offline
INTRO TO SERVER SIDE PROGRAMMING
Week Seven

Friday, October 18, 13
Review - Functions
Functions must start with the function keyword, must
contain a valid function identifier (with variables), provide an
optional list of arguments surrounded by parentheses, even
if there are none, and a block of code:
function do_something( $an_argument, $another ) {
// Code goes here
}
Nothing from outside is visible to code in the block
Nothing inside the block is visible outside the function
Pass values into a function as arguments at invocation:
do_something( 'some value', "$another_value );
Friday, October 18, 13
Assertion Testing
An assertion is a predicate (true-false statement) placed
in a program to indicate that the developer thinks that
the predicate is always true at that place.
Programmers can use assertions to help specify
programs and to reason about program correctness
A precondition- an assertion placed at the beginning of a
section of code, determines the set of states under which
the programmer expects the code to execute
A postcondition - placed at the end - describes the
expected state at the end of execution

Friday, October 18, 13
assert( 1 + 1 == 1 );
// PHP Warning: Assertion failed
assert( "1 + 1 == 1" );
// PHP Warning: Assertion "1 + 1 == 1" failed
assert_options( ASSERT_WARNING, false );
if( ! assert( "1 + 1 == 1" ) )
// No PHP Warning message

Friday, October 18, 13
Software Testing
Software testing is the process of validating and verifying
that the software:
meets requirements that guided its design and development
works as expected (produces the desired outputs/behavior)
satisfies the needs of stakeholders

Automated testing is the process of writing software that
performs automated, repeatable isolated tests on a
completely separate software system called the System
Under Test (SUT)

Friday, October 18, 13
Types of Testing
Assertion testing - is this statement correct? Can it be incorrect?
Unit testing - does this function produce the expected output?
Functional testing - does this module provide the expected
functionality?
Integration testing - do these modules work together?
System testing - can we run this software where we need it?
Validation testing - does it do what we said that it was supposed to do?
Acceptance testing - is it actually useful to the intended users?
Regression testing - now that we fixed something what else did we
break?

Friday, October 18, 13
Test-Driven Development
Test-driven development is a software development process
that relies on the repetition of a very short development cycle.
The developer writes an automated test case that defines a
desired improvement or function, then produces the minimum
amount of code to pass that test and finally refactors the new
code to acceptable standards
1. Write code that describes a function that would be desirable
to have but does not yet exist
2. Run the tests to generate feedback and observe
3. Write some code that attempts to provide the function
4. Run the tests to generate feedback. Note failures and
continue to write code to produce a success
5. Repeat as necessary

Friday, October 18, 13
How Does Testing Help?
Writing and running an automated, repeatable and isolated test suite
against your software answers:
How do I know that my system provides the desired functionality
according to the provided specs?
When a bug surfaces, how do I know where in the codebase the
problem exists and whether or not I've fixed it?
When I add a new functionality or correct a bug, how do I know that I
haven't broken something else?
How can I ensure that a bug, once fixed, does not resurface when I fix
another bug or add more functionality?
If I improve the structure or organization of my code for readability,
how do I know that it still works the same way?

Friday, October 18, 13
Rules of the Code Dojo
Pair Programming:
Pilot-Copilot
One person is the pilot and does the typing
One person is the copilot and tries to talk the solution out
Everyone else is passengers (quiet while flying!)

Timed for X minutes, then:
The pilot becomes a passenger, the copilot becomes the pilot, a
passenger becomes the new copilot

Repeat until the problem is solved, everyone has been pilot and
copilot, or we run out of time

Friday, October 18, 13
Rules of the Dojo cont.
Test Driven Development:
Red-Green-Refactor
Red: the pilot cannot write any production code until there is at
least one failing test
Green: the pilot should only write production code that attempts
to satisfy the current failing tests, save and rerun frequently
Refactor: Once all tests are passing, look for opportunities to
simplify or improve readability before moving on

Don't talk while Red:
Only the pair can talk while the timer is running
Allow the pair time to figure out the next steps on their own

Friday, October 18, 13
Dojo Assignment
Write a set of functions that all accept exactly two
parameters and provide the functionality of a basic
calculator: addition, subtraction, multiplication and
division. Use simple assertion tests to develop in a test
driven manner:
assert( 'add(1,1) == 2' );
assert( 'sub(4,2) == 2' );
Ensure that your test covers positive and negative
numbers for all operations and multiplication or division
by zero. The program should never produce a Fatal Error,
so handle error conditions internally

Friday, October 18, 13
Dojo Homework
Create a new file in your assignments rep named
assignment-8.1.md and open it
Research the different kinds of testing that we discussed,
specifically Unit Testing and Integration Testing and cite
some of the cons and pitfalls of them
Find a link to at least one blog post or article in favor of
testing and one against and save them to your file,
preparing to discuss them in class
List at least three of the many active testing frameworks
for PHP with links to the project pages
Save your work, commit changes and push to Github
Friday, October 18, 13

More Related Content

What's hot

Win at life with unit testing
Win at life with unit testingWin at life with unit testing
Win at life with unit testingmarkstory
 
Test Driven Development - Overview and Adoption
Test Driven Development - Overview and AdoptionTest Driven Development - Overview and Adoption
Test Driven Development - Overview and AdoptionPyxis Technologies
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentbhochhi
 
Quality Software With Unit Test
Quality Software With Unit TestQuality Software With Unit Test
Quality Software With Unit Testalice yang
 
Testing & continuous delivery
Testing & continuous deliveryTesting & continuous delivery
Testing & continuous deliveryNelson Melina
 
Verification and Validation in Manual Testing
Verification and Validation in Manual TestingVerification and Validation in Manual Testing
Verification and Validation in Manual TestingBollapalli Vasundhara
 
Beyond Unit Testing
Beyond Unit TestingBeyond Unit Testing
Beyond Unit TestingSøren Lund
 
Writing Testable Code
Writing Testable CodeWriting Testable Code
Writing Testable Codejameshalsall
 
Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016Søren Lund
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentguestc8093a6
 
Test Driven Development (TDD)
Test Driven Development (TDD)Test Driven Development (TDD)
Test Driven Development (TDD)David Ehringer
 
Documenting code yapceu2016
Documenting code yapceu2016Documenting code yapceu2016
Documenting code yapceu2016Søren Lund
 
Dependency Injection in iOS
Dependency Injection in iOSDependency Injection in iOS
Dependency Injection in iOSPablo Villar
 
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)Kaunas Java User Group
 
Quality Assurance Guidelines
Quality Assurance GuidelinesQuality Assurance Guidelines
Quality Assurance GuidelinesTim Stribos
 

What's hot (20)

Win at life with unit testing
Win at life with unit testingWin at life with unit testing
Win at life with unit testing
 
Test Driven Development - Overview and Adoption
Test Driven Development - Overview and AdoptionTest Driven Development - Overview and Adoption
Test Driven Development - Overview and Adoption
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
SW Testing Fundamentals
SW Testing FundamentalsSW Testing Fundamentals
SW Testing Fundamentals
 
Quality Software With Unit Test
Quality Software With Unit TestQuality Software With Unit Test
Quality Software With Unit Test
 
Testing & continuous delivery
Testing & continuous deliveryTesting & continuous delivery
Testing & continuous delivery
 
Verification and Validation in Manual Testing
Verification and Validation in Manual TestingVerification and Validation in Manual Testing
Verification and Validation in Manual Testing
 
Beyond Unit Testing
Beyond Unit TestingBeyond Unit Testing
Beyond Unit Testing
 
Writing Testable Code
Writing Testable CodeWriting Testable Code
Writing Testable Code
 
2 fitnesse
2 fitnesse2 fitnesse
2 fitnesse
 
Unit tests benefits
Unit tests benefitsUnit tests benefits
Unit tests benefits
 
Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016
 
XP in the full stack
XP in the full stackXP in the full stack
XP in the full stack
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Test Driven Development (TDD)
Test Driven Development (TDD)Test Driven Development (TDD)
Test Driven Development (TDD)
 
Documenting code yapceu2016
Documenting code yapceu2016Documenting code yapceu2016
Documenting code yapceu2016
 
Dependency Injection in iOS
Dependency Injection in iOSDependency Injection in iOS
Dependency Injection in iOS
 
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
 
Quality Assurance Guidelines
Quality Assurance GuidelinesQuality Assurance Guidelines
Quality Assurance Guidelines
 

Viewers also liked

Viewers also liked (16)

Separata protoracionalismo
Separata protoracionalismoSeparata protoracionalismo
Separata protoracionalismo
 
DIG1108 Lesson 5
DIG1108 Lesson 5DIG1108 Lesson 5
DIG1108 Lesson 5
 
Dig1108 c lesson1
Dig1108 c lesson1Dig1108 c lesson1
Dig1108 c lesson1
 
DIG1108 Lesson 6
DIG1108 Lesson 6DIG1108 Lesson 6
DIG1108 Lesson 6
 
Live virtual machine migration based on future prediction of resource require...
Live virtual machine migration based on future prediction of resource require...Live virtual machine migration based on future prediction of resource require...
Live virtual machine migration based on future prediction of resource require...
 
DIG1108 Lesson 8
DIG1108 Lesson 8DIG1108 Lesson 8
DIG1108 Lesson 8
 
Spanish verbs friends
Spanish verbs friendsSpanish verbs friends
Spanish verbs friends
 
DIG1108 Lesson 4
DIG1108 Lesson 4DIG1108 Lesson 4
DIG1108 Lesson 4
 
Dig1108C Lesson 2
Dig1108C Lesson 2Dig1108C Lesson 2
Dig1108C Lesson 2
 
Dig1108 Lesson 3
Dig1108 Lesson 3Dig1108 Lesson 3
Dig1108 Lesson 3
 
Spirent SDN and NFV Solutions
Spirent SDN and NFV SolutionsSpirent SDN and NFV Solutions
Spirent SDN and NFV Solutions
 
Solar powered house report
Solar powered house reportSolar powered house report
Solar powered house report
 
historia del internet
historia del internethistoria del internet
historia del internet
 
Acclerating SDN and NFV Deployments with Spirent
Acclerating SDN and NFV Deployments with SpirentAcclerating SDN and NFV Deployments with Spirent
Acclerating SDN and NFV Deployments with Spirent
 
Solar powered house
Solar powered houseSolar powered house
Solar powered house
 
Plc example presentation
Plc example presentationPlc example presentation
Plc example presentation
 

Similar to DIG1108 Lesson 7

Upstate CSCI 540 Unit testing
Upstate CSCI 540 Unit testingUpstate CSCI 540 Unit testing
Upstate CSCI 540 Unit testingDanWooster1
 
DIG1108C Lesson 7 Fall 2014
DIG1108C Lesson 7 Fall 2014DIG1108C Lesson 7 Fall 2014
DIG1108C Lesson 7 Fall 2014David Wolfpaw
 
SE2_Lec 21_ TDD and Junit
SE2_Lec 21_ TDD and JunitSE2_Lec 21_ TDD and Junit
SE2_Lec 21_ TDD and JunitAmr E. Mohamed
 
SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)Amr E. Mohamed
 
Testing Options in Java
Testing Options in JavaTesting Options in Java
Testing Options in JavaMichael Fons
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flexmichael.labriola
 
Testing practicies not only in scala
Testing practicies not only in scalaTesting practicies not only in scala
Testing practicies not only in scalaPaweł Panasewicz
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosFlutter Agency
 
Testing concepts ppt
Testing concepts pptTesting concepts ppt
Testing concepts pptRathna Priya
 
Testing concepts ppt
Testing concepts pptTesting concepts ppt
Testing concepts pptRathna Priya
 
Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2Tricode (part of Dept)
 
Unit testing (workshop)
Unit testing (workshop)Unit testing (workshop)
Unit testing (workshop)Foyzul Karim
 

Similar to DIG1108 Lesson 7 (20)

Upstate CSCI 540 Unit testing
Upstate CSCI 540 Unit testingUpstate CSCI 540 Unit testing
Upstate CSCI 540 Unit testing
 
DIG1108C Lesson 7 Fall 2014
DIG1108C Lesson 7 Fall 2014DIG1108C Lesson 7 Fall 2014
DIG1108C Lesson 7 Fall 2014
 
Why test with flex unit
Why test with flex unitWhy test with flex unit
Why test with flex unit
 
SE2_Lec 21_ TDD and Junit
SE2_Lec 21_ TDD and JunitSE2_Lec 21_ TDD and Junit
SE2_Lec 21_ TDD and Junit
 
SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Why unit testingl
Why unit testinglWhy unit testingl
Why unit testingl
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Testing Options in Java
Testing Options in JavaTesting Options in Java
Testing Options in Java
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
 
Testing practicies not only in scala
Testing practicies not only in scalaTesting practicies not only in scala
Testing practicies not only in scala
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
 
Testing concepts ppt
Testing concepts pptTesting concepts ppt
Testing concepts ppt
 
Testing concepts ppt
Testing concepts pptTesting concepts ppt
Testing concepts ppt
 
Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2
 
Unit testing (workshop)
Unit testing (workshop)Unit testing (workshop)
Unit testing (workshop)
 
SE2011_10.ppt
SE2011_10.pptSE2011_10.ppt
SE2011_10.ppt
 
PHPUnit
PHPUnitPHPUnit
PHPUnit
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
TDD Workshop UTN 2012
TDD Workshop UTN 2012TDD Workshop UTN 2012
TDD Workshop UTN 2012
 

Recently uploaded

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 

Recently uploaded (20)

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 

DIG1108 Lesson 7

  • 1. INTRO TO SERVER SIDE PROGRAMMING Week Seven Friday, October 18, 13
  • 2. Review - Functions Functions must start with the function keyword, must contain a valid function identifier (with variables), provide an optional list of arguments surrounded by parentheses, even if there are none, and a block of code: function do_something( $an_argument, $another ) { // Code goes here } Nothing from outside is visible to code in the block Nothing inside the block is visible outside the function Pass values into a function as arguments at invocation: do_something( 'some value', "$another_value ); Friday, October 18, 13
  • 3. Assertion Testing An assertion is a predicate (true-false statement) placed in a program to indicate that the developer thinks that the predicate is always true at that place. Programmers can use assertions to help specify programs and to reason about program correctness A precondition- an assertion placed at the beginning of a section of code, determines the set of states under which the programmer expects the code to execute A postcondition - placed at the end - describes the expected state at the end of execution Friday, October 18, 13
  • 4. assert( 1 + 1 == 1 ); // PHP Warning: Assertion failed assert( "1 + 1 == 1" ); // PHP Warning: Assertion "1 + 1 == 1" failed assert_options( ASSERT_WARNING, false ); if( ! assert( "1 + 1 == 1" ) ) // No PHP Warning message Friday, October 18, 13
  • 5. Software Testing Software testing is the process of validating and verifying that the software: meets requirements that guided its design and development works as expected (produces the desired outputs/behavior) satisfies the needs of stakeholders Automated testing is the process of writing software that performs automated, repeatable isolated tests on a completely separate software system called the System Under Test (SUT) Friday, October 18, 13
  • 6. Types of Testing Assertion testing - is this statement correct? Can it be incorrect? Unit testing - does this function produce the expected output? Functional testing - does this module provide the expected functionality? Integration testing - do these modules work together? System testing - can we run this software where we need it? Validation testing - does it do what we said that it was supposed to do? Acceptance testing - is it actually useful to the intended users? Regression testing - now that we fixed something what else did we break? Friday, October 18, 13
  • 7. Test-Driven Development Test-driven development is a software development process that relies on the repetition of a very short development cycle. The developer writes an automated test case that defines a desired improvement or function, then produces the minimum amount of code to pass that test and finally refactors the new code to acceptable standards 1. Write code that describes a function that would be desirable to have but does not yet exist 2. Run the tests to generate feedback and observe 3. Write some code that attempts to provide the function 4. Run the tests to generate feedback. Note failures and continue to write code to produce a success 5. Repeat as necessary Friday, October 18, 13
  • 8. How Does Testing Help? Writing and running an automated, repeatable and isolated test suite against your software answers: How do I know that my system provides the desired functionality according to the provided specs? When a bug surfaces, how do I know where in the codebase the problem exists and whether or not I've fixed it? When I add a new functionality or correct a bug, how do I know that I haven't broken something else? How can I ensure that a bug, once fixed, does not resurface when I fix another bug or add more functionality? If I improve the structure or organization of my code for readability, how do I know that it still works the same way? Friday, October 18, 13
  • 9. Rules of the Code Dojo Pair Programming: Pilot-Copilot One person is the pilot and does the typing One person is the copilot and tries to talk the solution out Everyone else is passengers (quiet while flying!) Timed for X minutes, then: The pilot becomes a passenger, the copilot becomes the pilot, a passenger becomes the new copilot Repeat until the problem is solved, everyone has been pilot and copilot, or we run out of time Friday, October 18, 13
  • 10. Rules of the Dojo cont. Test Driven Development: Red-Green-Refactor Red: the pilot cannot write any production code until there is at least one failing test Green: the pilot should only write production code that attempts to satisfy the current failing tests, save and rerun frequently Refactor: Once all tests are passing, look for opportunities to simplify or improve readability before moving on Don't talk while Red: Only the pair can talk while the timer is running Allow the pair time to figure out the next steps on their own Friday, October 18, 13
  • 11. Dojo Assignment Write a set of functions that all accept exactly two parameters and provide the functionality of a basic calculator: addition, subtraction, multiplication and division. Use simple assertion tests to develop in a test driven manner: assert( 'add(1,1) == 2' ); assert( 'sub(4,2) == 2' ); Ensure that your test covers positive and negative numbers for all operations and multiplication or division by zero. The program should never produce a Fatal Error, so handle error conditions internally Friday, October 18, 13
  • 12. Dojo Homework Create a new file in your assignments rep named assignment-8.1.md and open it Research the different kinds of testing that we discussed, specifically Unit Testing and Integration Testing and cite some of the cons and pitfalls of them Find a link to at least one blog post or article in favor of testing and one against and save them to your file, preparing to discuss them in class List at least three of the many active testing frameworks for PHP with links to the project pages Save your work, commit changes and push to Github Friday, October 18, 13