Object Oriented Data Structures Java: Chapter 2

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Why would we use an interface to formally specify the logical level of an ADT?

- It provides a template for classes to fill - A separate class then "implements" it

What are the two ways to define software testing?

- The process of executing a program with data sets designed to discover errors. - Software testing is one facet of software verification.

What are the Two Standard variations of stepwise refinement

- Top-Down: the problem is broken down into several parts and each part is divided and then those parts are subdivided. Used to design non-trivial methods - Bottom-up: Details come first. They are brought together into increasingly higher-level components. A useful approach if you can identify previously created program components to reuse in creating your system.

What conditions do Java interfaces have?

- Variables must be constant - Methods must be abstract - A Java interface cannot be instantiated

What are some benefits to using an interface

- We can check if our syntax meets our specifications - We can check if the interface "contract is met", IE: method names, return types, and parameters are correct. - We can provide a consistent interface to applications from among alternate implementations of the ADT.

Types of Observers

- contains(String element): returns true if element is in the StringLog, false otherwise; We ignore case when comparing the strings. - size: returns the number of elements currently held in the StringLog. - isFull: returns whether or not the StringLog is full. - getName: returns the name attribute of the StringLog. - toString: returns a nicely formatted string that represents the entire contents of the StringLog.

What must we do for each test case?

-determine inputs that represent the test case -determine the expected behavior of the program for the given input -run the program and observe the resulting behavior -compare the expected behavior and the actual behavior of the program

Preconditions

Assumptions that must be true on entry into a method for it to work correctly.

Constructors

Crates a new instance of the ADT. It's up to the implementer of the StringLog to decide how many and what kind of constructor to provide.

LLStringNode log

In this implementation, the elements of a StringLog are stored in a linked list of LLStringNode objects. We call the instance variable that we use to access the strings log. It will reference the first node on the linked list, so it is a reference to an object of the class LLStringNode.

Abstract Method Rules

Only includes a Description of its parameters No method bodies or implementations are allowed Only the interface of the method is included.

Instance variable int lastIndex = -1;

Originally the array is empty. Each time the insert command is invoked another string is added to the array. We use this variable to track the index of the "last" string inserted into the array.

Implementation (or concrete) level

Provides a specific representation of the structure to hold the data and the implementation of the operations. Here we deal with the "how" questions.

Logical (or abstract) level

Provides an abstract view of the data values (the domain) and the set of operations to manipulate them. At this level, we deal with the "what" questions. What is the ADT? What does it model? What are its responsibilities? What is its interface?

Instance variable String name;

Recall that every StringLog must have a name. We call the needed variable name.

String name;

Recall that every StringLog must have a name. We call the needed variable name.

What are the responsibilities of StringLog ADT

Remember the strings that have been inserted into it and to verify if their are any matching strings

Logical (or abstract) level

StringLogInterface provides an abstract view of the StringLog ADT. It is used by the UseStringLog application and implemented by the ArrayStringLog class.

Postconditions or Effects

The results expected at the exit of a method, assuming that the preconditions are true.

Data abstraction

The separation of a data type's logical properties from its implementation

Functional domain

The set of valid input data for a program or method

What is a StringLog used for?

To record strings and later check to see if a particular string has been recorded

Deskchecking

Tracing an execution of a design or program on paper

Application (or user or client) level

We use the ADT to solve a problem. When working at this level we only need to know how to create instances of the ADT and invoke its operations.

What purpose do test cases serve?

allow us to assert that a program works correctly

How to identify text cases?

- Covers general dimensions of data - Within each dimension identify categories of inputs and expected results - Test at least one instance of each combination of categories across dimensions. - Testing like this is called black-box testing and the tester must know the external interface to the module.

Types of Transformers & definitions

- Insert(String Element): Assumes the StringLog is not full and adds elements to the log of strings - Clear: resets the StringLog to the empty state; the StringLog retains its name.

Walk-through

A verification method in which a team performs a manual simulation of the program or design

Inspection

A verification method in which one member of a team reads the program or design line by line and the others point out errors

Software verification

The process of determining the degree to which a software product fulfills its specifications

Software validation

The process of determining the degree to which software fulfills its intended purpose.

Stepwise Refinement

- Approach a problem in stages. - Similar steps are followed during each stage, with the only difference being the level of detail involved. -The completion of each stage brings us closer to solving our problem.

How are Java interfaces similar to Java classes?

- Can include variable declarations - Can include methods

What must a StringLog have?

A "Name"

Self-referential class

A class that includes an instance variable or variables that can hold a reference to an object of the same class

Abstract data type (ADT)

A data type whose properties (domain and operations) are specified independently of any particular implementation

Test plan

A document showing the test cases planned for a program or module, their purposes, inputs, expected outputs, and criteria for success

Abstraction

A model of a system that includes only the details essential to the perspective of the viewer of the system

What is a node?

A node in a linked list is an object that holds some important information, such as a string, plus a link to the exact same type of object, i.e. to an object of the same class.

Test driver

A program that calls operations exported from a class, allowing us to test the results of the operations

In limited test cases, where the functional domain is small, what can someone do to verify the program is working?

Test the program against every possible input element.

Implementation (or concrete) level

The ArrayStringLog class developed in Section 2.3 provides a specific implementation of the StringLog ADT, fulfilling the contract presented by the StringLogInterface. It is used by applications such as UseStringLog. Likewise, the LinkedStringLog class (see Section 2.6) also provides an implementation.

Application (or user or client) level

The UseStringLog program is the application. It declares a variable log of type StringLogInterface. It uses the ArrayStringLog implementation of the StringLogInterface to perform some simple tasks.

Instance variable String[] log;

The elements of a StringLog are stored in an array of String objects named log.

Information hiding

The practice of hiding details within a module with the goal of controlling access to the details from the rest of the system


Kaugnay na mga set ng pag-aaral

LANGUAGE: Avoiding Stereotypes and Sexist Language

View Set