Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

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 Implement first for cantilevered beams Initial conditions are Beam Structure/Supports

10 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, we’ll assume q(x) is uniform (constant) Range of Loads

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, it’s good practice to think of the test before the code!

15 Where to test Remember, it’s 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/concepts/ Keep in mind: Once you get into programming, you don’t need to understand every line of someone else’s 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/static-beam/ Java Tutorials http://java.sun.com/docs/books/tutorial/ JUnit http://junit.sourceforge.net/#Documentation http://www.junit.org/


Download ppt "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."

Similar presentations


Ads by Google