PM past exams

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

(a) What is the purpose of the SwingWorker class of Java? (b) Describe the two main steps for client code to use the SwingWorker class? (c) Explain which design patterns play a role here, and what that role is.

(a) To avoid running of time consuming computations in the main GUI thread, and instead run them in a separate (background) thread. (b) i. (Static aspect; declaration) By subclassing SwingWorker and overriding the doInBackground() and done() methods. ii. (Dynamic aspect; execution) The resulting SwingWorker subclass must be instantiated for each run. The background thread is activated by calling execute(). (c) i. Template Method pattern: The methods execute(), publish(), and get() are template methods, holding the "common" code. The overridable methods doInBackground(), process(), and done() serve as hook methods, in which client code provides the (variable) details for the various "steps". ii. Facade pattern: SwingWorker provides a simplified interface for the Java thread library

What are the advantages of throwing a Java exception instead of returning a special value to signal a violated precondition?

(a) When all return values can occur under normal circumstances, it would be impossible to return a special value. (b) Client code needs to check for the special value, also if it just wants to propagate the signal to a higher level in the call chain. (c) The programmer might forget to check the return value; exc

Give three benefits of applying design patterns.

+ Design patterns facilitate reuse. + Design patterns make design easier. + Design patterns capture expertise and facilitate its dissemination. + Design patterns define a shared vocabulary for discussing design and architecture. + Design patterns move software development closer to a well-established engineering discipline. + Studying design patterns improves your ability to do original design. + Knowing popular design patterns makes it easier to learn class libraries that use design patterns.

What is the difference between a mutable and immutable class? What are advantages and disadvantages?

-

List at four reasons why it is not a good idea to include unnecessary test cases. You don't need to explain these reasons.

- Unnecessary test cases cost extra test development time. - Unnecessary test cases give false impression of code quality. - Unnecessary test cases give false impression of code quality. - Unnecessary test cases give false impression of code quality. - Unnecessary test cases add to the maintenance burden of your software.

Describe a solution for the Command design pattern, including a UML class diagram to indicatethe roles and relationships of the various parts of the solution.

1. Introduce separate superclass for command objects; 2. let concrete commands store 3. receiver and (when needed) actual parameters, and 4. provide a general method (e.g. execute()) to let invoker call the method on the receiver withgiven parameters, without having to know the receiving object and the name of the called method.

Define what an Iterator<T> is and what an Iterable<T> is. Highlight how they differ in purpose.

1. Iterator<T> holds state of a specific iteration over T. 2. Iterable<T> represents a collection over T that can be iterated over (with for-each statement, which uses the factory method iterator() ).

Test cases can be performed manually, or their execution can be automated. List four reasons for insisting on automated test cases as part of delivered software. You don't need to explain these reasons.

1. Manual testing is tedious, time consuming and error prone. 2. Automated test cases are more convenient, faster and more reliable. 3. It is easier to inspect results of automated test cases. 4. Automated test cases are operationalization of the requirements by specifying how to invoke tested feature, how to decide between passing and failing. 5. Good test cases obviate later debugging. 6. Automated test cases serve as a safety net when refractoring the code.

Give two resong why Abstract Data Types are useful.

1. implementation can change without affecting client code, keeping changes limited. 2. facilitates multiple implementations.

What is a generic class and why is it useful?

A class whose definition involves one or more type parameters. These parameters abstract from concrete types, making the class more generally (re)usable, and they improve type safety (compared to using Object as concrete type).

What is a good way to achieve robustness?

A good way to achieve robustness is to specify in the contract how violated preconditions will be signaled and then in the method implementation to check for these precondition violations and send the corresponding signal. The most appropriate sort of signal is throwing an exception with a useful message.

What does it mean that a method (function, procedure) is robust?

A method is called robust when its behavior under a violated precondition is well-specified in its contract.

For ADTs, we distinguish between specification and implementation. Which of the following form part of the implementation of ADT? - A representation invariant - Contracts for individual operations - Zero or more public invariants - An abstract function

A representation invariant and an abstraction function

What are advantages and disadvantages of using inner classes?

Advantages: • Logical grouping (increased coherence) Keep related things close together.• Encapsulation (decreased coupling) Only provide possibility to couple things that need to be coupled.• Improved readability and maintainability of source code A consequence of the preceding two benefits • Simpler code Inner class can access members of enclosing class, without needing an explicit reference to it. Disadvantages:

What is an abstract data type (ADT)?

An abstract data type makes available, for use in programs, a set of abstract values together with operations on those values. Its implementation is encapsulated and not directly accessible by client code, so that client code does not depend on the implementation.

How can such a dependence be avoided using design principles and patterns? (C to depend on another concrete class D)

Applying the Dependency Inversion Principle (DIP): Don't make a class (C) dependent on concrete code (D), rather make both depend on an abstraction. • Introduce an interface for class D. • Let class D implement that interface. • Make class C dependent on that interface. • Let client code of class C configure it at runtime to use class D (Dependency Injection). By considering D as an algorithm that needs to be variable at runtime, application of the Strategy design pattern will result in the same design with inverted dependency. Alternatively, one might be able to apply the Template Method or Factory Method design patterns.

When applying Observer design pattern, in practice, observer managemet supporting multiple observers is often built into the Subject. An alternative to this is to combine the application of the Observer design pattern with that of another design pattern. Which other design pattern is this?

Composite design pattern

For ADTs, we distinguish between specification and implementation. Which of the following are part of the specification of an ADT? - A representation invariant - Contracts for individual operations - Zero or more public invariants - An abstract function

Contracts for individual operations and zero or more public invariants

What is design principle DRY and how does it relate to functional decomposition?

DRY stands for Don't Repeat Yourself (Slide 29 of Lecture 2). Duplicated code should invite functional decomposition: put one copy of the duplicate code in a function (procedural abstraction), and replace each duplicate fragment by a call to that function.

Name three disadvantages of robustness.

Disadvantages: • Overhead to write the precondition checks, and to test them. • Overhead to read and understand, during maintenance/evolution. • Runtime overhead in checking the precondition, even if satisfied. • Runtime overhead in throwing, propagating, catching exceptions.

In the context of abstract data types, what is encapsulation, and why is it useful?

Encapsulation in ADT bundles and hides implementation details (data representation and operation implementations; using class mechanism), separate from specification in ADT (using interface or abstract class mechanism). It impossible for clients to directly dependon implementation details. It possible to change the encapsulateddetails (i.e. implementation) without affecting client code.

A design pattern is code solving a design problem

False

A design pattern is code solving a design problem.

False

A fault is a difference between actual and specified/expected result.

False

A fault is a human action ("slip") causing a failure.

False

An instance of a class implementing Iterator, i.e. an iterator for a collection of type T, can be reused for multiple iterations over that collection.

False

Given an abstract data type (ADT) specification and an implementation class for such an ADT, an abstraction function is a method in the implementation class that implements a method from the ADT specification.

False

Given two Java programs that satisfy the same specification, if one version applies a design pattern and the other does not, the former version is always preferable.

False

If teo class diagrams each represents the application of a design pattern and are the same apart from naming of classes, methods and variables, then they represent an instantiation of one and the same design pattern.

False

Let U be any subclass of a class T, possibly in multiple steps. You can substitute an object of typeU in each place where an object of type T can be used, without affecting the correctness of theprogram.

False

Testing localizes defects.

False

Testing, reviewing, and debugging are all about detecting defects.

False

The Adapter pattern is used to extend the functionality of an existing class.

False

The Liskov Substitution Principle states that for U a subtype (possibly in multiple steps) of T, you can substitute an object of type U in each place where an object of type T can be used, without affecting the correctness of the program.

False

The Template Method design pattern is special case of the Factory Method design patter.

False

Cohesion refers to elements in different modules, whereas coupling refers to elements in the same module.

False. Cohesion = Measure of relatedness of 'things' inside a 'module' Keep related things together; separate unrelated things Coupling = Measure of connectedness between 'modules' Interface of a 'module' concerns all its external connections.

Testing is used to show the absence of defects.

False. Testing: The process of systematically executing software with the intent of detecting the presence of defects.

The first step of test-driven development is to write test cases.

False. The first step of test-driven development is to write contracts and interfaces.

Disregarding the Java SwingWorkerConcurrency pattern, design patters are treated in this course can be categorized as creational or structural.

False. There are creational, structural and behavioral.

The use of generic types for collection classes decreses type safety

False. They increase type safety, compared to using collections of Objects.

An instance of a particular subclass of SwingWorker can be reused for multiple runs of the background task.

False???

The design technique Divide & Conquer consists of just two steps: (1) split into subproblems and (2) solve subproblems independently

False??? Divide: Split problem into subproblems (decomposition) Conquer: Solve subproblems independently (solution; possible Conquer, recursion) Rule: Combine subproblem solutions into total solution (integration)

Which of the following design patterns are used for Java'sSwingWorker? - Façade - Strategy - Template Method - Factory Method

Façade and Template Method

The design pattern Singleton is not without problems. Which of the following may cause problems when Singleton, although properly implemented, is used without care? - Dependence on global variables - Code duplication - High cyclomatic complexity - Hidden dependencies

Hidden dependencies

Why are ADTs useful? Explain your answer.

Implementation code of an ADT can be changed without affecting (correctness of) client code. This is useful, because it limits the consequences of making changes to implementations.

What is functional decomposition?

In Java, functional decomposition is the application of Divide and Conquer using class methods (functions). In general, it is expressing a larger piece of functionality as a composition of smaller functions.

Explain the Dependency Inversion Principle, and show how the Strategy design pattern satisfies this principle.

In the anti-pattern for the Strategy design pattern, client/context code of an algorithm, which is implemented in a concrete class, declares and uses a variable of that concrete class, and calls the algorithm directly. The client/context code depends on (cannot be compiled without) the concrete class. In the Strategy design pattern, a supertype (abstract class or interface) is introduced to provide only the signature of the algorithm method without any concrete implementation, and this supertype is used in the client/context code. At run-time, the client/context code can be handed an object of a concrete class that implements or extends the strategy supertype. The client/context code and the concrete algorithm classes both depend on the (more abstract) strategy interface/superclass. So, the dependency has been inverted.

How can one test for robustness?

Ingredients: 1. Call the method under test in a try block such that its precondition is violated. 2. If the next statement is reached, and thus no exception was thrown, the test case fails. 3. Catch the thrown exception with a catch block; the test passes. In other words, if the excepted exception was thrown, the test case passes, otherwise it fails.

Describe the structure of a test case for robustness using the Java try statement and how it works.

Ingredients: i. Call the method under test in a try block such that its precondition is violated. ii. If the next statement is reached (no exception was thrown), the test case fails. iii. Catch the thrown exception in a catch block. iv. If the expected exception was thrown, the test case passes, else the test case fails.

Why is it a good idea to write modular programs? Give five reasons.

It facilitates, e.g., + communication about design, + independent construction by a team (not about parallel programs, but about programming in parallel), planning and progress tracking, + verifiability, + maintainability, + reuse.

When should you strive for robustness, and when not?

It is especially important to strive for robustness of method on public interfaces. However, if precondition checking is too costly, for example because it would take too long, or use too much resources, then it is not a good idea.

Define what an Iterator<T> and Iterable<T>. How do the two differ from the perspective of multiple iterations over acollection?

Iterator<T> cannot be reused after iteration terminates, while Iterable<T> canbe reused for multiple iterations.

Liskov Substitution Principle

Let U be a subclass (possibly in multiple steps) of T. Type U is called a subtype of type T, when In each place where an object of type T can be used, you can substitute an object of type U,without affecting the correctness of the program. It is good practice to ensure that subclasses are also subtypes. A subtype is not only syntactically a substitute (it compiles), but also semantically (it works).Meaning of method in subclass must match meaning in superclass.

Explain how the Strategy design pattern can be used as an alternative to the Template Method design pattern.

Main ingredients: > Consider each step, i.e. hook, a Strategy (cf. Strategy pattern), and introduce an abstract class or interface for each. > Give alternative template method class a ( polymorphic) instance variable for each step, with an abstract step as type. > Give alternative template method class a constructor (or appropriate setters) from parameters with abstract step strategies as type, to initialize (set ) the instance variables. > Client code injects concrete steps into an instance of the alternative template method class, via the constructor (or appropriate setter(s)).

State Design pattern

Objects have state and bahevior. Objects change their state based on internal and external events. If an objects goes through clearly identifiable states and the object's behavior is especially dependent on its state, it is a good state candidate for the State design pattern.

Describe the context and intent of the State design pattern.

Objects have state and behavior. Objects change their state based on internal and external events. If an object goes through clearly identifiable states, and the object's behavior is especially dependent on its state, it is a good candidate for the State design pattern.

Which of the mechanisms play a role in the Strategy design pattern

Overriding Polymorphism Inheritance

The Singleton design pattern ensures that at most one instance of a class is created. What is an important danger when using this design pattern?

Possible dangers (induced by direct dependence on global object): - Weakened modularity - Testing is more difficult - Code reuse is hindered But also acceptable: Concurrency and race condions

Describe (a) the problem (context & intent) and (b) a solution for the Strategy design pattern, including a UML class diagram to indicate the roles and relationships of the various parts.

Problem (context & intent) (a) Accommodate multiple implementations of the same feature (method, class), (b) allowing selection of implementation at runtime, (c) ensuring that client code does not depend on implementation code. Solution: (a.i) Put specfication/interface/contract in separate (abstract) class or interface, (a.ii) implementations in subclasses of specification (b.i) Client declares variables in terms of specification type, (b.ii) assigning an object of the desired implementation type. (Note: This works by using the language mechanisms inheritance, polymorphism, and overriding.)

What is design principle SRP and how does it relate to functional decomposition?

SRP stands for Single Responsibility Principle - each 'function' should solve a single well-defined problem. It is a guideline for functional decomposition: if the code in a function implementation1 concerns multiple responsibilities, then that is reason to decompose it (further).

What does it mean for a concrete class C to depend on another concrete class D?

That class C cannot be compiled without having class D as well.

Adapter design pattern

The Adapter design pattern is useful in situations where an existing class provides a needed service but there is a mismatch between the interface offered and the interface client expect. The Adapter pattern shows how to convert the interface of the existing class into the interface clients expect. BENEFITS OF ADAPTER PATTERN: * -> Implementing the adapter pattern with the inheritance rather than composition requires less code. However, inheritance also creates the potential for tighter coupling between the adapter and adaptee. * -> Resolves incopatibilities between two existing interfaces. DRAWBACKS OF ADAPTER PATTERN: * -> Inheritance creates coupling between the adapter and adaptee. * -> Composition requires more code.

Command Pattern

The Command pattern encapsulates a request as an object and decouples the request from clients invoking the request. Components: 1. Receiver - the Receiver component represents existing functionality. The Command Pattern encapsulates a request. Typically the request is comprised of one or more operations being invoked on one or more existing receiver objects. 2. ConcreteCommand - ConcreteCommand calls operations on receiver objects in order to carry out the encapsulated request. 3. Command - Command is an abstract interface. It allows concrete commands to be loosely coupled to clients. 4. Invoker - Invoker objects initiate requests encapsulated in commands.

Composite design pattern

The Composite design pattern organizes objects into a tree data structure where lead nodes represent individual objects and interior nodes represent compositions of individual objects and/or other compositions. BENEFITS OF COMPOSITE PATTERN: * -> Allows clients to treat individual objects and compositions of objects uniformly. (Objects and compositions share the same interface.) * Clients interact with components in the Composite design pattern through the Component interface. Clients are unaware if they are dealing with primitive components or the composition of components.* (abstract class) Parcel <- Package, Jewelry, Clothes Client: Parcel mother = new Clothes("Mother", 6); Parcel father = new Clothes("Father", 8); Package parents = new Package("Parents"); parents.add(mother); parents.add(father);

Decorator design pattern

The Decorator design pattern provides an alternative to class inheritance for extending the behavior of existing classes. It uses object composition rather than class inheritance for a lightweight flexible approach to adding responsibilities to object runtime. It is especially useful when different combinations and permutations of features are permitted. BENEFITS OF DECORATOR PATTERN: * -> Does not violate Open-Closed principle. * -> Solves fragile superclass problem. DRAWBACKS OF DECORATOR PATTERN: * -> User must face a large number of small classes even for routine tasks. (interface) E_Book <- StandardEbook, (interface) E_Book <- Decorator <- Wi_Fi, DiscreetAdvertisements Client: standardEbook baseModel = new StandardEbook(); E_Book decoratedEbook = new Wi_Fi(new DiscreetAdvertisements (baseModel));

Facade design pattern

The Facade design pattern is used to provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use. BENEFITS OF FACADE PATTERN: * -> UNIFICATION. A Facade class defines a single point of access for clients. Clients deal with one class as opposed to a large interface or complex set of interfaces. * -> ABSTRACTION AND SIMPLIFICATION. The interface offered by the Facade class is a level of abstraction above that of the wrapped interface. This simplifies client code. * -> DECREASED COUPLING. A Facade class decouples clients from the details of a subsystem. Clients that access the services of a subsystem through a Facade class are buffered from changes in the subsystem. PointAndShootFacade: private Shutter shutter; private Aperture aperture; private Film film; Shutter Aperture Film Client: PointAndShootFacade pointAndShootCamera = new PointAndShootFacade(); pointAndShootCamera.takePicture();

Factory Method design pattern

The Factory Method Pattern defines an interface for creating an object, but lets subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses. BENEFITS OF FACTORY METHOD PATTERN: * -> Conforms to the open/closed principle. It is open for extension but closed for modification. * -> Allows changing the behavior of the object in the method creation. * -> Does NOT create a dependency between the code and the class or type of the object that is created. (Abstract class) ImageCreator (createImage()) <-ImageCreatorUsingFileData, ImageCreatorUsingFileExtensions (ADT) Image <- JPGImage, PNGImage Client: Image image1 = imageCreator.createImage("beach.jpg");

Iterator design pattern

The Iterator design pattern solves the problem of how to traverse the elements of a collection object in a way that keeps client code doing the traversing loosely coupled to the collection object as well as the traversal algorithm (without exposing the underlying implementation). BENEFITS OF INTERATOR PATTERN: * -> Does NOT expose the uderlying implementation

Observer design pattern

The Observer design pattern defines a one - to - many relationship between a subject-object and any number of observer objects such that when the subject object changes, observer objects are notifies and given a chance to react to changes in the subject. BENEFITS OF OBSERVER PATTERN: * -> Makes maintenance easier: Adding a new view would not require modifying the existing class (interface) Observer <- StockTrader, StockView Subject (attach, detach, notifyObserver) <- Stock (get price, get symbol, etc. - class that encapsulates the name and price of a stock.) Client: Stock stock = new Stock ("IBM", 250); StockView sv = new StockView(stock); StockTrader st = new StockTrader(stock, 253); The Subject class is responsible for: > Attaching and detaching observers > Notifying attached observers when the state of the subject changes > Application-specific state and logic

Quong from the Design Patterns book by Eddie Burris, "Designing software as a loose confederation of cooperating objects one brings with it the need to maintain consistency between related objects." Describe how the Observer design pattern helps to maintain this consistency, i.e. describe the intent of the Observer design paern

The Observer design pattern defines a one-to-many relationship between a subject object and any number of observer objects such that when the subject object changes, observer objects are notified and given a chance to react to changes in the subject. 1 point for essenally stang that "when the subject object changes, observer objects are nofied and given a chance to react to changes in the subject".

Singleton design pattern

The Singleton design pattern ensures that not more than one instance of a class is created and provides a global point of access to this instance. BENEFITS OF SINGLETON PATTERN: * -> Ensures that no more than one instance is created. * -> SYNCHRONIZED getInstance() method is thread-safe. (But bad performance) * -> Easy access. DRAWBACKS OF SINGLETON PATTERN: * -> Weakened modularity - many other modules will depend on that object/variable. * -> Code reuse is hindered - to reuse code depending on the global, you must also reuse that object. * -> Testing is more difficult - tests must also work with that one object; cannot easily vary it. private static Singleton firstInstance1 = null; public synchronized static Singleton getInstance1() { if (firstInstance1 == null) { firstInstance1 = new Singleton(); } return firstInstance1; }

Strategy design pattern

The Strategy design pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it. BENEFITS OF STRATEGY PATTERN: * -> Suit for componenets that postpone algorithm selection until runtime. * -> New algorithms can be added without altering context and context can be modified without altering algorithms (strategies). DRAWBACKS OF STRATEGY PATTERN: * -> Difficulty in hadling data interchange between the context and strategy objects * -> Client must be aware of different strategy algorithms and understand the tradeoffs among strategies in order to select the best one in the given situation. * -> Increased coupling between clients and the details of implementation. SamplingStrategy <-SystematicSampling, RandomSampling Client creates SamplingHelper (context). SamplingHelper calls the Sampling strategies.

Describe a solution of the Observer design pattern, by describing its three main components, as well as the role of each of these.

The Subject is responsible for: • Attaching and detaching observers • Notifying attached observers when the state of the subject changes • Application-specific state and logic "Observer defines an abstract interface with the callback operation [that] subject objects use to notify observers of a change. A subject is loosely coupled to its observers because the subject only knows about its observers through the abstract interface Observer. Concrete Observer implements the abstract interface Observer."

Template Method Design Pattern

The Template Method design pattern is used when there are two or more procedures or code fragments with the same basic structure but different detailed steps. BENEFITS OF TEMPLATE METHOD PATTERN: * -> Easy to manage the code, keep all document up to date. * -> Shows how to eliminate repetition in algorithm structure (DRY). DRAWBACKS OF TEMPLATE METHOD PATTERN: * -> High runtime and time complexity. Vegetable <- Tomato, Pumpkin Client: creates Tomat and Pumpkin

Describe a solution of the State design pattern.

The solution is to encapsulate state-specific behavior into separate objects and have the context (the object that goes through identifiable states) delegate state-specific requests to these objects. A separate concrete state class is created for each identifiable state of the context. State-specific behavior is encapsulated in these classes. The context defines the interface of interest to clients. It keeps a reference to the state object for the current state of the context. State-dependent requests from clients are forwarded to the current state object. State-independent requests from clients are handled locally in the context. Either the context or the concrete state objects are responsible for transitioning from one state to another

A design pattern is reusable in multiple, diverse, specific contexts

True

A failure is when a product deviates from requirements during use/operation.

True

A static member class can refer to all static members of its enclosing class directly, i.e, without qualifying the name and including those static members that are private.

True

Cohesion refers to elements in the same module, whereas coupling refers to elements in different modules.

True

Design idiom is a different form of reuse than a design pattern.

True

Each inner class has access to all members of its outer class

True

One of the purposes of an Iterator is to separate iteration logic from the collection to be iterated over.

True

Programming idiom is a different form of reuse than a design pattern

True

Test-Driven Development (TDD) forces one to define contracts and interfaces before wring test cases.

True

Testability benefits from funcional decomposion

True

The Decorator pattern is used to extend the functionality of an existing class.

True

The Factory Method design pattern is a special case of the Strategy design pattern

True

The Liskov Substitution Principle states that for U any subtype (possibly in multiple steps) of T, you can substitute an object of type U in each place where an object of type T can be used, without affecting the correctness of the program.

True

The main ingredients of a test case for a given method are its movation, which concrete input values to use, which output values to consider, and precise criteria to decide between passing and failing.

True

In Java, functional decomposition is the application of Divide & Conquer using class methods (functions).

True??

In an abstract data type (ADT), the representation invariant maps a valid data representation to the corresponding abstract value.

True??? Representation invariant (short: rep invariant) is condition to be satisfied by the instance variables, in order to make sense as a representation of an abstract value.

Why is it a good idea to strive for robustness? Use at most 50 words.

Without an explicit signal that a precondition was violated, it may appear that the problem is located inside the method that seemingly misbehaves.With an explicit signal that a precondition was violated, it is clear that the problem is located outside the method (it does not misbehave).

What are two concrete disadvantages of such a dependence? (C to depend on another concrete class D)

i. Hinders verifiability: C is harder to test, because you must use it together with that particular class D. That may be difficult, slow, expensive, and it can be hard to check that C uses D properly (since D is not designed to help in testing of C). ii. Hinders maintainability: when (the implementation of) class D changes, you must check (recompile, test) class C as well. iii. Hinder reuse: when reusing class C, you must reuse class D as well.

What kinds of code and documentation must be delivered to implement an ADT?

• Code: - A data representation (in terms of concrete types or other ADTs) - Implementations of all operations • Documentation: - representation invariant, stating the condition under which the data representation is valid; that is, when it represents an abstract value. - abstraction function, mapping a valid data representation to the corresponding abstract value.

Explain one major benefit of functional decomposition.

• Enables solution of more complex problems. • Organizes communication about solution domain. • Facilitates parallel construction by a team. • Improves ability to plan work and track progress . • Improves verifiability (facilitates "getting it to work"): - Allows early review of design. - Allows unit testing of separate components. - Allows stepwise integration (avoiding a "big bang"). • Improves maintainability : changes affect few components. • Improves possibilities for reuse .

What are the benefits of implementing test cases before, rather than after, implementing a software product?

• It helps stabilize interfaces and contracts before implementing them. • It encourages analysis of interfaces and contracts before implementing them. • It allows you to focus on implementing the module and getting it to work, without being interrupted by test case development.

What are the differences between an Iterator and an Iterable?

• Iterator<E>: - holds state of one specific iteration over E (1 point) - cannot be reused after the iteration terminates • Iterable<E>: - represents a collection over E that can (only) be iterated over with foreach statement (1 point) - can be reused for multiple iterations

Explain one disadvantage of functional decomposition.

• Top-level divisions are hard to make: can have big consequences. Need experience and need to experiment (try alternatives). • Separation often brings overhead (to cross boundary/interface). Also depends on implementation facilities (programming language). • The result looks bigger (overhead, again). But it has explicit structure (there is a price to that). • Functions cannot be specified/designed/implemented in isolation. They need to be considered in related groups (cf. class).


संबंधित स्टडी सेट्स

Investment Banking Practice Questions

View Set

MASON ANDREWS BASIC ENGLISH LESSON 1 1 THOUGH 12

View Set

Key General Chemistry Skills Properties of Solutions Dynamic Study Module

View Set

CBG.17 - Bacterial genetics 1 (Transformation)

View Set

Quiz 1: Choice in a world of scarcity

View Set