CPSC 2150 - DAY 12 OCTOBER 4, 2016 ================================================================================ BENEFITS OF ABSTRACTION IN INTERFACE SPECIFICATION -------------------------------------------------- Benefits of abstraction in interface specifications .For users and testers (this lecture) .Code .Contracts public interface IntegerStack { /** * mathematical model Str(Z); * initialization ensures this = < > * defines maxDepth: N; * constraints |this| <= maxDepth; */ ***constraints are just like invariants. We use constraints in interfaces and invariants in classes *** ... } Code | State --------------------------------------------- IntegerStack si = new Stack1(100); si = < > Black Box Testing When test plans are based entirely on contracts, the approach is termed black-box testing (code is treated like a black-box) .Black-box test cases don't change if implementation code changes. DEVELOP A TEST PLAN FOR PUSH ---------------------------- .The idea of testing is a software engineering concept, not to be confused with how to do testing in java. .A set of test cases for a given unit is called a test plan or a test fixture for that unit. .Look at boundry, routine cases ------------------------------------------------ | Inputs | Results | Reason | ------------------------------------------------ |this = < > | this = <1> | boundry | |x = 1 |x=1 | | ------------------------------------------------- ***By saying nothing in the specs, this means ensures si = #si*** Notice we can do the testing, tracing, writing user code and everything without knowing the implementation Some more String Thepory .Reverse (s) >is the reverse order of string s .Prt_Btwn (m, n, s) >is the substring between possibilites in string ex. ) = <7,8,9> .Occurs_Ct >Counts the number of occurances of number .