Test-based programming - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

Test-based programming

Description:

Test-based programming Ask: What should this software do? Write a test first Does this software do X correctly? Fill in the code, and keep working until ... – PowerPoint PPT presentation

Number of Views:98
Avg rating:3.0/5.0
Slides: 22
Provided by: AlanA168
Category:

less

Transcript and Presenter's Notes

Title: Test-based programming


1
Test-based programming
  • Ask What should this software do?
  • Write a test first Does this software do X
    correctly?
  • Fill in the code, and keep working until the test
    runs successfully

2
Designing a Simple Computational Program
  • Static Beam Deflection

Exaggerated beam deflection
3
Desired Output
  • Prediction of shape of beam deformed under static
    load
  • More specific

4
Necessary Inputs
5
Necessary Mathematics
  • Math is what will connect the inputs and outputs

6
Mathematical Steps
  • Translate inputs into mathematical terms
    (boundary conditions, loads)
  • Solve the differential equation (numerically)
  • Parse the numerical output to get user-desired
    output

7
Generality
  • Hardest part of starting numerical code is
    finding the right level of generalization to
    start coding with
  • too general means it takes too long to get going
  • too specific can mean substantial investment in
    risky re-engineering later
  • Rule of thumb structure for the most common
    range of cases first, and get it running
  • Re-engineering may never happen (false cost)
  • may be easier after your experience (inflated
    cost)
  • will have test cases (makes re-writing more
    reliable)

8
Generality in Beam Problem
  • Beam Structure/Supports
  • Mathematical Solving Technique

9
Beam Structure/Supports
  • Implement first for cantilevered beams
  • Initial conditions are

10
Range of Loads
  • Loads are
  • difficult to input as functions
  • hard to input as a list of points with forces
  • harder to integrate numerically with point forces
  • For a first run, well assume q(x) is uniform
    (constant)

11
Designing the software
Need user input, mathematical formulation,
solving, and expressing user output Will code in
object oriented format, with beam being an object
12
Designing the software II
13
Necessary Functions
14
Where to test
  • Remember, its good practice to think of the test
    before the code!

15
Where to test
  • Remember, its good practice to think of the test
    before the code!

16
What are the tests?
  • Input/Output for beam
  • Integration Module

17
Test code vs. Functional Code
18
Implementation in Java
19
Getting Started with Java
  • Download the Java Development Kit (JDK)
  • (not the run-time environment, which just lets
    you run programs, not write them)
  • Follow the tutorials to get a Hello, world
    program running
  • Read up on the fundamentals of object-oriented
    programming
  • http//java.sun.com/docs/books/tutorial/java/conce
    pts/
  • Keep in mind
  • Once you get into programming, you dont need to
    understand every line of someone elses code
  • imitation (also known as cut and paste) is the
    sincerest form of flattery. If appropriate,
    simply cite the source.

20
For next class
  • Get Java running on a machine you can use
  • Get a working program running
  • Get the scaffold for a beam class, which has
    inputs for the cantilevered case
  • No internals need to be written yet
  • Read the JUnit descriptions (as much as makes
    sense to you)
  • Come with questions!

21
Resources
  • Beam deflection
  • http//www.geom.uiuc.edu/education/calc-init/stati
    c-beam/
  • Java Tutorials
  • http//java.sun.com/docs/books/tutorial/
  • JUnit
  • http//junit.sourceforge.net/Documentation
  • http//www.junit.org/
Write a Comment
User Comments (0)
About PowerShow.com