Final Flashcards

(366 cards)

1
Q

What is ad hoc development?

A

a one-time solution to a problem

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does CHAOS define success as?

A

a project being delivered on time, on budget, with all expected features

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the software crisis / No silver bullet

A

there is still no single development which by itself promises even one order-of-magnitude improvemnet with a decade in productivity, reliability, and simplicity

technology improves much faster than human’s development skills

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why do we write software?

A

to solve problems

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are Essential complexities?

A

difficulties that are intrinsic to developing software

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are accidental complexities?

A

difficulties that emerge due to circumstance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is External Software Quality?

A

refers to the quality of the software from the perspective of the stakeholders (anyone affected by the software, not just the user - i.e. anyone who holds stake in the usage of the software)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the External Quality Measures?

A

Functionality: does it do everything it is supposed to do?

Reliability: what is the capability of the software to maintain performance under certain conditions over a certain period of time?

Usability: how much effort is needed for a customer to use software?

Efficiency: when operating, what resources are used, and to what extent, by the software?

Portability: how able is the software to be transferred from one environment to another?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is Internal Software Quality?

A

the software quality from the perspective of the developers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the primary measure in internal software quality?

A

Maintainability: how maintainable it is from the developers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the Software Maintenance measures?

A

Analyzability: to what extent can the software construction be understood?

Changeability: the effort it requires to make changes to the software

Stability: the extent to which changes in one part of a software construction affect other parts

Reusability: the extent to which parts of the construction can be reused in other parts of the construction or in other software projects

Testability: the extent to which the software can be tested to find faults or defects in the software construction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the most important skill to achieving high internal software quality?

A

design

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is software entropy?

A

over time, software naturally becomes harder to modify - maintainability decreases

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is compiling?

A

turning human-readable source code into computer readable instructions

ex: waiting for someone to produce a translated transcript after a speech ended

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is interpreting?

A

fundamentally the same thing as compiling, only rather than turning the entire program into machine code first and then running second, when code is interpreted, we do both at the same time with the help of another program

ex: using headphones to listen to a live translator who is translating a speech as it is being made

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

what does the command
java example.Main
do?

A

runs the .class file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

what does the command
java -jar MyJar.jar
do?

A

runs a jar file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

what does the command
javac Student.java
do?

A

compiles a java file into a .class file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What does the JDK mean and do?

A

JDK: Java Development Kit

compiles code and produces a .class file, which is the bytecode that specifies the machine instructions

used for compiling

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What does JRE mean and do?

A

JRE: Java Runtime Environment

used to run Java programs

doesn’t interact with the JDK

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What does JVM mean and do?

A

acts like a separate computer

virtual machines have their own operating system, memory, processor, instruction set (machine language), etc. - each of the resources is effectively borrowed from the host (physical) machine

handles the direct interactions with the actual underlying physical

an interpreter, that interprets the code it is given at runtime, which is the class bytecode compiled by the JDK, and passed to the JVM by the JRE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What does JIT mean and do?

A

part of the JVM, specifically the part that can compile JVM bytecode instructions into machine code instructions for the underlying hardware

natively compiled machine code, machine code specifically compatible with the underlying physical hardware, is much more efficient than interpreted Java code

boosts optimization and efficiency

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Benefits of the JDK, JRE, JVM, JIT approach?

A

Portability: an application built and compiled on Windows will behave the same way on a Linux and Mac computer if they have a compatible JRE

Convenience
Distributability
Performance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

How do you create a package?

A

package edu.virginia.cs.dategetter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is the convention for naming packages?
reverse internet domain name cs.virginia.edu -> edu.virginia.cs
26
For command line arguments, what index is the first argument after the program name?
0
27
What is a version control system (VCS)?
a system for tracking changes to files in a project overtime
28
What is a distributed repository?
there is a remote repository, annd you work on your working copy, commit to your local repository, and then push to the remote repository
29
How does Git work?
it separates committing from pushing Git supports deciding which files you want to commit by use of a "staging area"
30
What does Git encourage?
pushing early and often
31
What does the command git add my_filename do?
adds any changes to the file to the repo tells git the next time you commit, add the changes of this file to the local repository
32
What does staged changes mean?
changes that are ready to be stored int the repo
33
What does the command git commit -m "message" do?
stores your current changes in your local repo require a meaningful commit message
34
What does the command git push do?
pushes all commits in your current branch since the last push to the remote repo send the state of your local repo to the remote repo can and will push multiple commits at the same time
35
What should you always do before you push?
pull
36
What does the command git pull do?
gets the most recent changes from the remote repo for your current branch only pulls for your current branch, not for every branch
37
What does the command git branch do?
shows all of the existing branches with an asterisk marking the branch you are currently on
38
What does the command git branch my_branch do?
adds a new branch - does not check the new branch out, it only creates one
39
What does the command git switch my_branch do?
switches to the branch specified it was created to split up the two functions that checkout does, so now there is switch and restore
40
What does the command git checkout my_branch do?
switches to the branch specified and restores an old version of the repo or particular file your working copy will be updated to the most recent commit in your local repo for that branch
41
What does the command git merge my_branch do?
merges specified branch into your current branch
42
What are the steps to merging?
commit your changes in your feature branch checkout main pull main checkout feature branch git merge main to merge main into your feature branch resolve any conflicts, commit and push checkout main git merge featureBranch
43
What is Gradle?
a build tool
44
What are the advantages to using Gradle?
greatly simplifies the process of downloading and using external libraries greatly simplifies the process of updating to new libraries greatly simplifies the process of building a Java project into a distributable Jar file
45
What will Grade do for you?
download all of the dependencies compile all the code run the existing test suite to make sure there are no known failures build the output jar file for you to use automatically optimizes the build processes once Gradle finishes building, you will find a .jar file in the build/libs folder inside of your project
46
What does the repository section tell Gradle?
that you want to download all references from the repo within the brackets
47
What does the dependencies section tell Gradle?
lists all the external libraries (and their versions) the program is using
48
What does the command gradle build do?
used to compile, test, and package your project tells Gradle to execute the build script, build.gradle uses the globally installed version of Gradle
49
What does Gradle's test command do?
tells gradle how to execute our tests
50
What does fat-jar mean?
a jar that contains not only my own code, but also all of the dependencies of my code
51
What does gradlew mean and do?
it is the Gradle wrapper, which ensures consistency by downloading and using the project-specific Gradle verion automatically installs gradle by running .\gradlew build
52
What is Verification?
asking the question "does our code meet our specification?" largely focused on an internal perspective did you build the thing right?
53
What is validation?
asking the question "is the customer satisfied?" primarily external is this waht the customer wanted, and does it solve their problem? did you build the right thing?
54
What is a defect?
an existing problem according to the software specification in the product that has not been discovered yet
55
What is a failure?
the inability of the software system to perform its function accordinf to the specification
56
What is a mistake?
a human error that produces something incorrect, such as a bug in the code or a misunderstood customer need
57
What is an error?
the difference between the current state and the correct state
58
What is the primary purpose of testing?
to find defects
59
When does a test pass?
when the expected and actual results match
60
When does a test fail?
when the expected and actual results do not match
61
What is a testing scenario?
a constructed case to test a code by executing it under controlled conditions
62
What does testing allow us to do?
test our hypothesis for whether or not a particular input will be defective
63
What is unit testing?
testing individual modules/functions we want to unit test all non-trivial public methods allows us to isolate the bug in the unit test to the method easy to automate, ensuring that running the existing test suite is a simple, automatic process
64
What is integration testing?
testing when modules are combined testing a class within a larger operation that combines the class with another class can typically be automated when testing integration between the user interface and the rest of the system, a real user interface may be generated during testing with an automatic entity "pressing" buttons
65
What is system testing?
involves testing the entire system as a whole from the user perspective typically involves following a script to use a specific feature or sets of features within an application if a defect is first found during system testing, this likely means there was a lack of thoroughness in the unit and integration testing
66
What is regression testing?
the idea of keeping all of your old tests around ensures we do not reintroduce old defects into our code, or break portions of our code that are already working gradle performs regression testing for us with gradlew test typically you run your entire suite of automated tests for our software system
67
What is alpha testing?
system testing carried out internally by the developing organization mock users are encouraged to experiment with the system
68
What is beta testing?
the goal is to find actual customers, or external people who would be likely to use the system after it releases users are closely monitored for how they use the software, and often their usage is logged extensively
69
What types of testing makes up acceptance testing
Alpha and beta - validation testing
70
What is continuous integration?
the practice in software development where when code is merged into or added a "protected branch", like main or development, the code is run against the existing testing suite to ensure known defects are not accepted into these protected branches
71
What does the tag @Test do?
used to identify a test method that is public and not static, returns void, and takes in no arguments
72
What does the tag @BeforeEach do?
tells JUnit to run the function before each test goes before all the test functions, under the global variables, right under class ensures that the state of the instance variables is always the same at the start of every test, no matter what tests we've run, or how many of them we have run
73
What does the assertion asserEquals do?
test passes if the expected output and the actual output match always put the expected value first and the actual value second
74
What assertEquals do we use with doubles and why?
assertEquals(double expected, double actual, double tolerance) there is imprecision you have to consider with floating point numbers
75
what does assertEquals use with Objects?
the .equals() method of the class of the expected to compare to actual
76
what does assertThrows do?
used when we expect the code we are using to throw an exception ex: assertThrows(IndexOutOfBoundsException.class, ()-> myList.get(0))
77
Why do we need automated testing?
onboarding refactoring evolution
78
How many times should you execute the function you are testing in a test?
once
79
Do you test the interface or the implementation?
interface
80
What is a sound test?
a test that correctly tests against the specification
81
What is a false positive?
a test fails, indicating a defect, but there is no defect with the code
82
what is a false negative?
a test passes, but it shouldn't, as there is an underlying defect that the test fails to find
83
What is an equivalence test?
"typical" test cases - test cases that show how the software behaves under normal, predictable conditions generally show the basic, most common operation of the function we are testing
84
What is a boundary test?
typically cases where there is something interesting or unique about the test case to separate it from an equivalence case
85
What is an exception test?
test cases that cannot be meaningfully executed correctly and should throw exceptions
86
What do robustness tests do?
test cases that are syntactically valid but semantically meaningless often times in these cases, it may be unclear how they are intended to behave, and it may be worth checking the specification itself
87
What is black-box testing?
the tester focuses on the functionality of the software without any knowledge of its internal workings or code only inputs and outputs are considered and the internal logic is unknown select what test cases to write based on its specifiaction
88
Are black-box exhaustive tests feasible?
almost never
89
Are black-box random testing useful?
no, can easily miss important test cases we should consider we want a systematic way to find a set of test scenarios that will include scenarios likely to generate defects
90
What is equivalence partitioning?
breaking up our equivalence cases into groups that largely behave the same write at least one test for each partition, but we do not necessarily need to write several tests for each partition
91
What is white-box testing?
the tester has full knowledge of the internal workings, structure, and code of the system the tester examines the code and creates test cases based on its logic, internal paths, and flows ensures out existing code is reasonably tested we select cases while considering the existing implementation of the code
92
What does white-box testing aim to do?
to achieve high code coverage
93
What is statement code coverage?
measure of what percentage of statements have been covered by our tests 100% statement coverage is a good minimum target for testing, as we don't want to rely on any lines of code we haven't tested at least once
94
What is branch code coverage?
we want to write tests such that we test the outcome of all conditional logic for every if statement, we test with the condition true and false for every loop, we test enters loop as well as skip loop if we are using a do-while loop, we want to test one pass and multiple passes
95
What is conditional code coverage?
for every boolean value, we want to evaluate the code if it's true or false we don't just want to consider if the whole statement is true or false, we want at least one test for every possible combination of true or false
96
What is path code covereage?
what percentage of possible paths through our code we have taken ex: enters if and while loop, enters if and skip while loop, skips if and enters while loop, etc. can explode in complexity
97
What do green and red mean in running with coverage?
green lines mean a line that has been executed by a passing test red lines mean the line has not been executed by a passing test
98
What is test-driven development?
write tests first that describe the specification first, and only implement the method after the code is written
99
What is a stub?
a method that is intentionally incomplete
100
What are the steps for TDD?
write a stub write a test - one test at a time and for each test write just enough code to make the last test pass implement the method commit test written and failing made 1st test pass commit test written and passing
101
What type of testing is TDD?
black-box
102
When designing a class, function, and interface, we should use exceptions for what?
pre-conditions and post-conditions
103
What should you never do as a way of handling control-flow?
throw exceptions with try-catch
104
When should you use try-catch?
should only be used when you can meaningfully handle an exception or when dealing with checked exceptions, turning a checked exception into an unchecked exception never catch an excpetion you can't handle
105
What are checked exceptions?
exceptions that Java forces you to either handle or throw exceptions that are checked at compile time usually represent conditions that a program can reasonably be expected to recover from ex: IOException, SQLException, ClassNotFoundException, FileNotFoundException
106
What are unchecked exceptions?
exceptions that occur at runtime and are not checked by the compiler (aka runtime exceptions) compiler does not require the developer to explicitly handle unchecked exceptions usually represent programming errors or issues that the program cannot be expected to recover from handling is optional ex: NullPointerException, ArrayIndexOutOfBoundsException, ArithmeticExpetion
107
How can you make your own exception?
public class InsufficientFundsException extends RuntimeException { public InsufficientFundsException(String message) { super(message); } }
108
How do you enable AssertionErrors to be thrown?
you must add -ea to the VM arguments (not command line arguments) in the run-configurations window
109
What does the assert keyword do?
if the asserted statement is false, then this results in an AssertionError, which is not the same as an exception, and cannot be caught with a try-catch or Exception or any sub-types should not be relied upon for deployed software replace assert statements with Exceptions when deploying
110
What is the relationship between readability and understandability?
readability is a necessary but insufficient condition for understandability i.e. our code cannot be understandable if it isn't readable; however, just because our code is readable does not mean it is understandable
111
What is code smells?
problems with the internal quality of software - i.e., problems with maintainability, analyzability, complexity, testability, etc.
112
Why not use long functions?
they are difficult to read and understand, difficult to use, and difficult to maintain functions are good at doing one thing and one thing only
113
Why not use large classes?
they lead to poor maintainability, reduced code readability, and increased complexity, making it difficult to understand, debug, and modify the code as the project evolves
114
Why not have a long parameter list?
can be confusing to read and remember what parameters to use
115
What is the ideal number of arguments for a function?
zero, then one, then two, and after that it should be avoided to use three and more if possible
116
Why not use boolean parameters?
it requires whoever is calling the function to know at least some information about how the function works - meaning understanding the function requires more knowledge replace with polymorphism
117
Why not use primitive obsessions?
it means modeling complex, unrelated data in one class directly with primitive data types instead, combine the primitives relevant to specific behaviors together in different classes
118
Why not use message chains?
They are unreadable
119
What is refactoring?
the process of making changes to the code to improve the internal software quality, without making any changes to the functionality of the software
120
Refactoring: renaming identifiers
most common refactoring never use use-and-replace to rename variables
121
What does code should read like "well-written prose" mean and how do we achieve this?
the code shouldn't require pausing to try to understand a simple idea ask "is this the best name?"
122
Refactoring: extract constants
we can extract raw values into named constant values to improve code readability
123
Refactoring: abstract conditional logic
refactor by encapsulating the if-statements boolean logic to a separate function
124
Refactoring: invert boolean
If it is not summer, charge the winter price. Otherwise, charge the summer price. if it is summer, charge the summer price. Otherwise, charge the winter price. second is easier to read
125
Refactoring: replace ErrorCode with exception
error codes (return values pre-selected to indicate an error) are generally a bad idea use an exception so your client has to handle incorrect usage of the function
126
Refactoring: replace null with Optional
instead of returning null, return Optional.empty() you are not just letting the client decide what to do if the function cannot return a meaningful value, you are syntactically forcing the client to decide what to do
127
Refactoring: extract method
Break up big methods Well-written prose - Defines an understandable, high-level procedure, and then each function handles the low-level details of how that behavior is implemented
128
Refactoring: extract class
Single Responsibility Principle - A class should have only one reason to change Want to break functions up into classes that handle different behavior Encapsulation - The entire goal of classes is to hide implementation details If our file structure changes, or we need to use a completely different file format, we necessarily have to change our implementation
129
Refactoring: preserve whole object
work with data-type of Object if class interface or implementation changes, this code can remain unchanged
130
What does DRY stand for and mean?
Don't Repeat Yourself avoid duplication of code, logic, or data the goal is to make sure that every piece of knowledge in the system has a single, unambiguous representation reduces redundancy, making the code easier to maintain, more efficient, and less error-prone
131
What does WET stand for and mean?
Write Everything Twice suggests code duplication is sometimes acceptable, often when reuse would overcomplicate the code or reduce clarity allows flexibility and simplicity, accepting some code duplication if it enhances readability or maintainability
132
What are comments?
provides internal explanations to help developers understand specific lines or sections of code generally informal explains how a particular piece of code works
133
What is documentation?
provides external explanations about the overall functionality, usage, or API of a system or software target audience is end users, developers using the software, or other stakeholders who need to understand how to use the software describes the high-level functionality, public APIs, usage instructions, and often the overall system explains what the software does and how to use it
134
What is technical debt?
you aren't done when your code works - you are done when you've cleaned up
135
Functions can be ...
treated as variables, passed as arguments, and returned by functions
136
What are lambda functions?
an unnamed function rather than naming a function, we create a function when it's needed on the fly at runtime
137
What is the general structure of a lambda statement?
(parameters) -> {code block} OR (parameters) -> expression
138
What is Comparator's method?
public int compare(E e1, E e2)
139
What is Comparator's Java Stream?
sorted() and sort()
140
What is Comparator used for?
used in sorting lists
141
What is Consumer's method?
public void accept(E e)
142
What is Consumer's Java Stream?
forEach()
143
What is Consumer used for?
to take in some value and doing something with it, but don't return anything
144
What is Predicate's method?
public boolean test(E e)
145
What is Predicate's Java Stream?
filter()
146
What is Predicate used for?
used for checking if a value meets some condition
147
What is Function's method?
public R apply(T)
148
What is Function's Java Stream?
map()
149
What is Function used for?
to pass some instance of T as an argument, return an instance of R
150
What is Executable's method?
public void execute()
151
What is Executable's Java Stream?
assertThrows()
152
What is Executable used for?
used in assertThrows, dynamicTest, and assumingThat
153
What is a Java Stream?
a stream is like an assembly line - we take in some collection of information on one side, pass it through a number of steps, and then at the end we have some useful information allows us to utilize functional programming to simplify queries and operation on collections of data
154
What can we make streams from?
List, Set, Map (via entrySet())
155
What is stream()?
Stream starts with a collection like a List or a Set from there we make a stream using: myCollectionVariable.stream() this gives us a Stream that we can now perform zero or more intermediate operations on and one terminal operation on, which converts the stream back into something useful like a List or gives us summary information
156
What is parallelStream()?
we can replace stream() with parallelStream() to take advantage of automated multithreading
157
What is the cost of multithreading?
may do operations in an unpredictable order workaround to use forEachOrderedI() instead of forEach() managing threads creates a lot of overhead complexity parallelStream will typically only benefit you with very large data sources
158
What is the output for sorted(Comparator comparator)?
Stream sorted by the comparator
159
What is an example of sorted?
.sorted((a,b) -> a.size() - b.size())
160
What does sorted do?
we may want to sort during our intermediate steps (such as when we get the five smallest states) this method lets us define a sorting methodology functionally
161
What is the output for map(Function f)?
Stream
162
What is an example for map?
.map(x -> x.size())
163
What does map do?
it is used to convert our data from one thing to another
164
What is the output for filter(Predicate p)?
Stream with only elements that return true for our Predicate function; elements that return false are removed from the stream
165
What is an example for filter?
.filter(x -> x.getPopulation > 100000)
166
What does filter do?
we may want to "filter out" certain values from our stream, or only keep certain other values
167
What is the output for limit(long n)?
Stream, but only the first n elements
168
What is an example of limit?
.limit(10)
169
What is limit used for?
to limit to a certain number of elements in general, if we want to use limit, we only use it after sorted
170
What is the output for peek(Consumer e)?
Stream with no elements removed or altered
171
What is an example of peek?
.peek(System.out::println)
172
What is peek used for?
similar to forEach, this method performs some functinos on every element in the Stream; however, forEach is a terminal operation, while peek is an intermediate operation
173
What is the output for distinct()?
Stream with all duplicate elements removed
174
What is an example of distinct()?
.distinct()
175
What does distinct do?
uses E's .equals() method to remove any duplicate elements from our Stream
176
What is the output for forEach(Consumer e)?
void - forEach cannot be used to return anything directly
177
What is an example of forEach?
.peek(item -> summaryList.add(item))
178
What does forEach do?
used for performing some action with items left in the Stream at the end of the intermediate operations
179
What is the output for count()?
long - the number of items left in the Stream
180
What is the output for .toList()?
a List that is unmodifiable and immutable which matches the state of the Stream at the end of the Stream chain of operations
181
What is the output for reduce(T identity, BinaryOperator accumulator)
T
182
What does reduce do?
allows you to define a way to reduce a stream of multiple objects to one value first argument in our function is our summary value the second argument is each item in our list
183
What is the difference between a good design and a bad design?
A good software design is modular, maintainable, scalable, flexible, and simple, with a clear structure that facilitates testing and future changes A bad software design is often rigid, difficult to maintain, and prone to errors, with tightly coupled components, poor scalability, and convoluted logic
184
What does modularity mean?
break up our big problem into little problems that are easier to solve, and each unit is potentially reusable we call each individual unit of code a module
185
What is decomposition?
break up our software into smaller parts
186
We want modules that are...
highly cohesive and loosely coupled
187
What is the single responsibility principle?
A class (or module, function, etc.) should have only one reason to change, meaning it should have only one responsibility
188
What is functional independence?
each function should be functionally independent each module can perform its own purpose with minimal interactions with the rest of the system when interactions are necessary, they are simple, with little information necessary as possible to perform the transaction
189
What is coupling?
The measure of how interdependent two modules are
190
What is abstraction?
the process of hiding all unnecessary details and exposing only required details typically, it means that we hide implementation details behind a minimal interface we use our modules to encapsulate some behavior or data
191
What does it mean to design for the interface, not the implementation?
so long as the interface is maintained, changes to the implementation will not force changes to other modules
192
What is information hiding?
mechanism by which we create a limited interface to achieve abstraction we want to intentionally force clients to only use the interface this ensures that our module is only used correctly, as any incorrect usage is prevented syntactically we want out module to be usable with as low a barrier of understanding as possible
193
What is cohesiveness?
refers to how much each class adheres to one specific purpose - how much each part of a module is interdependent upon other parts of the module
194
What does highly cohesive mean?
refers to the degree to which the elements within a module, class, or component of a software system are closely related and focused on a single, well-defined task means that methods, functions, and responsibilities inside a class or module all contribute to performing a unified and specific function
195
What does loosely coupled mean?
refers to the degree of dependency between components, classes, or modules in a software system in a loosely coupled system, components have minimal dependencies on each other, meaning changes in one component are less likely to affect other components each module or class interacts with others through well-defined interfaces, rather than relying on direct knowledge of their inner workings or implementation details
196
What is coincidental cohesion?
worst - very loose cohesion, avoid at all costs elements are combined into a module by effectively coincidence a module contains elements that are not clearly related to one another
197
What is logical cohesion?
worst - very loose cohesion, avoid at all costs elements are grouped into a module because they described the same general activity, or have similar interfaces, or are otherwise categorized the same
198
What is temporal cohesion?
worst - very loose cohesion, avoid at all costs where items are grouped because they occur at or around the same time (but not in any particular sequence), but are otherwise unrelated we are grouping things whose implementations likely do not interact with each other
199
What is procedural cohesion?
decent - acceptable, but often could be better supporting unrelated activities in which control passes from one activity to the next, ensuring they execute in a specific order
200
What is communicational cohesion?
decent - acceptable elements are grouped together in a module simply because they perform actions on the same data for either input or output behaviors are not tightly related to one another
201
What is sequential cohesion?
best - generally considered very cohesive, second only to funcitonal we can group modules into individual "procedures" allows us to easily replace/swap steps for specific use cases elements are grouped because they describe a single procedure stipulates that one element's output are directly used by the next element's inputs - elements must occur in sequence
202
What is functional cohesion?
best describes a single well-supported function, i.e., a something that only does one thing module only has one behavior this is very maintainable, because so long as the interface remains the same, the implementation can change without propogating change to any other module cannot have any "state", so no mutable variables - the function simply takes in input and returns output - no side effects
203
What is content coupling?
occurs when one class modifies the inner state of a class it depends on directly instead of using the public interface
204
What is common coupling?
when they have read and write access to the same global data static values should generally be limited to constants this can be resolved by creating one module that handles database interactions with other modules that need to interact with
205
What is control coupling?
when one module passes some kind of flag (typically a boolean) to another module which is used in control flow
206
What is stamp coupling?
exists when a module passes a data structure to another module, when the entire data structure is not needed if you find your function is throwing away a significant part of the input data, consider if it might be more tightly defined
207
What is data coupling?
the gold standard - all communication between modules is done via passing the minimum amount of data as arguments and returning exactly the data needed this ensures that any action taken by the "called" method, with the exception the data it returns, will not affect the execution of the calling method additionally, the calling method only needs to understand the intent of the parameters at a functional interface level this allows us to develop both modules independently, without worrying about behavior of one module complicating the behavior of another
208
What is dependency?
a class depends on another class when it uses methods or functions from that class
209
What is aggregation?
a relationship between two classes in object-oriented programming where one class contains or owns objects of another class, but both can exist independently of each other it represents a "has-a" relationship, meaning one class (the whole) has objects of another class (the parts), but the parts can exist on their own without the whole
210
What does "A aggregates B" mean?
refers to an instance of class, A, "has" one or more instances of class B
211
What is composition?
"A is composed of B" refers to a relationship where one or more instances of B are intrinsically part of another class, A in general, B does not such that they often cannot be meaningfully separateed the composing class brings together these items, and the items by themselves don't have a meaning outside of their attachment to the composing class subset of aggregation relationships
212
What is bidirectional association?
two classes are connected in such a way that interaction may be needed both ways this can be expressed as mutual aggregation in general, the semantics generally refer to a relatively symmetrical relationship in the sense that neither class possesses the other, but they do reference each other
213
What is realization?
a class realizes an interface or abstract by implementing/extending it "is-a" relationship on class (the parent) describes the behaviors, and the other (the child) implements the behavior tighter coupling type of generalization
214
What is generalization?
"is-a" a parent describes a general behavior, and a child describes a specific behavior, or specialization of the parent
215
Why do we often say "Prefer Composition/Aggregation over Inheritance"?
Introducing abstraction to support polymorphism is valuable when it reduces usage complexity by more than it increases coupling and implementation complexity In short, before considering adding functions to a class via inheritance, consider just adding the class to your functions via aggregation Creates a tight coupling
216
What is the benefit of polymorphism?
Polymorphism is a key concept in object-oriented programming (OOP) that allows objects of different classes to be treated as instances of the same class through a common interface Polymorphism enables the ability to "call the same method" on different types of objects and have each object respond in its own way
217
What is dependency inversion?
Entities should only depend on abstractions, not on concretions It suggests that high-level modules should not depend on low-level modules; both should depend on abstractions (such as interfaces or abstract classes) Abstractions should not depend on details, but details should depend on abstractions
218
What does architecture mean with software?
generally refers to the design of our overall project think of components
219
What is a component?
major sub-systems in our software system groups of modules that handle the same major feature or feature-set independent programs data sources external internet connections, such as servers, browsers, etc.
220
What types of designs are the hardest to change?
architectural design
221
What are creational design patterns?
any design that either hides or limits the usage of constructors provide object creation and instantiation mechanisms that increase flexibility and re-use of existing code
222
What are the types of creational design patterns?
singleton factory abstract factory
223
What are structural design patterns?
have to do with de-coupling an abstraction from its implementation typically assemble objects and classes into larger structures by combining multiple classes or bringing together existing objects
224
What are types of structural design patterns?
adapter facade proxy bridge decorator
225
What are behavioral design patterns?
take care of communication between objects and the assignment of responsibilities between them, by manifesting flexible behavior
226
What are the types of behavioral design patterns?
iterator observer command strategy
227
What is a pattern?
a known strategy to addressing design concerns inherently abstract
228
What is a framework?
existing code/structure that you use to build your own programs
229
What is layered architecture?
each component interacts with the component(s) in the layer above it and the layer below it a layer provides services to the layer above, and sends requests to the layers below
230
What is the difference between client-side and server-side?
in a client-server architecture, we have effectively two separate components communicating with one another client application runs on their own device and communicates with a centralized server over the internet a separately deployed application will run on the remote server that will receive requests from the client-side, likely interact with some database, and then send information back over the internet to your phone
231
What are some challenges in client-server?
handling monitoring server load synchronization issues
232
What are the three layers in three-layer architecture?
Presentation Business Logic Data
233
What is the presentation layer?
how users/other services see and interact with our system can range from a GUI based web-application, to an API that outputs JSON data based on arguments entered through a URL, and everything between
234
What is the business logic layer?
provides a set of services that implement the features of the application enforcing real world business rules on our system, such as course pre-reqs, enrollment limits, etc.
235
What is the data layer?
interactions with data sources might be, for example, a database and code that handles storing and retrieving data as our website is used
236
What does MVC stand for?
Model-View-Controller
237
What is the difference between MVC and Three-Layer?
MVC is a subset of the Three-Layer architecture the motivation is the same idea, separate the visual representation of the user-interface from the use cases of the software, which is also separated from the data management of the application
238
What does Model mean in MVC?
the state of the system, including the data representations of that state
239
What does View mean in MVC?
the thing the user sees and interacts with
240
What does Controller mean in MVC?
receives user gestures from the view, and then reacts accordingly to update the "state" of the Model, retrieve information from the Model, and then update the View
241
What is Integration Testing?
the act of combining different software modules together we want to ensure two or more modules are communicating correctly
242
How is integration testing different from unit and system testing?
we first check each module works independently (unit testing), and then we need to ensure that the modules integrate correctly (integration testing), and then we need to ensure the entire system is working together (system testing)
243
What are the strategies of integration testing?
Big-Bang Top-Down Bottom-Up Sandwich
244
What is Big-Bang integration testing?
"no plan" integration we haphazardly integrate modules in whatever order we feel like at the time it is not scalable and can lead to conflicting strategies by the developers on the team
245
What is Top-Down integration testing?
integrate starting with the class on which nothing depends integrate classes that are depended upon by your integrated classes use stubs to test our integration since there are unimplemented dependencies use mocking with mockito since it allows us to test even when we have unintegrated, or even unimplemented dependencies
246
What are the advantages and disadvantages to Top-Down integration testing?
advantages: lets us integrate our system in the same way we want to design our system - from the high-level to the low-level we are able to make decisions about the high-level classes early before we integrate low-level classes, allowing us to ensure our high-level design is effective and flexible disadvantages: can be difficult in testing user-interfaces directly mocking user input can be difficult Lower-level modules are often integrated last, and are typically tested in fewer integration tests as a result (as compared to Bottom-Up) since in most integration tests, the lower levels are either absent or mocked
247
What is Bottom-Up integration testing?
as we develop modules, we integrate them in order from the low-level to the high-level integrate starting with the class that depends on nothing integrate each class after all of its dependencies have been integrated
248
What are the advantages/disadvantages to Top-Down?
advantages: can use the strategy of integrating as we build - we can test our unit and integration at the same time As we integrate, if a fault emerges, it becomes easier to locate that fault, as it is likely related to our most recent integration As we integrate higher-level modules, we can design our tests to go as “deep” as we need to go to fully test the feature disadvantages: The most critical aspects of our program (high-level logic) get tested last by this approach You can end up with the higher-level classes having to change to accommodate lower-level classes, which we want to avoid High-level modules tend to be the most critical for facilitating good software design and ensure good modularity, functional independence, and abstraction Can make prototyping difficult, as it is much easier to show a useful prototype to customers with a real interface, but fake data, than the other way around
249
What is Sandwich integration testing?
combines bottom-up and top-down integration testing we start with a target layer somewhere in the middle and then integrate both up and down, in the order we choose, testing as we go
250
What are the advantages/disadvantages to Sandwich?
advantages: It can be very valuable in larger applications, as it allows for more scalability as new modules and sub-projects are integrated We are often able to isolate the User Interface (which is typically the most volatile part of our application), while still being able to test by decomposing features into individual modules disadvantages: This approach struggles where there are a large number of interdependencies between modules, as isolate a “target layer” to integrate up and down from becomes difficult
251
What are stubs?
an object that replaces an object with another object of the same interface typically hardcoded to return specific values
252
What are drivers?
a software component that lets the operating system and a sevice communicate a piece of code that acts as a bridge between the operating system and a specific hardware device, allowing the system to communicate with and utilize the device's functionalities
253
What are Mocks?
We create an object like a stub object to remove the need for external dependencies; however, we still want to monitor to verify that the class interacts with external dependencies as expected
254
In Mockito, when do we use verify?
Verify is used to verify that a particular function, with a particular argument, was called on our mockList object Verify should only be used on methods that can produce side effects as post-conditions
255
What does data persistence mean?
the idea that we want some information (typically data) in our programs to be saved, or persisted, from one run to the next
256
What means do we have to achieve data persistence?
use files and databases
257
What are the benefits to JSON?
structured, but flexible nesting of data human readability plays nicely with objects
258
What is a JSONObject?
contained in brackets {} functions like a HashMap in terms of usage, but values can be different types the key must always be a String datatype, while the value can be a String, number, boolean, JSONObject, or JSONArray
259
What is a JSONArray?
contained in square braces [] can access values, but instead of using String key like a JSONObject, since this is an ordered array, we use int index
260
What is a database?
a place to persist data
261
What is a Relational Database?
database is stored in one or more tables, often with constraints on the contents of the tables to store data integrity data is explicitly formatted where all data in a single table matches the format, and tables are related to one another through foreign keys
262
What is a table?
a specific that divides data into multiple attributes, and store multiple units of data as records should generally be named as plural nouns
263
What is a record?
each row in a table
264
What is an attribute?
each column in a table
265
What is a primary key?
can be used to identify a single record all PKs must be unique and not null
266
What is a foreign key?
a reference from a record in one table to a record in, typically, another table enforces data integrity by default, SQLite are not enforced, enforce with PRAGMA foreign_keys=ON;
267
What does ON DELETE CASCADE mean?
means if the referenced record in the other table is deleted, then cascade that deletion to all records with that ID in this table
268
What is a unique constraint?
each record must have a different attribute than every other record
269
What is a not null constraint?
no record may be blank in that column
270
What is a check constraint?
a check constraint includes a boolean expression
271
What does a default constraint do?
if we leave this column null when inserting data, that null value is replaced by the default value if we insert a value, the default is ignored
272
How is SQLite distinct from MySQL, PostgreSQL, etc.?
SQLite is lightweight and easy to start up - it's an embedded database, meaning the database is tightly integrated with the application using the database
273
What are some features SQLite is missing?
database permissions no user access control lack of datatpye enforcement nullable primary key foreign keys are off by default text literals != integer literals lack of boolean and DateTime
274
What are the advantages of SQLite?
invoked directly, with no need for a separate server application running locally the database is stored as literal files on the disk, usually with the extension .sqlite3 or .db great for local storage of data portable across platforms and operating systems, making data easy to share
275
What are the disadvantages of SQLite?
ill-suited for high-traffic client-server situations worse when there are a large degree of data writes can function as a database for a website on the server side, but not as good as PostgreSQL ill-suited for very large datasets
276
What does CREATE do?
creates a new, empty table with no data
277
What does INSERT do?
add data to a table
278
What does SELECT do?
retrieve data from a table
279
What does UPDATE do?
edit data that is already in a table
280
What does DELETE do?
remove records from a table
281
What does DROP do?
delete a table completely (removes all data AND deletes the structure)
282
While listing the column names in the first line is technically optional, why should you always do it when inserting?
You’re assuming the column name order, which could change; columns can also be removed, rename, etc. We should think of a record like an entry in a Map, where the key is the primary key, and the value is a mapping of column names to values (not unlike JSON) The scheme of our table may change in a way that we think this insert is valid, but now we’re inserting something into something else because of changes
283
What does upsert mean?
insert or update - insert new data or change existing data
284
While the where clause is technically optional for update and delete, in practice you will almost always use it. Why?
otherwise, it will update/delete all the records from that table
285
What does BEGIN TRANSACTION do?
sets the starting point of a transaction; changes to the database after this statement are "temporary," and can either be committed or rolledback
286
What does COMMIT do?
make all changes since the last BEGIN TRANSACTION permanent
287
What does ROLLBACK do?
undo all changes since the last BEGIN TRANSACTION (meaning any data added, changed, or deleted is undone)
288
Why should you use transaction, commit, and rollback whenever using an insert, update, or delete query?
SQLite has auto-commits turned on - any commits are permanent by default, only disabled when you begin a transaction any changes to the underlying data are immediately made permanent
289
What is First Normal Form?
each table cell contains only a single value each record needs to be unique (no repeat rows)
290
What is Second Normal Form?
First Normal Form, as well as single column primary keys
291
What is JDBC used for?
connecting to and using a SQLite database in Java it is a built in Java library for connecting to databases and running queries
292
What is a Connection Object used for in JDBC?
the connection object is used to send queries to our database and get results from our database
293
How do you create the Connection Object with JDBC?
jdbc:sqlite:[database_file_path] Connection con = DriverManager.getConnection("jdbc:sqlite:[database_file_path]");
294
How do you close a Connection?
connection.close()
295
How do you turn off auto commit with Connection in JDBC?
connection.setAutoCommit(false);
296
When do you use statement.executeQuery()?
returns a ResultSet used for SELECT queries
297
When do you use statement.executeUpdate()?
returns an int of the number of rows affected used for INSERT queries
298
What does ORM stand for?
Object Relational Model
299
What is the purpose of an ORM?
automatically go from Object to Record in a database and back
300
What constructor must exist in an entity class?
a zero-argument constructor
301
What methods must exist in an entity class?
getters and setters for all fields that you wish to have as TableColumns
302
What are design patterns?
a toolkit of solutions to general problems that arise in software design
303
What are the advantages of design patterns?
can be applied to improve software quality
304
What are some disadvantages to design patterns?
it can introduce unnecessary complexity, there is potential for misuse or overuse, there is a learning curve
305
When should we use design patterns?
design patterns should never be forced or overused; you should only add features to your code when required
306
What is the singleton creational design pattern?
used when you want only one instance of an object to exist at any given time this instance can be shared amongst different modules, without the modules being aware of each other
307
What are some examples to singleton creational design pattern?
logging client side UI settings service locators
308
What is single factory creational design pattern?
factories are useful for combining existing pieces of code into one class they provide an interface for creating objects in a superclass, allowing subclasses to alter the type of object that will be created
309
What is abstract factory creational design pattern?
let you produce families of related object without specifying concrete classes used when you have multiple factories that produce the same abstract goods but have their own concretions of the product at runtime, the concrete factory is picked based on what you want to use
310
What is builder creational design pattern?
introduced to solve some of the problems with factory and abstract factory design patterns when the Object contains a lot of attributes
311
What is adapter structural design pattern?
adapters adapt an existing class or object to a new interface without changing the underlying class they are useful to update interfaces while minimizing size effects/propagation of changes this allows objects with incompatible interfaces to collaborate, by converting the interface of one object to something another object can understand
312
What is decorator structural design pattern?
decorators are amazing for attaching new behaviors to objects this is done by placing objects inside special wrapper objects that contain any new behaviors all wrappers and base objects must follow a common interface
313
What is proxy structural design pattern?
when facing an issue where you have a massive object consuming resources, but the object is only needed from time to time, you should probably use a proxy design pattern proxy patterns create a proxy class with the same interface as an original service object
314
What is facade structural design pattern?
general good design practice to solve issues of temporal coupling and complex dependencies, a facade is usually a great solution a facade solves these issues by providing a simplified interface to a library, framework, or any other complex set of classes however, developers should be careful to not turn a facade into a god object or class
315
What is iterator behavioral design pattern?
iterators allow you to visit all elements of collections one at a time the key advantage of iterators is functional independence and information hiding: someone does not have to know how a collection is structured, does not have to worry about how the iterator works, and they can trust that the iterator will allow them to visit every element
316
What is strategy behavioral design pattern?
sometimes, we want to specify a particular part of an algorithm in a given context at runtime the strategy design pattern uses a strategy interface and concrete strategy classes the concrete strategy is passed as an instance to the method that implements the rest of the algorithm at runtime
317
What is observer behavioral design pattern?
when you have objects that need to notify a varying list of other objects that some event has occurred, an observer may be the solution an observer calls for an observer interface and a concrete observer that implements it, while looking at another concrete class
318
What is a JavaFX Stage?
a top-level container in Java, and will generally be displayed as a window
319
What is a JavaFX Scene?
a particular arrangement of a Stage organized as a tree of Nodes
320
What is a JavaFX Node?
an abstract class for every "thing" (such as a button, text field, etc.) that is in our scene nodes in a given scene are organized in a tree, where the root node must be a Pane
321
What is a JavaFX Pane?
a container a place to put nodes, such as Buttons, TextAreas, other panes, etc. each scene must have exactly one root pane
322
What is a JavaFX FlowPane?
a very simple way to use layout where Nodes are simply added in-order, left-to-right, top-to-bottom as space permits however, your results will have effectively no formatting, so you're unlikely to get anything aesthetically pleasing
323
What is a JavaFX Layout?
describes how items (widgets or other panes) inside a Pane are arranged describe a particular type of Pane cannot be changed
324
What are JavaFx Controls?
a widget used to allow for display and/or user interaction
325
What are JavaFX Labels?
displays some text to the user, but does not support user interaction useful for labels, status messages, etc.q
326
What are JavaFX Buttons?
a clickable button that performs some action when clicked by the user
327
What are JavaFX TextFields?
boxes for users to enter text TextField provides only one line, while a TextArea provides multiple lines
328
What is a FXML file?
an XML-based user interface markup language created by Oracle Corporation for defining the user interface of a JavaFX application
329
What is a Controller class?
a class that directly handles interactions with our user interface scene in general, every .fxml scene will have one Controller
330
What is fx:id?
it is attached to a Label control, meaning give this Label object the variable name specified we can then add that variable to our Controller class
331
What is fx:controller?
connects our FXML to this controller add this to the root pane of our scene
332
What is onAction="#handleAction"?
this tells JavaFX that whenever this button is clicked, it should call this method named handleAction in our controller class
333
What part of JavaFX is each of the MVC parts?
Model - business logic and data layer, application class View - .fxml file Controller - controller class
334
What are good design practices for your controller classes?
a controller should handle actions from the view, update the view, and call functions in the model when needed no meaningful or complicated business logic should be handled in the FXML Controller class since Controller is already tightly coupled with the UI
335
What is premature optimization?
refers to devoting a significant amount of time to tasks that you might not truly require
336
Premature optimization is...
the root of all evil
337
Why is premature optimization so bad?
misplaced priorities overemphasis on micro-optimizations changing requirements lack of profiling data complexity and maintainability
338
What is a Critical Section? Why do we care about this with respect to optimization?
Critical section - in a single module, class, subroutine, or overall piece of software, is the section of code that costs the most time overall the more a piece of code is executed, the more critical it is it can take a long time to run
339
What does a Profiler do?
highlights the lines of code that took the longest good to disable any user input when running a profiler, since any time the program is "waiting" on user input will count as time spent on the line of code where the input is collected
340
What is Lazy Evaluation optimization pattern?
we only evaluate something when we need to we avoid invoking costly functions until we need to it is a good idea to avoid eager evaluation, as it is at best as good as lazy evaluation, we avoid invoking costly functions until we need to
341
What is Lazy Initialization optimization pattern?
we avoid creating new objects until we need to beneficial if we frequently will create or use a class, but not need or interact with its aggregations
342
What is memoization?
the idea of storing this response to make future requests faster we trade memory space now for improved time performance later
343
When do you invalidate a stored memo?
when the memo is tied to a something that is unstable, like something that is very likely to change moment to moment, or changes are unpredictable and hard to monitor
344
What is short-circuiting in optimization?
where an expression is stopped being evaluated as soon as its outcome is determined && is a short-circuited operation with boolean expressions
345
What is the frontend?
the client-side the screen the user sees any local storage
346
What is backend?
the server-side remote databases remote servers
347
What is monolith?
entire application on one code-base that can be deployed to one or more servers - each server has the same application
348
What are the advantages of monolith?
scaling entire application is easy, just buy more servers and load the same application on each no redirection cost which can occur with microservers easier debugging - if you don't have to figure out which service caused a cascading failure reduced monitoring overhead
349
What are the disadvantages of monolith?
cannot scale individual services, since all services are on the same server reliability - an error that causes a crash on one server can cause a crash on all of them services can end up tightly-coupled, making them harder to separate/change, overtime, especially with poor developer practices
350
What is Microservice?
rather than implement your entire backend as a single service, have individual services hosted on their own server(s)
351
What are the advantages to microservice?
Because each service is a smaller code base, and may have its own database, less “accidental coupling” can be injected, and development is easier (less code to read at any one time) Server requests as function calls Indirection costs (a microservice calls a microservice calls a …) Scaling - if particular services have a high demand, they can be scaled up individually to more servers
352
What are the disadvantages to microservices?
Monitoring - you need to be able to see which services are functional and which aren’t Debugging - each server may have its own logs; if several services go down at nearly the same time, identifying the source can be hard Infrastructure costs - each service can have its own costs
353
What HTTP is sent by the client?
HTTPRequests
354
What HTTP is received by the client?
HTTPResponse
355
What does the HTTPRequest Operation GET do?
retrieve some information generally no message body
356
What does the HTTPRequest Operation POST do?
store new information on the server input data typically included in a request body as a hash-map
357
What does the HTTPRequest Operation PUT do?
similar to POST, but for changing existing information
358
What does the HTTPRequest Operation DELETE do?
remove information
359
What do HTTP 2xx codes do?
indicates a successful HTTP response
360
What does the HTTP code 200 do?
successful HTTP response with results in the response body
361
What do HTTP 4xx codes do?
generally indicate a bad HTTPRequest
362
What does HTTP 401 code mean?
unauthorized - typically means no user information was provided in the request
363
What does HTTP 403 code mean?
forbidden - user in request is not authorized to view the material
364
What does HTTP code 404 mean?
the requested resource does not exist
365
What do HTTP 5xx codes mean?
generally indicate a server-side error
366
What does HTTP code 500 mean?
server side code had an error while running (for instance, an unhandled runtime error on server side)