0% found this document useful (0 votes)
238 views9 pages

Refactoring

The document discusses refactoring in software development. It provides definitions for key refactoring terms like refactoring, code smells, invariants, preconditions and postconditions. It also discusses techniques for refactoring like critical pair analysis and graph transformation. The goals of refactoring are outlined as improving qualities like maintainability while preserving functionality and behaviors. Metrics like cohesion and coupling are mentioned for evaluating internal software qualities both before and after refactoring.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
238 views9 pages

Refactoring

The document discusses refactoring in software development. It provides definitions for key refactoring terms like refactoring, code smells, invariants, preconditions and postconditions. It also discusses techniques for refactoring like critical pair analysis and graph transformation. The goals of refactoring are outlined as improving qualities like maintainability while preserving functionality and behaviors. Metrics like cohesion and coupling are mentioned for evaluating internal software qualities both before and after refactoring.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 9

Question: What is the purpose of refactoring in software development?

Answer: b) To decrease the maintenance cost of the software


Options:
a) To increase the complexity of the software
b) To decrease the maintenance cost of the software
c) To modify the software's functionalities
d) To conform to coding standards

Question: What is the term used for restructuring applied on object-oriented


software?
Answer: b) Refactoring
Options:
a) Restructuring
b) Refactoring
c) Redesigning
d) Reorganizing

Question: Which of the following is NOT a non-functional requirement improved


through restructuring?
Answer: d) Functionality
Options:
a) Readability
b) Extensibility
c) Maintainability
d) Functionality

Question: What is the goal of software restructuring?


Answer: c) To increase the external value of the software
Options:
a) To make the software more difficult to understand
b) To make the software more susceptible to faults
c) To increase the external value of the software
d) To decrease the lifetime of the software

Question: What is a code smell?


Answer: a) A symptom in source code that indicates a deeper problem
Options:
a) A symptom in source code that indicates a deeper problem
b) A pleasant scent emitted by well-structured code
c) A term used to describe well-documented code
d) A type of error in source code

Question: What are the entities that can be refactored at the design level?
Answer: a) Software architecture, class diagram, statechart diagram, and activity
diagrams
Options:
a) Software architecture, class diagram, statechart diagram, and activity diagrams
b) Software architecture, class diagram, and global control flow
c) Class diagram, statechart diagram, and database schemas
d) Software architecture, activity diagrams, and database schemas

Question: According to Figure 7.1, which refactorings are mentioned?


Answer: d) All of the above
Options:
a) R1: Rename method print to process in class PrintServer
b) R2: Rename method print to process in class FileServer
c) R3: Create a superclass Server from PrintServer and FileServer
d) All of the above
Question: Why is it important to carefully choose a subset of refactorings?
Answer: d) All of the above
Options:
a) Some refactorings must be applied together
b) Some refactorings must be applied in certain orders
c) Some refactorings can be individually applied, but they must follow an order if
applied together
d) All of the above

Question: What is needed to identify a feasible subset of refactorings?


Answer: a) Tool support
Options:
a) Tool support
b) Design expertise
c) Code review
d) User feedback

Question: Which technique can be used to analyze a set of refactorings to select a


feasible subset?
Answer: a) Critical pair analysis
Options:
a) Critical pair analysis
b) Sequential dependency analysis
c) Testing
d) Verification of preservation of call sequence

Question: What constitutes a conflicting pair in the context of refactorings?


Answer: b) Two refactorings that cannot be applied together
Options:
a) Two refactorings that can be applied together
b) Two refactorings that cannot be applied together
c) Two refactorings that have the same input/output behavior
d) Two refactorings that preserve non-functional requirements

Question: What must be applied before a refactoring can be applied?


Answer: a) One or more refactorings
Options:
a) One or more refactorings
b) Sequential dependency analysis
c) Critical pair analysis
d) Verification of preservation of call sequence

Question: What happens when a mutually exclusive refactoring has already been
applied?
Answer: b) It cannot be applied anymore
Options:
a) It can still be applied
b) It cannot be applied anymore
c) It becomes applicable to a different set of refactorings
d) It becomes conflicting with other refactorings

Question: What is the goal of preserving the software's behavior during


refactoring?
Answer: b) To preserve non-functional requirements
Options:
a) To change the input/output behavior of the program
b) To preserve non-functional requirements
c) To optimize resource usage
d) To apply sequential dependency analysis
Question: Which of the following is NOT a non-functional requirement that should be
preserved during refactoring?
Answer: d) Functional requirements
Options:
a) Temporal constraints
b) Resource constraints
c) Safety constraints
d) Functional requirements

Question: How can the preservation of the software's behavior be shown


pragmatically?
Answer: c) Testing
Options:
a) Critical pair analysis
b) Sequential dependency analysis
c) Testing
d) Verification of preservation of call sequence

Question: What is one way to ensure that the sequence(s) of method calls are
preserved in the refactored program?
Answer: d) Verification of preservation of call sequence
Options:
a) Critical pair analysis
b) Sequential dependency analysis
c) Testing
d) Verification of preservation of call sequence

Question: What are some examples of internal qualities of software?


Answer: b) Size, complexity, coupling, cohesion, testability
Options:
a) Performance, reusability, maintainability, extensibility
b) Size, complexity, coupling, cohesion, testability
c) Robustness, scalability, maintainability, extensibility
d) Coupling, cohesion, size, testability

Question: Which of the following statements is true about refactoring techniques?


Answer: c) Refactoring techniques are highly specialized, improving only a small
number of quality attributes.
Options:
a) Refactoring techniques improve all quality attributes simultaneously.
b) Refactoring techniques have no impact on quality attributes.
c) Refactoring techniques are highly specialized, improving only a small number of
quality attributes.
d) Refactoring techniques improve performance and maintainability only.

Question: How can the impacts of refactorings on external qualities be measured?


Answer: a) By evaluating the metrics before and after refactoring and comparing
them.
Options:
a) By evaluating the metrics before and after refactoring and comparing them.
b) By measuring the size, complexity, and coupling of the software.
c) By assessing the impact on internal qualities.
d) By selecting refactorings that improve quality attributes.

Question: What is the concept of a soft-goal graph used for?


Answer: a) Selecting refactorings that improve quality attributes.
Options:
a) Selecting refactorings that improve quality attributes.
b) Measuring the impacts of refactorings on internal qualities.
c) Verifying the assumptions made by programmers.
d) Viewing refactorings as applications of transformation rules.

Question: Which formalism is useful in viewing refactorings as applications of


transformation rules?
Answer: b) Graph transformation
Options:
a) Assertions
b) Graph transformation
c) Soft-goal graph
d) Metrics

Question: What are the three kinds of assertions mentioned in the passage?
Answer: a) Invariants, preconditions, and postconditions
Options:
a) Invariants, preconditions, and postconditions
b) Metrics, cohesion, and coupling
c) Graph transformation, software metrics, and refactoring
d) Programmers, assumptions, and Boolean expressions

Question: What is an invariant?


Answer: a) An assertion that evaluates to true wherever in the program it is
invoked
Options:
a) An assertion that evaluates to true wherever in the program it is invoked
b) A condition that must be satisfied before a computation is performed
c) A condition that must be satisfied after a computation is performed
d) A metric used to represent the strength of togetherness in the same module

Question: What is a precondition?


Answer: b) A condition that must be satisfied before a computation is performed
Options:
a) An assertion that evaluates to true wherever in the program it is invoked
b) A condition that must be satisfied before a computation is performed
c) A condition that must be satisfied after a computation is performed
d) A metric used to represent the strength of togetherness in the same module

Question: What is a postcondition?


Answer: c) A condition that must be satisfied after a computation is performed
Options:
a) An assertion that evaluates to true wherever in the program it is invoked
b) A condition that must be satisfied before a computation is performed
c) A condition that must be satisfied after a computation is performed
d) A metric used to represent the strength of togetherness in the same module

Question: What are the two metrics considered in software metrics?


Answer: b) Cohesion and coupling
Options:
a) Invariants and preconditions
b) Cohesion and coupling
c) Graph transformation and software metrics
d) Programmers and assumptions

Question: What is cohesion?


Answer: d) A metric used to represent the strength of togetherness in the same
module
Options:
a) An assertion that evaluates to true wherever in the program it is invoked
b) A condition that must be satisfied before a computation is performed
c) A condition that must be satisfied after a computation is performed
d) A metric used to represent the strength of togetherness in the same module

Question: What is coupling?


Answer: d) A metric used to represent the strength of dependency between separate
modules
Options:
a) An assertion that evaluates to true wherever in the program it is invoked
b) A condition that must be satisfied before a computation is performed
c) A condition that must be satisfied after a computation is performed
d) A metric used to represent the strength of dependency between separate modules

Question: What is the purpose of substituting an algorithm?


Answer: c) To replace one algorithm with another for clarity, performance, or
standardization reasons
Options:
a) To represent the strength of togetherness in the same module
b) To represent the strength of dependency between separate modules
c) To replace one algorithm with another for clarity, performance, or
standardization reasons
d) To measure the internal and external qualities of software

Question: What is the purpose of replacing parameters with methods?


Answer: d) To replace formal parameters with methods in a code segment
Options:
a) To represent the strength of togetherness in the same module
b) To represent the strength of dependency between separate modules
c) To replace one algorithm with another for clarity, performance, or
standardization reasons
d) To replace formal parameters with methods in a code segment

Question: What is the advantage of refactoring the code segment mentioned in the
passage?
Answer: a) It reduces the number of parameters passed to methods.
Options:
a) It reduces the number of parameters passed to methods.
b) It increases the efficiency of the code.
c) It improves the readability of the code.
d) It eliminates errors in the code.

Question: Which refactoring technique is illustrated in Figure 7.7(b)?


Answer: a) Push Down Method
Options:
a) Push Down Method
b) Parameterize Methods
c) Elimination-of-goto approach
d) Localization and information hiding approach

Question: What is the purpose of parameterizing methods?


Answer: d) To replace multiple methods performing the same computations on
different input data sets.
Options:
a) To reduce the number of parameters passed to methods.
b) To improve the efficiency of the code.
c) To eliminate errors in the code.
d) To replace multiple methods performing the same computations on different input
data sets.
Question: Which approach is NOT mentioned as a restructuring technique in the
passage?
Answer: e) Program slicing approach
Options:
a) Elimination-of-goto approach
b) Localization and information hiding approach
c) System sandwich approach
d) Clustering approach

Question: Which of the following factors can influence software structure?


Answer: d) All of the above
Options:
a) Code and documentation
b) Tools and programmers
c) Managers and policies
d) All of the above

Question: How can adherence to coding standards improve code quality?


Answer: d) All of the above
Options:
a) By enhancing code understanding
b) By improving code readability
c) By reducing code errors
d) All of the above

Question: Which of the following is an example of internal documentation?


Answer: d) In-line documentation
Options:
a) Requirements documents
b) Design documents
c) User manuals
d) In-line documentation

Question: Which of the following tools can help programmers better understand the
code?
Answer: d) All of the above
Options:
a) Tracing of source code
b) Animation of algorithms
c) Cross referencing of global variables
d) All of the above

Question: How can management influence software structure?


Answer: d) All of the above
Options:
a) By designing policies to adhere to standards
b) By tying performance reviews to adherence to standards
c) By allocating resources
d) All of the above

Question: Which control constructs are emphasized in structured programming?


Answer: a) for, while, until, and, if-then-else
Options:
a) for, while, until, and, if-then-else
b) if, else, switch, case
c) do, while, break, continue
d) try, catch, finally, throw

Question: What is localization in programming?


Answer: a) Collecting logically related computational resources in one physical
module
Options:
a) Collecting logically related computational resources in one physical module
b) Hiding the details of implementations of computational resources
c) Organizing global variables and functions into package-like groups
d) Organizing groups of functions into hierarchical package structures

Question: What is information hiding in programming?


Answer: b) Hiding the details of implementations of computational resources
Options:
a) Collecting logically related computational resources in one physical module
b) Hiding the details of implementations of computational resources
c) Organizing global variables and functions into package-like groups
d) Organizing groups of functions into hierarchical package structures

Question: What is the System Sandwich Approach used for?


Answer: b) Retaining software for its outputs while improving the interface and
data storage
Options:
a) Restructuring software with hope for improvement
b) Retaining software for its outputs while improving the interface and data
storage
c) Modularizing software for better design
d) Transforming flowchart programs into goto-less programs

Question: What is the Clustering Approach used for?


Answer: c) Modularizing software for better design
Options:
a) Restructuring software with hope for improvement
b) Retaining software for its outputs while improving the interface and data
storage
c) Modularizing software for better design
d) Transforming flowchart programs into goto-less programs

Question: What are the two ways to remodularize a program?


Answer: a) Top-down and bottom-up
Options:
a) Top-down and bottom-up
b) Left-right and up-down
c) Front-back and side-to-side
d) Inside-out and outside-in

Question: Which approach is used in system level remodularization?


Answer: a) Top-down
Options:
a) Top-down
b) Bottom-up
c) Left-right
d) Inside-out

Question: What is entity level remodularization?


Answer: b) Bottom-up approach
Options:
a) Top-down approach
b) Bottom-up approach
c) Left-right approach
d) Inside-out approach
Question: What is the concept of clustering in modularization?
Answer: b) Grouping entities into larger modules
Options:
a) Separating entities into smaller modules
b) Grouping entities into larger modules
c) Combining entities into a single module
d) Rearranging entities within a module

Question: What are the two factors taken into account while applying clustering?
Answer: a) Similarity metrics and clustering algorithm
Options:
a) Similarity metrics and clustering algorithm
b) Distance measures and association coefficients
c) Top-down and bottom-up approaches
d) System level and entity level remodularization

Question: Which distance measures can be used as similarity metrics?


Answer: a) Euclidean distance and Manhattan distance
Options:
a) Euclidean distance and Manhattan distance
b) Simple matching coefficient and Jaccard coefficient
c) Top-down and bottom-up approaches
d) System level and entity level remodularization

Question: What is the formula for the simple matching coefficient?


Answer: a) simple(x, y) = (a + d)/(a + b + c + d)
Options:
a) simple(x, y) = (a + d)/(a + b + c + d)
b) simple(x, y) = (a + b)/(a + b + c + d)
c) simple(x, y) = (a + c)/(a + b + c + d)
d) simple(x, y) = (b + c)/(a + b + c + d)

Question: What is the formula for calculating the Jaccard coefficient?


Answer: a) Jaccard(x, y) = a/(a + b + c)
Options:
a) Jaccard(x, y) = a/(a + b + c)
b) Jaccard(x, y) = a/(a + b)
c) Jaccard(x, y) = a/(a + b + c + d)
d) Jaccard(x, y) = a/(a + b + c + d + e)

Question: Which of the following is NOT a clustering algorithm technique?


Answer: d) Hierarchical algorithms
Options:
a) Graph theoretical algorithms
b) Construction algorithms
c) Optimization algorithms
d) Hierarchical algorithms

Question: What is the general structure of an agglomerative algorithm?


Answer: a) Begin with N clusters, compute similarities, merge similar clusters,
recompute similarities
Options:
a) Begin with N clusters, compute similarities, merge similar clusters, recompute
similarities
b) Begin with N clusters, compute similarities, merge dissimilar clusters,
recompute similarities
c) Begin with N clusters, compute differences, merge similar clusters, recompute
differences
d) Begin with N clusters, compute differences, merge dissimilar clusters, recompute
differences

Question: What does the dendogram represent in the context of clustering


algorithms?
Answer: c) The hierarchy of clusters
Options:
a) The similarities between clusters
b) The differences between clusters
c) The hierarchy of clusters
d) The number of entities in each cluster

Question: What are the two kinds of program slicing mentioned in the passage?
Answer: a) Forward slicing and backward slicing
Options:
a) Forward slicing and backward slicing
b) Cohesive slicing and decomposed slicing
c) Extracted slicing and restructuring slicing
d) Large slicing and small slicing

Question: What is the key idea in program slicing?


Answer: d) Identifying and extracting a portion of the code
Options:
a) Extracting cohesive subsets of statements
b) Decomposing large functions into smaller functions
c) Restructuring programs
d) Identifying and extracting a portion of the code

Question: What can be done to restructure programs with large functions?


Answer: b) Decompose into smaller functions using program slicing
Options:
a) Extract a cohesive subset of statements
b) Decompose into smaller functions using program slicing
c) Use formalisms for refactoring
d) Perform activities in a refactoring process

You might also like