1 of 10

STDIO Ghana

CABP

Object-Oriented Programming

&

Test-Driven Development

2 of 10

STDIO Ghana

CABP

Preview: why talk about these together?

OOP is about self-contained "widgets"

TDD is about writing tests then code.

How do you think they fit together?

3 of 10

STDIO Ghana

CABP

Syntax for objects in various languages

Java / Scala, C, C++, R, Perl, Javascript

What do these common features tell us?

4 of 10

STDIO Ghana

CABP

Notable similarities?

Types

Scope

Inheritance

What are their benefits?

5 of 10

STDIO Ghana

CABP

Interlude: Object Exercises

6 of 10

STDIO Ghana

CABP

Test Driven Development

initially, all tests fail, so...

code until each passes

testMethod1(testInput1) == desiredOutput1

testMethod2(testInput2) == desiredOutput2

...

testMethodN(testInputN) == desiredOutputN

7 of 10

STDIO Ghana

CABP

Test Driven Development

More details

- testing language features, OSS libraries?

- work incrementally

- what's worth testing?

- trade off test development vs. product development

8 of 10

STDIO Ghana

CABP

Some Testing frameworks

JUnit, ScalaTest, Perl tests,

Check, Google Test, etc

Why testing?

9 of 10

STDIO Ghana

CABP

What else would we want to "test" that hasn't been discussed so far?

What are hurdles to doing testing?

10 of 10

STDIO Ghana

CABP

Review:

How might OOP & TDD work together?

What needs to be tested in your projects?