C# Flashcards

1
Q

The concept of organizing your code such that logic that follows a certain theme or have some dedicated functionality are grouped together

In a nutshell: Leveraging classes and other grouping mechanisms to group data and logic that belong with each other

We want to avoid having spaghetti code! We want lasagna!

This is the first step in writing readable, extendable, and maintainable code

A

Separation Of Concerns

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

Building blocks of your program

They are the blueprints to the actual objects that you process in your program

Besides being used to structure data, you also use classes to encapsulate logic and the data that go together.

A

Classes

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

Logical grouping of types that follow a certain theme of functionality.

To utilize the classes located in a different namespace, use the using keyword

Analogous to Java packages.

Note: If namespaces are the logical grouping of types, the physical grouping are called assemblies.

A

Namespace

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

a container for one or more related projects, along with build information, Visual Studio window settings, and any miscellaneous files that aren’t associated with a particular project.

Final packaging of your application

A

Solution

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

contains all files that are compiled into an executable, library, or website.

Those files can include source code, icons, images, data files, and so on.

contains compiler settings and other configuration files that might be needed by various services or components that your program communicates with.

A

Project

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

A typical C# program uses types from the class library and user-defined types that model the concepts that are specific to the program’s problem domain.

You use data types to structure the data that you process in your program. They’re very important in app design!

Setting a data type is also a form of validation that leverages the strong typing of C#.

Fun Fact! All types inherit from the System.Object base class. (Which is just a fancy way of saying all types are objects!)

A

Data Types

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

What are the two types of data types?

A

Value and Reference

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

What does CTS stand for?

A

Common Type System

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

What is CTS?

A

The CTS is a standard definition of the types in .NET compliant languages.

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

Analogous to java’s primitives

Types that derive from System.Value.

Stored in the stack and not the heap.

This means that when accessing the value of a variable set to a value type, you get the value directly and not a reference to where the value is stored in heap.

There’s no separate heap allocation or garbage collection overhead for value-type variables.

Two categories:
Structs – used to create custom value types
Enums - defines a set of named integral constants

A

Value Types

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

A type that is defined as a class, string, delegate, array, interface, or record is a reference type.
Record is a new reference type introduced in .NET 5/C#9

At run time, when you declare a variable of a this type, the variable contains the value null until you explicitly create an object by using the new operator or assign it an object that has been created elsewhere.

A

Reference Types

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

Where are Reference Types stored?

A

Note that reference types are stored in the heap. The stack holds the reference to a place in heap that contains the actual value of the object.

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

What is language interoperability?

A

Basically, in one solution, your projects can be written in multiple .NET compliant language.

You can have a project written in VB.NET and reference that same project in a project written in C#

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

What is .NET?

A

.NET is a free, open-source development platform for building many kinds of apps.

Development platform means it’s a collection of libraries and languages that you can use to develop applications as well as runtime implementations to run your applications on

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

What does SDK stand for? What does it do?

A

The software development kit (SDK) includes everything you need to build and run .NET Core applications, using command line tools and any editor (including Visual Studio).

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

what does the runtime do?

A

Theruntimeincludes just the resources required to run existing .NET Core applications. The runtime is included in the SDK.

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

What does BCL stand for? What does it do?

A

The base class library (BCL) provides classes and types that are helpful in performing day to day operation e.g. dealing with string and primitive types, database connection, IO operations.

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

What does CLR stand for? what does it do?

A

.NET provides a run-time environment, called the common language runtime, that runs the code and provides services that make the development process easier.

Some of those services include:
Memory management
JIT compilation
Exception handling support

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

Code whose execution is managed by a runtime.
The CLR is in charge of taking the managed code, compiling it into machine code and then executing it. On top of that, runtime provides several important services such as automatic memory management, security boundaries, type safety etc.

A

Managed Code

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

Code that is developed outside .NET is unmanaged code.

Code that isn’t managed by the CLR

Does not leverage CLR features such as memory management

Executed by the help of wrapper classes

A

Unmanaged Code

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

What is Garbage Collection?

A

CLR provides automatic memory management of your heap memory

When the garbage collector performs a collection, it checks for objects in the managed heap that are no longer being used by the application and performs the necessary operations to reclaim their memory.

Sometimes we utilize resources that are outside the scope of the CLR. We need to clean this up ourselves.
Luckily, there is the IDisposable interface with the dispose() method that can be used to clean up these external resources.

Types that utilize these unmanaged resources inherit from the IDisposable Interface

You can also use using blocks and statements for clean up.

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

What is a collection?

A

A collection is a data structure that can hold one or more items.

In C# there are two major types of collections: generic and non generic

All collections provide methods for adding, removing, or finding items in the collection.

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

What are Arrays?

A

The basic data structure to store a group of objects

A collection of objects of the same data type stored in a contiguous space in memory

Array types:
Single dimensional
Multidimensional
Jagged: Array of arrays

Note that array sizes are immutable!

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

Note that arrays belong in the System namespace and is not included in the hierarchy.

All collections that directly or indirectly implement the ICollection interface or the ICollection interface share these features:
The ability to enumerate the collection
The ability to copy the collection contents to an array
Capacity and Count properties
A consistent lower bound

The IEnumerable interface exposes an enumerator, which supports a simple iteration over a non-generic/generic collection

A

Collection Hierarchy

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

What are non-generic collections?

A

Non generic collections are used to store data when the size is unknown. This makes sure that you only take up the memory space you need!

Some common non generic collections:
Arraylist
Hashtable
Stack 
Queue

Note that non generic collections store data as objects, this means that you can store multiple data types in one collection. To be able to have a homogenous data set, you’ll have to set up some type checking before storing in a non generic collection.

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

what are generic collections?

A

Leveraging generics you are able to have a type safe collection

Because you’re not casting things to an object, you’ll be able to save on overhead

Some common generic collections:
List
list of objects that can be accessed by index
An ever expanding array

Dictionary
Represents a collection of key/value pairs that are organized based on the key.

Stack
LIFO

Queue
FIFO

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

What is the root interface of the collections hierarchy?

A

ICollection Interface

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

What is the IEnumerable for?

A

The IEnumerable interface exposes an enumerator, which supports a simple iteration over a non-generic/generic collection

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

Arrays vs ArrayList vs List?

A

Arrays have the same data type (type safe) and a fixed size

ArrayList can have multiple data types and do not have a fixed size

List have the same data type (type safe) and do not have a fixed size

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

What are non-access modifiers?

A

AKA keywords, modifiers, etc.

They are used to modify the declaration of types and type members

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

Applied to: classes and class members

Enables you to create classes and class members that are incomplete and must be implemented in a derived class.

This keyword cannot be used with the static keyword

____ methods are:
Implicitly virtual (implicitly overridable)
Only declared in abstract classes
Have no method body (just a method signature)

A

Abstract

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

Applied to: fields
_____ fields and locals aren’t variables and may not be modified.
_____ can be numbers, Boolean values, strings, or a null reference.
Don’t create a ____ to represent information that you expect to change at any time.

A

Constant

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

Applied to: fields, structs, and struct members

______ fields:
indicates that assignment to the field can only occur as part of the declaration or in a constructor in the same class.
A ______ field can’t be assigned after the constructor exits

_____ struct:
indicates that the structure type is immutable.

A

Readonly

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

Whats the difference between the non-access modifiers: readonly and constant?

A

Const fields are initialized on declaration. The initialization of readonly fields can be accomplished at a later point.

A const field is a compile-time constant, the readonly field can be used for run-time constants.

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

Applied to: classes, class members

_____ classes cannot be inherited by other classes

______ methods and properties aren’t overridable in
any classes that inherit those members

Similar to the final keyword in java

A

Sealed

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

Applied to: classes and class members

Used to create class members which belongs to the type itself rather than to a specific object

This means that all instances of the type would have the share the same variable value for ___ fields

You wouldn’t need to instantiate an object of the type to access a static method

A ____ class can only have ____ members

A

Static

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

Applied to: methods, properties, indexers, events

Used to modify a method, property, indexer, or event declaration and allow for it to be overridden in a derived class.

By default, methods are non-_____. You cannot override a non-_____ method.

You cannot use the ____ modifier with the static, abstract, private, or override modifiers.

A

Virtual

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

Applied to: classes and class members

Used to partially declare a class or class member.

This keyword allows definition of a class/class 
member to be spread across multiple different files.
A

Partial

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

Applied to: methods, properties, indexers, events

Required to extend or modify the abstract or virtual implementation of an inherited method, property, indexer, or event.

A

Override

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

Applied to: methods, properties, indexers, events

____ modifier (different from the ___ keyword!) is used to hide the base implementation of a class member. Instead of extending the virtual or abstract class members, ____ modifier creates a ____ class member with the same name and makes the base implementation inaccessible.

You cannot use this with override, as they are mutually exclusive.

A

New

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

What are modifiers? Are they only limited to access modifiers?

A

The modifiers include private, public, protected, internal, and two combinations: protected-internal and private-protected.

No, there are also non-access modifiers

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

What are non-access modifiers?

N.O.V.A.S S.P.R.C (novas spark)

A

New, Override, Virtual, Static, Sealed, Partial, Readonly, Constant, and Abstract

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

Where can I apply the sealed keyword to?

A

Applied to: classes, class members

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

How do I make something overridable? How do I override it?

A

use keyword override

ex public virtual void dog(){}
public override void dog(){}

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

What’s the difference between new and override?

A

The override modifier may be used on virtual methods and must be used on abstract methods. This indicates for the compiler to use the last defined implementation of a method. Even if the method is called on a reference to the base class it will use the implementation overriding it.

The new modifier instructs the compiler to use your child class implementation instead of the parent class implementation. Any code that is not referencing your class but the parent class will use the parent class implementation.

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

What are the four OOP pillars?

A P.I.E

A

Abstraction
Polymorphism
Inheritance
Encapsulation

47
Q

a technique for dealing with complexity by providing users with a simplified interface which hides the complex details of an operation

Separation between the needed functionality and implementation details

Hide the implementation details of how data is being processed, of how logic is executed, show your end user the properties/methods available to them for use

Implemented in C# using interfaces and ____ classes

A

Abstraction

48
Q

Contains definitions for a group of related functionalities that a non-abstract class or a struct must implement

May not declare instance data such as fields, auto-implemented properties, or property-like events.

All method stubs declared within interfaces are implicitly abstract

May define static methods, which must have an implementation

Does not have constructors

Cannot be instantiated at all

A

Interfaces

49
Q

What are Abstract Classes?

A

Denoted using abstract keyword

Can have constructors

these are used to initialize fields in the abstract class

Often contains unimplemented method stubs

May have abstract and non abstract methods

May have fields

50
Q

What is the difference between abstract classes and interfaces?

A

Abstract classes are used to impose/create hierarchy whilst interfaces are used as a contract to impose functionality/behavior

51
Q

What is Polymorphism?

A

Literally means “many forms”

When you present the same interface but the inputs/data types being utilized would different

Ability to substitute different implementation details for different needs

Ability of an object to take on many forms

52
Q

What are examples of Polymorphism?

A

Type casting:
Going to and from from one type to another
Up/Implicit and Down/Explicit casting

Method Overloading:
Methods with the same name, different parameters
They act differently depending on what parameters are passed to them

Method Overriding:
We override a parent’s method in a derived class, so while they have the same name and signature, they behave differently depending on which class’s method we call

Generics
Yes, that generic collections.
Why are they a form of polymorphism? Because you can have things like List, List, List», but we’re guaranteed that all of the List’s methods will behave the same way no matter what we “collect” inside. For different data types, they have to behave differently under the hood.

53
Q

The mechanism of basing an object or class upon another object or class, retaining similar implementation

Establishes an “is-a” relationship between objects
Promotes code reusability

In C# the constructors are inherited from parent to child

You can ____ from multiple interfaces but you can only ____ from one class

A

Inheritance

54
Q

Are the static members of a class inherited?

A

Static classes are sealed and therefore cannot be inherited. They cannot inherit from any class except Object.

55
Q
Treat related data/behavior as a single unit/capsule
This means that the validation and any processing of the data in your data classes would be done in the class itself. 

_______ also concerns itself with the data security

We use classes and access modifiers to achieve _____

A

Encapsulation

56
Q

What is the difference between Encapsulation and Abstraction?

A

“Abstraction and encapsulation are complementary concepts: abstraction focuses on the observable behavior of an object…encapsulation focuses on the implementation that gives rise to this behavior“

57
Q

What are some use cases for abstraction? Polymorphism? Inheritance? Encapsulation?

A

abstraction: Iphone home screen, result of an action created by the user: example pressing jump makes you jump

Polymorphism: Overloading and overriding

Encapsulation: access modifiers, such as, private, public, protected, and internal

58
Q

What are the different types of variance?

A

Covariance: using child in place of parent
Contravariance: using parent in place of child
Invariance: you’re not allowed to substitute types

59
Q

What is boxing?

A

Boxing is the process of converting a value type to the type object or to any interface type implemented by this value type.

Consider the following declaration of a value-type variable:

int i = 123;
The following statement implicitly applies the boxing operation on the variable i:

// Boxing copies the value of i into object o.
object o = i;
The result of this statement is creating an object reference o, on the stack, that references a value of the type int, on the heap. This value is a copy of the value-type value assigned to the variable i.
60
Q

What is unboxing?

A

Unboxing is an explicit conversion from the type object to a value type or from an interface type to a value type that implements the interface. An unboxing operation consists of:

Checking the object instance to make sure that it is a boxed value of the given value type.

Copying the value from the instance into the value-type variable.

The following statements demonstrate both boxing and unboxing operations:

int i = 123; // a value type
object o = i; // boxing
int j = (int)o; // unboxing

61
Q

Who uses boxing and unboxing?

A

Non-generic collections

62
Q

Going from more derived/restrictive type to less
derived/broader type

Ex. Int -> double

Implicit (you don’t have to explicitly tell the compiler)

A

Upcasting

63
Q

Going from a less derived/broader type to a more derived/restrictive type

Double -> int

Explicit
May result in data loss

A

Downcasting

64
Q

used to check if the run-time type of an object is compatible with the given type or not.

It returns true if the given object is of the same type otherwise, return false. It also returns false for null objects.

A

is operator

65
Q

used to get a type at the compile-time. Or in other words, this operator is used to get the System.Type object for a type.

Gives you the CTS version of the type

This operator takes the Type itself as an argument and returns the marked type of the argument.

Often confused with the GetType() method of an object

This method returns the type in the c# sense of an object

A

typeof operator

66
Q

How is variance related to polymorphism?

A

Covariance and contravariance are terms that refer to the ability to use a more derived type (more specific) or a less derived type (less specific) than originally specified. And this is related to polymorphism because you might want to override a method to have a double type instead of an int type.

67
Q

What are the different ways to type cast?

A

upcast and downcast

68
Q

What are the different ways to check a type?

A

is operator and typeof operator

69
Q

Why is type checking important?

A

it eliminates class errors before you run the program

70
Q

What is a byte stream?

A

As the name suggests its a stream of bytes

Used in writing to an external file

Can be thought of as a bridge between c# code and the file

You send bytes to the byte stream so they can be written externally

Types of bytestreams in c#:
Stream, FileStream, MemoryStream and BufferedStream

71
Q

What is a character stream?

A

Similar to a byte stream, this is also used to write to external files

Stream of characters

Used to write stream of text to file

Types of character streams in c#:
Textreader, TextWriter, StreamReader, StreamWriter

72
Q

What is serialization? Why is it important?

A

Process of converting an object into a stream of bytes to store the object or transmit it to memory, a database, or a file

Save the state of the object for latter recreation (when needed)

It is important because if you have important information like a clients username and password, you want it to be saved for the next time they access your website.

73
Q

What is deserialization?

A

Process of unpacking serialized objects

74
Q

What is SOLID? Give a brief explanation of each concept.

A

used to create robust programs that are understandable, flexible and maintainable

Single Responsibility (Principle) - Objects should have one and only one purpose

Open-Close (Principle) - Open for extension, closed for modification

Liskov Substitution (Principle) - Derived objects should be substitutable for their base implementations

Interface Segregation (Principle) - Users of interfaces should not be dependent upon methods they do not use

Dependency Inversion (Principle) - Concrete implementations should be based upon abstract definitions

75
Q

How do I implement SRP? OCP? LSP? ISP? DIP?

A
implenting:
SRP = This means that every class, or similar structure, in your code should have only one job to do. Everything in that class should be related to a single purpose.

OCP = Here “Open for extension” means, we need to design our module/class in such a way that the new functionality can be added only when new requirements are generated. “Closed for modification” means we have already developed a class and it has gone through unit testing.

LSP = This principle is just an extension of the Open Closed Principle and it means that we must ensure that new derived classes extend the base classes without changing their behavior.

ISP = An interface should be more closely related to the code that uses it than code that implements it. So the methods on the interface are defined by which methods the client code needs rather than which methods the class implements. So clients should not be forced to depend upon interfaces that they don’t use.

DIP = High-level modules/classes implement business rules or logic in a system (application). Low-level modules/classes deal with more detailed operations; in other words they may deal with writing information to databases or passing messages to the operating system or services.

76
Q

What are Regular Expressions?

A

As the name suggests regular expressions are expressions used to regulate input.

77
Q

When can we use regular expressions?

A

They’re primarily used in pattern matching.

Using certain notation, you can build an expression to check if a certain input follows a pattern

For example, if you want to restrict input to a proper format, maybe letters followed by digits only

We can build and utilize RegEx expressions using the RegEx class

78
Q

An ____ is an event that occurs during the execution of a program that disrupts the normal flow of instructions.

Could be a bad (if you’re demoing something to important people) or good (if you’re developing and find out a use case you haven’t handled)

Note: ____ are different from errors. Errors indicate serious problems that an application shouldn’t try to catch. They’re events that are fatal to the program runtime. They’re not something that can be handled. Like a stack overflow, its something out of the developer’s hands.

A

Exceptions

79
Q

Throwing Exceptions

A

Obviously, exceptions tell you when something is wrong

You’d want to know why your program isn’t working
Exceptions are also good for enforcing logic/rules in your program

In fact, you can make custom exceptions for this purpose!

You throw exceptions using the throw keyword

80
Q

Handling Exceptions

A

Exceptions are handled using a try-catch block

You wrap the risky (might throw an exception) code in a try block

Handle any exceptions that have occurred in a catch block

Note that order matters! Catch the more specific exceptions first then the more general ones

Clean up any open resources using a finally block
Or run any code that should always run with or without exception

81
Q

What are exceptions? How are they different from errors?

A

Exceptions are different from errors. Errors indicate serious problems that an application shouldn’t try to catch. They’re events that are fatal to the program runtime. They’re not something that can be handled. Like a stack overflow, its something out of the developer’s hands.

82
Q

Why handle exceptions?

A

helps maintain the normal, desired flow of the program even when unexpected events occur.

83
Q

How do you handle exceptions?

A

Exceptions are handled using a try-catch block

84
Q

Why throw exceptions?

A

You should throw an exception if a method is not able to do the task it is supposed to do.

85
Q

What is the exception hierarchy?

A

it lists all the exceptions an object could have

86
Q

used for the passing the arguments to methods as a reference type

It is generally used when a method returns multiple values

The ____ parameter does not pass the property

The variable need not be initialized when passing an out parameter

A

Out keyword

87
Q

used for the passing the arguments by a reference

Or we can say that if any changes made in this argument in the method will reflect in that variable when the control return to the calling method.

The ____ parameter does not pass the property

The variable needs to be initialized before passing

A

Ref keyword

88
Q

What does it mean to pass by reference?

A

Basically, it means that any change made to a value that is passed by reference will reflect this change since you are modifying the value at the address and not just the value.

89
Q

What are some use cases for passing by reference?

A

if you want to change the value of a methods parameter
ex:

class Product
{
    public Product(string name, int newID)
    {
        ItemName = name;
        ItemID = newID;
    }
public string ItemName { get; set; }
public int ItemID { get; set; } }
private static void ChangeByReference(ref Product itemRef)
{
    // Change the address that is stored in the itemRef parameter.
    itemRef = new Product("Stapler", 99999);
    // You can change the value of one of the properties of
    // itemRef. The change happens to item in Main as well.
    itemRef.ItemID = 12345;
}
private static void ModifyProductsByReference()
{
    // Declare an instance of Product and display its initial values.
    Product item = new Product("Fasteners", 54321);
    System.Console.WriteLine("Original values in Main.  Name: {0}, ID: {1}\n",
        item.ItemName, item.ItemID);
// Pass the product instance to ChangeByReference.
ChangeByReference(ref item);
System.Console.WriteLine("Back in Main.  Name: {0}, ID: {1}\n",
    item.ItemName, item.ItemID); }
// This method displays the following output:
// Original values in Main.  Name: Fasteners, ID: 54321
// Back in Main.  Name: Stapler, ID: 12345
90
Q

What are the key differences between ref and out parameters?

A

ref:

It is necessary the parameters should initialize before it pass to ref.

It is not necessary to initialize the value of a parameter before returning to the calling method.

The passing of value through ref parameter is useful when the called method also need to change the value of passed parameter.

When ref keyword is used the data may pass in bi-directional.

out:

It is not necessary to initialize parameters before it pass to out.

It is necessary to initialize the value of a parameter before returning to the calling method.

The declaring of parameter through out parameter is useful when a method return multiple values.

When out keyword is used the data only passed in unidirectional.

91
Q

What is application monitoring? Why is it useful?

A

Highlighting certain events that come up during the runtime of your program

Highlighting events in the form of pausing program execution or recording its occurrence

Useful in finding points of failure, i.e, debugging
What

92
Q

During development, you can add ____ to certain lines of your code

When you do a debug run, the program pauses its execution when it hits a breakpoint

Upon hitting a ____, you can:
Check the values of any variables in scope
Continue to the next ____
Step over a function that is called
Step into a function that is called
Step out into the original line that called the function

A

Breakpoints

93
Q

Practice wherein certain events during a program runtime is recorded

Events that warrant a record: 
Errors 
Business logic events 
For example, someone logged in the program
Transactions with external systems 
For example, performing actions on a database
Etc 
Depends on the need 
Company conventions
A

Logging

94
Q

What are the logging levels? Give a brief explanation of each.

VID FEW

A

Verbose
Anything and everything you might to know about a running block of code

Debug
Internal system events that aren’t necessarily observable from the outside

Information
“Things happen”

Warning
Service is degraded or endangered

Error
Functionality is unavailable, invariants are broken, or data is lost

Fatal
Very severe events that will lead the application to abort

95
Q

where are the logs?

FDC

A

Files
.txt, .xml, etc
Really depends on how you configure your logs

DBs
You can use databases to store your logs

Console
Like a heathen

96
Q

Confused with logging since they use similar software

Used to track a user’s interaction with the system

Unlike logging that shows the events that occur during runtime, _____ is highly involved in debugging and would include information such as which functions were called and what parameters were provided during the time the user interacted with the program.

You would go through the same steps as the user to find where the bug occurs
Any methods that throw an error during ____, would be logged

A

Tracing

97
Q

Why are breakpoints important? What’s the use of breakpoints?

A

Breakpoints are one of the most important debugging techniques in your developer’s toolbox. You set breakpoints wherever you want to pause debugger execution. For example, you may want to see the state of code variables or look at the call stack at a certain breakpoint.

98
Q

Why is logging important?

A

so you can see when certain events happen during a runtime of your program. For example, if a customer breaks your UI, you’ll want to know how. Through logging, you will be able to see where the error occurred and thus help you fix it.

99
Q

Why are there logging levels?

A

Logging levels help the programmer tell different log events from each other

100
Q

____ is a reference data type in C# that defines the method signature
It is a way to pass functions as parameters
Can be used in various ways, such as event handling or callback functions

A

Delegate

101
Q

How do you create a delegate?

A

Declare a delegate
Define which kind of method signature is needed for your delegate
EX. Public delegate void MyDelegate(string msg);

  1. Set a target method
    Create a method that matches your delegate’s signature, and then assign it to your delegate
    EX. MyDelegate del = (string msg) =>
    Console.WriteLine(msg);
  2. Invoke your delegate
    Either using Invoke() method or with () operator, like how you would call any other function.
102
Q

You can assign more than one methods to a delegate
Simply use the addition assignment operator (+=) to tack on additional methods

Use subtraction assignment operator (-=) to remove them.

MyDelegate del = Method1;
del += Method2;
del -= Method1;

A

Multicasting

103
Q

What are some built-in delegates?

A

Func
Action
Predicate
EventHandler

104
Q

____ has 0 or more input parameters and 1 output parameters.

Use ____ Delegate when you are returning one object

Syntax: public delegate TResult ____ (T1 arg1, T2 arg2)

This translates to..
Public delegate TResult MyDel(T1 arg1, T2 arg2)
Use: public delegate ____ sum = (int n, int m) => n + m;

A

Func (System)

105
Q

___ takes in 0 or more input and returns void.
Use ___ with methods that have side effects but does not return anything
Ex. ___ printInt = (int n) => Console.WriteLine(n);

A

Action (System)

106
Q

_____ is a delegate that takes in one argument and returns a Boolean value.

Equivalent to Func

This is the delegate we use with LINQ’s FirstOrDefault, or Where, or FindIndex, etc.

Ex. _____ isUpper = (string str) => str.Equals(str.ToUpper());

A

Predicate (System)

107
Q

____ is a special type of multicast delegate

Use these with event keyword instead of delegate

The class with the delegate is a publisher who emits events

The classes whose methods are assigned to the delegate are called subscribers

To pass data along with the event, use EventArgs, or your custom object that extends EventArgs.

Ex. Public event EventHandler MyEvent

A

EventHandler (System)

108
Q

Testing small units of your code.

Helpful when you wanna make sure everything is working perfectly (without repeating some actions to get there).

Also helpful in pinpointing where the code is going wrong.

The _______ framework we’ll be using is Xunit

A

unit testing

109
Q

What are the parts of a unit test? give a brief explanation of each.

A

Arrange
This is any setup necessary to prepare for the behavior to test. You assume the thing you wanna test works.

Act
You do the thing you wanna test. You usually name the method after the thing you wanna test.

Assert
Verify the behavior was as expected, sometimes on the same step as ACT.

110
Q

What does TDD stand for? what does it mean?

A

Test Driven Development

TDD reduces the number of bugs in production and improves code quality. In other words it makes code easier to maintain and understand.

Ex:
Write tests that fail
Implement code to make tests pass

111
Q

Why use TDD?

A

Reduces bugs when applied to legacy projects
Decreases bug to code ratio in new projects
Increases overall software quality
Increases code quality

112
Q

Why is unit testing important?

A

developers can save time as bugs can be identified early in the process as it is the initial phase of testing.

113
Q

What is c#?

A

C-Sharp is an object-oriented programming language developed by Microsoft that runs on .Net Framework. It has features like strong typing, imperative, declarative, object-oriented (class-based), and component-oriented programming. It was developed by Microsoft within the .NET platform

C# is an ideal choice for building applications for both hosted and embedded systems