(Test Driven) Software Development - PowerPoint PPT Presentation

About This Presentation
Title:

(Test Driven) Software Development

Description:

Title: PowerPoint Presentation Last modified by: Erik Zeitler Created Date: 1/1/1601 12:00:00 AM Document presentation format: On-screen Show Other titles – PowerPoint PPT presentation

Number of Views:193
Avg rating:3.0/5.0
Slides: 22
Provided by: uuse
Category:

less

Transcript and Presenter's Notes

Title: (Test Driven) Software Development


1
(Test Driven) Software Development
  • Erik Zeitler

2
Dream up a business case
  • Think of a service you want to see
  • Figure out how to do it in a way that doesnt
    suck
  • Do it

3
How to do it?
  • Think about the use cases
  • How will the service be used
  • Cut the work into pieces
  • User Interface, application code, database
  • Assign pieces within the project group
  • Use Test Driven Development
  • Test each piece (unit tests)
  • Test all pieces together (integration/regression
    tests)

4
Rapid prototyping
  • Make a simple prototype ASAP
  • See what new ideas it gives you
  • Often, users dont know what they want until
    they see it Steve Jobs
  • Show your prototype to the other project groups
  • Give feedback to each other

5
Three-tier architecture
  • User Interface
  • What should the user see?
  • Make drawings
  • Database
  • What information will you keep?
  • Do data modelling, using ER diagrams
  • Business logic
  • How will you present the data to the users?
  • For any non-trivial function, do test driven
    development

6
Data modelling
  • Keep persistent data in a database
  • Customer information
  • Banking information
  • Inventory
  • What do you carry, and how much do you have right
    now?
  • Past activity
  • What has the customer bought?
  • What has the customer looked at?
  • What information do you want to store? Why?
  • Make an Entity Relationship diagram
  • Translate the ER diagram into SQL tables

7
Example of an ER diagram
8
Why ER diagrams?
  • Keep talking about the algorithms, and everyone
    will stay totally mystified
  • Show the ER diagram, and everything else will be
    obvious

9
Software development is all about Getting Things
Done
  • Priorities in software development
  • Make it work
  • Make it beautiful
  • Make it fast

10
How?
  • How to make it work?
  • First write tests,
  • then write code.
  • This is called Test Driven Development.
  • How to make it beautiful?
  • Re-factor
  • How to make it fast?
  • Dont worry about performance until performance
    is a problem.

11
Why TDD?
  • Because
  • Debugging sucks
  • Testing rocks
  • Because does it
  • A test is a specification
  • The capabilities of a program is defined by its
    tests
  • If the tests pass
  • we know that the program works for the test
    cases.
  • A test is a piece of documentation

12
The rules of TDD are simple
  • You can't write production code unless there is a
    broken test.
  • First write a test, then write the code
  • When there is a broken test, you change your code
    to make it pass.
  • When your code is working, you refactor to
    eliminate any code smells

13
What is code smell?
  • Something is fishy about the code
  • http//en.wikipedia.org/wiki/Code_smell
  • Examples
  • Large method
  • A function that is gt 1 page
  • Duplicated method
  • A method, function, or procedure that is very
    similar to another.
  • Contrived Complexity
  • Forced usage of overly complicated design
    patterns where simpler design would suffice

14
Demonstration
  • yay

15
A good set of tests
  • Covers all code
  • How many lines of code do you have?
  • How many lines are tested?
  • Do you have gt 90 test coverage?
  • performs tests on different scale
  • unit integration regression
  • tests for all cases, including edge cases and
    errors
  • e.g. expectException()

16
Different sized tests
Large (regression)
Medium (integration)
Small (unit)
isolation,speed
confidence in whole system
17
Where is the bug?
vs.
Test failed
Test failed
18
Does the entire system work?

vs.



19
Tests for edge cases and errors
  • Write tests for invalid input data, like
  • empty strings
  • empty data sets
  • false
  • broken input data
  • what happens to your functions if they get
    a76tr4234, when they expected a single
    character (e.g. a)?
  • Generate exceptions in production code
  • catch exceptions in test code

20
Test your database
  • Set up a test database, identical to your
    production database
  • Grant privileges to your php test script
  • Call your stored procedures from your php test
    script
  • Validate the result data from the database

21
Further resources
  • Soon available on the course home page
  • The latest PHPUnit (simpletest)
  • These slides
  • My demonstration examples
  • IDEs (Eclipse, Netbeans, ...) have infrastructure
    for testing
Write a Comment
User Comments (0)
About PowerShow.com