Chapter 4 – Writing, Debugging, and Testing Functions Flashcards

1
Q

What does the C# keyword void mean?

A

It indicates that a method has no return value.

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

What are some differences between imperative and functional programming styles?

A

An imperative programming style means writing a sequence of statements that the runtime executes step by step like a recipe. Your code tells the runtime exactly how to perform the task. Do this. Now do that. It has variables meaning that the state can change at any time, including outside the current function. Imperative programming causes side effects, changing the value of some state somewhere in your program. Side effects are tricky to debug. A
functional programming style describes what you want to achieve instead of how. It can also be described as declarative. But the most important point is that functional programming languages make all states immutable by default to avoid side effects.

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

In Visual Studio Code or Visual Studio, what is the difference between pressing F5, Ctrl or Cmd
+ F5, Shift + F5, and Ctrl or Cmd + Shift + F5?

A

F5 saves, compiles, runs, and attaches the debugger; Ctrl or Cmd + F5 saves, compiles,
and runs the application without the debugger attached; Shift + F5 stops the debugger and
running application; and Ctrl or Cmd + Shift + F5 restarts the application without the debugger
attached.

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

Where does the Trace.WriteLine method write its output to?

A

Trace.WriteLine writes its output to any configured trace listeners. By default, this includes the terminal or the command line but can be configured to be a text file or any custom listener.

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

What are the five trace levels?

A

0 = Off, 1 = Error, 2 = Warning, 3 = Info, and 4 = Verbose.

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

What is the difference between the Debug and Trace classes?

A

Debug is active only during development. Trace is active during development and
after release into production.

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

When writing a unit test, what are the three “A”s?

A

Arrange, Act, and Assert.

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

When writing a unit test using xUnit, what attribute must you decorate the test methods with?

A

[Fact] or [Theory].

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

What dotnet command executes xUnit tests?

A

dotnet test.

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

What statement should you use to rethrow a caught exception named ex without losing the
stack trace?

A

Use throw;. Do not use throw ex; because this will lose stack trace information.

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

What statement should you use to rethrow a caught exception named ex without losing the
stack trace?

A

Use throw;. Do not use throw ex; because this will lose stack trace information.

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