100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

SQA Final Exam Prep UPDATED ACTUAL Exam Questions and CORRECT Answers

Rating
-
Sold
-
Pages
34
Grade
A+
Uploaded on
14-04-2025
Written in
2024/2025

SQA Final Exam Prep UPDATED ACTUAL Exam Questions and CORRECT Answers segment code - CORRECT ANSWER functionality - methods should perform one well-defined how does segment code increase testability? - CORRECT ANSWER maintainable, the methods don't depend on each other anymore DRY - CORRECT ANSWER - Don't Repeat Yourself DRYL why shouldn't we repeat ourselves? - CORRECT ANSWER maintain, more room for error - more reusable and - - Increased code to - Less timetable → have to do increased testing and when there is a defect, the bug fix has to b

Show more Read less
Institution
SQA
Course
SQA











Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
SQA
Course
SQA

Document information

Uploaded on
April 14, 2025
Number of pages
34
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

SQA Final Exam Prep UPDATED ACTUAL
Exam Questions and CORRECT Answers
segment code - CORRECT ANSWER - methods should perform one well-defined
functionality


how does segment code increase testability? - CORRECT ANSWER - more reusable and
maintainable, the methods don't depend on each other anymore


DRY - CORRECT ANSWER - Don't Repeat Yourself



DRYL why shouldn't we repeat ourselves? - CORRECT ANSWER - - Increased code to
maintain, more room for error
- Less timetable → have to do increased testing and when there is a defect, the bug fix has to be
replicated in all copies


DRY: what do i do with similar code? - CORRECT ANSWER - merge them!



functionally similar w/ diff types? - CORRECT ANSWER - polymorphism


DRY: which type of classes and methods should we make use of? - CORRECT
ANSWER - - generic ones
- parameterized types


use generic classes when - CORRECT ANSWER - there is no superclass



TUFs - CORRECT ANSWER - Test-Unfriendly Features



TUCs - CORRECT ANSWER - Test-Unfriendly Constructs

,no TUFs inside - CORRECT ANSWER - TUCs



TUFs are - CORRECT ANSWER - features that you want to fake using stubs (because
they take too long to set up to work correctly, or test, or testing them causes unwanted side-
effects


examples of TUFs - CORRECT ANSWER - - printing to console
- reading / writing from a database / to a filesystem
- access a diff program or system / the network


TUCs are - CORRECT ANSWER - methods that are hard to fake using stubbing or
overriding


stubbing def - CORRECT ANSWER - replacing a method in a mocked object using
Mockito


overriding def - CORRECT ANSWER - overriding a method in a "fake" class that
subclasses real class


TUCs examples - CORRECT ANSWER - - object constructors / destroctors
- private methods
- final methods


(the above four are impossible to override)


- static methods: impossible to override or to stub (since static methods are called on classes not
objects)

,so what does no TUFs inside TUCs mean? - CORRECT ANSWER - do not put code that
you want to fake (TUFs) inside methods that are hard to fake (TUCs)


make it easy to satisfy preconditions - CORRECT ANSWER - - depnednece on external
data is bad for testing


external data examples - CORRECT ANSWER - - val of global vars
- val extracted from a global data structure
- val read from a file / database
- basically any val that you did not pass in as args
- aka side-effects


pass in data using args (will need less external data) and for the remaining external data -
CORRECT ANSWER - - segregate hard-to-test code w/ side-effects into a small corner
- keep as many methods pure as possible


make it easy to reprouce - CORRECT ANSWER - - dependence on random data is bad for
testing
- random data = impossible to reproduce result


if you pass in Die d var, - CORRECT ANSWER - you can do


int dieRoll = d.roll();


(above is better)


than


int dieRoll = (new Die()).roll();

, with int dieRoll = d.roll(); you can - CORRECT ANSWER - mock Die and stub d.roll():



or you can just pass in dieRoll - CORRECT ANSWER - public Result playOverUnder(int
dieRoll) { if (dieRoll > 3) { return RESULT_OVER; } else { return RESULT_UNDER; } }


and don't have to mock or stub anything yay!


when we pass in instances of room into the house parameter, we can mock and stub more easily:


public class House {
private Room bedRoom;
private Room bathRoom;
public House(Room r1, Room r2) { bedRoom = r1;
bathRoom = r2;
}
public String toString() {
return bedRoom.toString() + " " + bathRoom.toString();

} } - CORRECT ANSWER - Room bedRoom = Mockito.mock(Room.class);
Room bathRoom = Mockito.mock(Room.class);
House house = new House(bedRoom, bathRoom);


dependency injection def - CORRECT ANSWER - passing a dependent object as arg
(instead of building it internally)


dependency injection features - CORRECT ANSWER - - makes testing easier by allowing
you to mock that object
- also what allowed us to mock the Die object for repproducibility
- has other software engineering benefits like decoupling the two classes

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
MGRADES Stanford University
View profile
Follow You need to be logged in order to follow users or courses
Sold
1067
Member since
1 year
Number of followers
102
Documents
68976
Last sold
9 hours ago
MGRADES (Stanford Top Brains)

Welcome to MGRADES Exams, practices and Study materials Just think of me as the plug you will refer to your friends Me and my team will always make sure you get the best value from the exams markets. I offer the best study and exam materials for a wide range of courses and units. Make your study sessions more efficient and effective. Dive in and discover all you need to excel in your academic journey!

3.8

168 reviews

5
73
4
30
3
43
2
8
1
14

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions