Interviews Flashcards

(48 cards)

1
Q

Await versus Tak.ContinueWith

A

Intrebari:
- Codul async nu blocheaza executiile viitoare, insa ce face cu liniile executate care depinde de rezultat?
————————————————-
public async void MyMainMethod()
{
await DoSomethingAsync();

//Here is a critical method that I want to execute only when
//DoSomethingAsync is finished

CriticalStuff();
}

public async Task DoSomethingAsync()
{
//Do whatever
await LongOperation();
// Rest of the method that is executed when the long operation is
//finished.

}
When DoSomethingAsync returns, it doesn’t just blindly hand control back to the calling method. It hands it a Task. If the method in fact completed synchronously, it’ll hand back a task that’s already completed. Otherwise, if the method still has work to do, the Task will be running, not (yet) completed.

So, DoSomethingAsync actually triggers some async behaviour and returns back a not-yet-completed Task to Main. What does Main do with it? It awaits it. await is how that method indicates “I can’t do anything useful unless this awaitable (usually a Task) is complete”.

Asyncronicitate, NU concurenta

If this is the first (required) await in the method, it’s at this point that the async machinery kicks in, signs up a continuation and returns from Main itself &raquo_space;
When the local thread would be doing nothing except blocking (waiting for a reply), then : in many cases there are much better things that the thread could be doing: In the case of a client app, those “better things” include painting the UI and responding to input. In the case of a server app, those “better things” include servicing other concurrent requests / load.
——————————————————
Similarity:
So from the preceding it’s clear that both Task.ContinueWith and await Task wait for the task to finish and allows continuation after the task completion. But they work differently.
- ContinueWith
The ContinueWith function is a method available on the task that allows executing code after the task has finished execution. In simple words it allows continuation.
- await:
The await keyword causes the runtime to run the operation on a new task and causes the executing thread to return and continue with an execution. (In most cases it executes the main thread of the application). Once the await operation finishes it returns to the statement where it left off (in other words it returns to the caller, in other words it returns depending on the state saved) and starts executing statements.

Difference:
(La ContinueWith poti pierde contextul din momentul lansarii codului async)
ContinueWith doesn’t save any kind of state, the continuation operation is attached using ContinueWith run on the default thread scheduler in case a scheduler is not provided.

await: when encountering this keyword the state is saved and once the task on which await is done completes its execution the flow picks up the saved state data and starts the execution statement after await. (Note: State is having detail about executioncontext/synchronizationcontext.).

Resource: https://www.c-sharpcorner.com/UploadFile/pranayamr/difference-between-await-and-continuewith-keyword-in-C-Sharp/

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

Is there a new thread created for async/await?

A

> No, async await is just made to allow code to run whilst something else is blocking, and it doesn’t do Task. Run, or start a new thread.
The async and await keywords don’t cause additional threads to be created. Async methods don’t require multithreading because an async method doesn’t run on its own thread. The method runs on the current synchronization context and uses time on the thread only when the method is active.
SynchronizationContext is a representation of the current environment that our code is running in. That is, in an asynchronous program, when we delegate a unit of work to another thread, we capture the current environment and store it in an instance of SynchronizationContext and place it on Task object.

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

Value type vs reference type
- exemple
- diferente (alocare a memoriei, dealocare)
- poate un value type fii salvat si in alte locatii…
- sunt value type sealed?

A

Value:
They contain the actual values. eg (fundamental data types: -int, enum, structs).

Ref:
eg-class,interface,delegate,string,object, Array
———————————————————
Allocation

Value: Memory is allocated at compile time
Ref: Memory is allocated at run time

Value type:Value type is popped on its own from stack when they go out of scope.
Reference type:Required garbage collector to free memory.
———————————————————-
Deallocation

While the objects stored on the stack are gone when the containing stack frame is popped, memory used by objects stored on the heap needs to be freed up by the garbage collector.
When an object stored on the heap no longer has any references pointing to it, it’s considered eligible for garbage collection.
At a certain point, garbage collector kicks in, interrupts all running threads, invokes the finalizers of the objects it’s trying to get rid of (on a special finalizer thread), and then marks the memory as free to use.

Value type and it storage locations

If the value type was declared as a variable inside a method then it’s stored on the stack.
If the value type was declared as a method parameter then it’s stored on the stack.
If the value type was declared as a member of a class then it’s stored on the heap, along with its parent.
If the value type was declared as a member of a struct then it’s stored wherever that struct is stored.

Starting with C#7.2, a struct can be declared as ref struct, in which case it will always be allocated on the stack, preventing it from being declared inside reference types.

Value types- Sealed or not

Instances of value types directly contain their data. Variables that are of value types each have their own copy of the data, and therefore, an operation on one variable does not affect other variables. Value types are implicitly sealed types, since they cannot be derived from.

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

Boxing vs unboxing

A

Boxing - convertirea unui value type in reference type.
Boxing - implicit
Unboxing- explicit

– : very processive expensive
++: enables unified view of the type system wherein a value of any type can ultimately be treated as an object

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

Mutable vs immutable

A

The meaning of these words is the same in C# programming language; that means the mutable types are those whose data members can be changed after the instance is created but Immutable types are those whose data members can not be changed after the instance is created.

String context:
Why somebody should avoid to concatenate a large number of strings? What is the alternative?
• Immutable: Strings are immutable, which means we are creating new memory everytime instead of working on existing memory.
So, whenever we are modifying a value of the existing string, i.e., we are creating a new object which refers to that modified string and the old one becomes unreferenced.
• Mutable: StringBuilder is a mutable type, that means we are using the same memory location and keep on appending/modifying the stuff to one instance. It will not create any further instances hence it will not decrease the performance of the application.

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

Transactions- phenomena that can happen

A
  • dirty read: read an uncommitted value, which will be might be reverted
  • non repeatable reads: reading the same value in a row twice, wont fetch the same result (a nu se confumda cu dirty; e fiindca chiar s-a schimbat intre timp)
  • phantom reads: All the rows in the query have the same value before and after,but different rows are being selected(because B has deleted or inserted some). Example:select sum(x) from table;will return a different result even if none of the affected rows themselves have been updated, if rows have been added or deleted.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Transaction Isolation level

A
  • read uncommitted : dirty read can happen
  • read committed , dirty read cannot happen because the transaction holds a write and read lock on the current row
  • repeatable read: most restrictive isolation level- hold lock (read and write) on all isolation levels
  • serializable: all transactions seem to be executed serially. No phantom read
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Define ACID

A

Atomicity- all or nothing type if transaction
Consistency- guarantees transaction state
Isolation- assures transactions are run independently
Durability- data is never lost

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

Define SOLID

A

Single responsability principle- any class/module should have but one responsability
T: . Uncle Bob Martin (who first proposed the Single Responsibility Principle) suggests that components should be broken down until each one has only one reason to change.- not always valid as well - https://reflectoring.io/single-responsibility-principle/

Open closed principle- open to extension, close to modification. Should inherit a base instead of changing internal
Liskov substitution principle- any subtype should be able to replace its parent type, without modifying the app behaviour
Interface segregation - make small interfaces upon the need. Don’t write one that does anything
Dependency Inversion Principle- base on abstractions and not on details between the modules so you can have a loosely coupling

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

Explain how async/await works behind the scenes

A
  • async is the method that marks the code that has to be executed async
  • await is where the async code must complete its promise; If the code from async is not yet done, it will be returned to the its initial caller (where the await is)
  • if async code is finished before reaching the await, its execution is no longer suspended and returned to the calles
  • async return types:
  • task: await statement (este asteptat, dar nu se returneaza nimic; folosit cu statementuri care nu returneaza nimic sau au return simplu, fara a returna un operand)
  • task await: await expression (utilizat in cazul statementurilor care returneaza operands; initial se returneaza un obiect de tip task, care la “await” suspenda executia metodei in care ne aflam si populeaza si cu valoare, cand aceasta este disponibila)
  • void: se folosesc rar, ca nu se pot prinde erori, de ex pentru event handlere! (eg: click pe un buton, etc)

Source: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/async/task-asynchronous-programming-model

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

Can async/await cause a deadlock?

A

Yes it can cause if the caller blocks the synchronization context synchronously blocks the task returned by the async code (blocking also the context thread), but the async code is waiting for the liberation of the synchronization context to finish its job.
public static async Task GetJsonAsync(Uri uri)
{
// (real-world code shouldn’t use HttpClient in a using block; this is just example code)
using (var client = new HttpClient())
{
var jsonString = await client.GetStringAsync(uri);
return JObject.Parse(jsonString);
}
}

// My “top-level” method.
public class MyController : ApiController
{
public string Get()
{
var jsonTask = GetJsonAsync(…);
return jsonTask.Result.ToString();
}
}

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

What is CLR?

A

Common Language Runtime este o masina virtuala a Microsoftului care gestioneaza rularea mai multor limbaje de programare, precum si C#. CLR ofera un managed runtime environment (nu pe OS direct), care ofera security handling, memory management, automatic garbage collection

Sursa: intrebarea 2- What is Common Language Runtime (CLR)?

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

Type of classes in C#?

A

Abstract
Sealed
Static
Partial
- to be continued

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

Abstract classes VS interfaces

A

to be continued

Abstract classes- used for objects that are closely related
Interfaces- used to define common functionality to unrelated classes

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

Managed VS unnmanaged code

A

Manged - runs on the CLR
Unnmanaged - outside the .NET framework, lacking high level language services

source: https://www.interviewbit.com/c-sharp-interview-questions/
- to be continued

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

Ref VS out keywords

A

Both are a way of passing arguments as a reference to a method. While ref is used in a bidirectional way and is used to update an existing value, out is used to retrieve multiple values (no prev instantiation, but must be initialized inside the method)

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

Extension methods. What are? When do we use them?

A

Extension methods enable you to ‘add’ methods to existing classes without creating a new derived class or modifying the existing class. They are static methods but they are called as they would be the instance’s methods.

One of the most popular extension methods are the LINQ - standard query operator methods- that add querable behavior to the IEnumerable collection.

https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/extension-methods

https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/extension-methods

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

How is memory deallocated in. NET?

A

In the context of CLR, the garbage collection works automatically.
It is called when:
- overall memory os low
- the current generation is full
- on demand
GC works in generations, meaning that the first variables are stored on Gen0. When the first clean-up starts, what is not deleted to Gen1 and so on…
Cleaning up means that the GC will look into the app root and will delete everything that’s not global or static and is out of context.

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

Covariance and contravariance

A

Covariance is the feature that enables you to pass a derived class when a base class is expected.
Covariance: assignment is preserved
Useful in polymorphism
> Assignment compatibilit:assign a more derived object to a less derived one.
Covariance and contravariance: implicit reference conversion for arrays, delegates and generics.
Covariance preserve assignment compatibility, while contravariance reverses it.

Ex de mai sus nu vrea sa se salveze cum trebe- https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/covariance-contravariance/
Until C# 9, return type covariance won’t work.

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

Define DIP

A

Dependency inversion principle says that we should obtain decoupling by:
- high level modules should not depend on low level modules, they should be all based on abstraction
- abstraction should not depend on details, but details should depend on abstraction

Example:
1. Use abstract classes and interfaces when calling/using an object (ex: business and data layers)
2. Never use its interface directly, but apply the Inversion control principle to make the detail rely on abstraction (factory/abstract factory, strategy, template DI, service locator)

Exemplu complet era: tightly coupled > IoC (factory) > DIP (clase abstracte + înglobează factory dinainte) > DI (ctor, method, prop) > DI/IoC Container (automated DI: register, resolve, dispose)

– https://www.tutorialsteacher.com/ioc/dependency-injection

21
Q

What are generics in C#?

A

Generic collections have added upon the simple collections, the type safety. Which means that, when initializing a generic collection, one has to specifically mention the type it’s going to be used with, leading to better performance compared to the non-generic collections, as they don’t require the hassle of boxing and un boxing.

https://www.tutorialsteacher.com/csharp/csharp-collection

22
Q

Collections in C#

A
  1. Array-based
    1.1. Array - continuous memory, type safe, fixed size
    1.2. Arraylist- can have dynamic size but is not type safe
    1.3. List-dynamic size + type safe
  2. LinkedList - efficient for insertion and deletion, because of its structure
  3. Binary-tree based
    3.1. Sorted Dictionary-does not have cont allocation in memory; takes more memory, but it has less hassle with the memory.
    3.2. SortedList- cont memory allocation; predispose to memory fragmentation…
    > both used when you frequently need the elements sorted (avoid sorting it multiple times)
  4. What about hash maps?

https://taagung.com/c-sharp-collections-implementation/amp/

23
Q

OOP Concepts

A
  1. Encapsulation - different cells express different genes. Each of them have private behaviour, they don-t have to know and access everything from its neighbour
  2. Abstraction-we know what some systems do, such as eating, but the majority of the process it’s a Blackbox, and we’re just using the final functionality
  3. Inheritance- let’s take the stem cells that differentiate into more specialized classes; they are all somehow related, and they get new behaviour as they specialize into a child class. However, the biological example wouldn’t sustain the Liskov Substitution Principle, where the child can replace the parent
  4. Polymorphism- the majority of animals have eyes and they behave similarly in the way they define their interface, in terms of interaction with the brain for example. However, human eye perceive 3 colors, while the mantis 12
24
Q

Sorting algorithms. Their efficiency

A

Quick sort- in place sorting (memory efficient)

25
Class a = new Class(); Class b = a; a = null; Does assigning null value to an object in C# free memory?
La asignare de null, se muta pointerul de la a inspre null si in mod normal memoria ocupata ar trebui sa fie enabled pentru GC. Dar fiindca b pointeaza inca inspre zona aia din heap, nu se va elibera => copierea se face shallow
26
Techniques for improving DB queries techniques
- indexing 2. Data defragmentation 2.1. Partitioning means organizing large data into smaller (dynamic fragments) by one or more columns (with small cardinality) > works best when cardinality is not high Eg: year/month 2.2. Bucketing or clustering will result in a fix number of files, because it will take the selected field (only one), create a hash and save the entry in that bucket > useful when the field has high cardinality and data is equally distributed Eg: projects in a land https://stackoverflow.com/questions/19128940/what-is-the-difference-between-partitioning-and-bucketing-a-table-in-hive
27
Lifetime of an application domain
- Singleton: creates a service only once during the app's runtime -- memory efficient but wathcout memory leaks!!! -- used when you need to maintain application's wide state - Scoped: new instance for every scope (request=scope) -- best to use, of course, when you want to maintain state within a request - transient- instance is created every time you request it -- safest but require resources & memory; best to use with lightweight services with little or no state https://www.tektutorialshub.com/asp-net-core/asp-net-core-dependency-injection-lifetime/
28
Optimistic vs pessimistic locking
Optimistic Locking is a strategy where you read a record, take note of a version number (other methods to do this involve dates, timestamps or checksums/hashes) and check that the version hasn't changed before you write the record back Pessimistic Locking is when you lock the record for your exclusive use until you have finished with it. It has much better integrity than optimistic locking but requires you to be careful with your application design to avoid Deadlocks.
29
Service locator VS dependency injection
DI e un Dumnezeu care da depend te modulelor și încheagă munca. Service locator e modulul care striga după dependințe și cineva știe sa i-o dea. Service Locator is used in the consumer and it pulls services by ID from some storage by direct consumer's request (o clasa statica cu switch-uri care returnează pe baza unui param) DI Container is located somewhere outside and it takes services from some storage and pushes them to the consumer (no matter via constructor or via method) https://jhonatantirado.wordpress.com/2012/04/24/dependency-inversion-service-locator-or-dependency-injection/
30
What is a transaction?
In short, a database transaction is a sequence of multiple operations performed on a database, and all served as a single logical unit of work — taking place wholly or not at all. In other words, there's never a case that only half of the operations are performed and the results saved
31
Lifetime of a DbContext
The lifetime of a DbContext begins when the instance is created and ends when the instance is disposed. A DbContext instance is designed to be used for a single unit-of-work. This means that the lifetime of a DbContext instance is usually very short. - A typical unit-of-work when using Entity Framework Core (EF Core) involves: Creation of a DbContext instance Tracking of entity instances by the context. Entities become tracked by Get: Being returned from a query Post: Being added or attached to the context Changes are made to the tracked entities as needed to implement the business rule SaveChanges or SaveChangesAsync is called. EF Core detects the changes made and writes them to the database. The DbContext instance is disposed - DbContext in dependency injection for ASP.NET Core In many web applications, each HTTP request corresponds to a single unit-of-work. This makes tying the context lifetime to that of the request (Scoped) a good default for web applications. ASP.NET Core applications are configured using dependency injection. EF Core can be added to this configuration using AddDbContext in the ConfigureServices method of Startup.cs.
32
Cum se face exception handling intr-un cod asincron (context de Task Parallel Library/ task-based program)?
https://hamidmosalla.com/2018/06/19/exception-handling-in-asynchronous-code/ AggregateException is used to consolidate multiple failures into a single, throwable exception object. Excepțiile dintr-un task sunt puse pe un task object, wrapped inside an Aggregate Exception si returnate thread-ului caller. How it works - When exception are thrown in a code that runs inside a task, all the exceptions are placed on the task object and returned to the calling thread. - When exceptions happen, all the exceptions are re-thrown by the calling thread. - To do that they’re wrapped inside AggregateException (care are innerException list in interior) and returned to the caller. How to catch - AWAIT: So when we await a task, we only get the first exception from a collection of exceptions that might exist on a task. In other words if multiple exceptions happen, if we await the task in a normal way, we only going to get the latest exception. When using await, it’s going to unwrap the first exception and return it, that’s why we don’t hit the catch (AggregateException e) line. - WAIT: But if we use .Wait, we catch the AggregateException- note that it’s not a good idea since we’re blocking the running thread. - WhenAll + .Exception : This way we catch the exceptions from the Exception property and assign it to a variable of type AggregateException + .exception.Flatten: Imagine a scenario when a task contains another task, the inner task throws couple of exceptions. Now the parent task throws exceptions too, in this scenario, the InnerExceptions property of the parent contains another AggregateException. In this case we can use Flatten() method to flatten all the child exceptions.
33
Cum e implementat un dictionar?
Dictionarul are in spate un array, iar pe fiecare pozitie a arrayului este un linked list continant key-value (care au avut collisions) - Cheia e transformata in integer, pe integer se aplica functile absolute si modulus (ca sa fie pozitiv si itnr-un range intre 0 si cat vrem array-ul nostru sa fie de lung) - Pe fiecare pozitie a array-ului se salveaza un linked list, care contine ca si elemente key+value https://medium.com/swlh/things-every-engineer-should-know-hashmaps-b354088206b5 https://github.com/Tyrrrz/interview-questions/blob/master/C%23/HashSet%20and%20Dictionary.md
34
In ce situatii sunt bune Linke Lists?
https://levelup.gitconnected.com/things-every-software-engineer-should-know-linked-lists-4841f75614ba
35
What is a circular array?
An array is called circular if we consider the first element as next of the last element. Circular arrays are used to implement queue (Refer to this and this). Se parseaza folosinf modulo - i%n (unde n e indexul de la care vrem sa plecam). Si cum arrayul acceseaza in O(1)...tot e O(1) dar pornim din zone diferite. An array is called circular if we consider the first element as next of the last element. Circular arrays are used to implement queue (Refer to this and this).
36
How does it verify that an element is unique?
When adding a new element to a HashSet or a new key to a Dictionary, its hash code is used to check for uniqueness. Every type in .NET inherits GetHashCode() method from System.Object which can be used to uniquely represent internal state of an object as an Int32 value. If there are two objects of the same type, their GetHashCode() must return the same value if they are equal and it should return different values if they are not equal. In other words, non-equal objects may have identical hash codes (key collisions => linked list on the same array position) If you will be trying to add an element whose hash code matches one of the elements already present in the collection, these two elements will be checked for equality using Equals() method. If the result is true, the element will not be added to the collection, and in case with Dictionary an exception will be thrown.
37
What happens if Equals()/GetHashCode() are not overridden and a custom comparer is not specified? What if the type is not immutable? Should we use dictionaries? How does Dictionary perform element lookup?
In case of struct types, their default implementation of Equals() and GetHashCode() uses reflection to compare instances and calculate hash code based on the values of declared fields. This means you can use struct types inside HashSet and Dictionary without having to implement these methods yourself. As for class types, their default implementation of Equals() uses reference comparison instead of value comparison, while GetHashCode() returns unpredictable values. This means that all instances of class types that don't override Equals() and GetHashCode() will be considered unique in regards to HashSet and Dictionary. ___________________________________________________ You shouldn't use mutable types as dictionary keys or elements in HashSet. These collection types have no way of knowing that an element's state was modified, so the stored hash code values GetHashCode() will become outdated. ________________________________________________________ Elements in a dictionary are split into a growing set of buckets according to their hash code (in an array). The implementation tries to minimize the average number of elements in a bucket. In an ideal case, each bucket contains only one element. When you attempt to get an element by its key, e.g. using TryGetValue() method, it will determine which bucket may contain this element using modulus of the hash code over the number of buckets (represents the index of the array). If the bucket exists and it contains only one element, it will simply return it; if the bucket exists but there are multiple elements in it, it will use Equals() to find the exact match for given key; if the bucket doesn't exist, the element is not present.
38
What is a thread + What does it contain + Thread Life Cycle
What it is? > A thread is defined as the execution path of a program. Each thread belongs to exactly one process and no thread can exist outside a process. Each thread represents a unique flow of control. What does it contain? > A thread contains its own program counter that keeps track of which instruction to execute next, system registers which hold its current working variables, and a stack which contains the execution history. A thread shares with its peer threads few information like code segment, data segment and open files. When one thread alters a code segment memory item, all other threads see that. Thread Life Cycle > The life cycle of a thread starts when an object of the System.Threading.Thread class is created and ends when the thread is terminated or completes execution. - The Unstarted State − It is the situation when the instance of the thread is created but the Start method is not called. - The Ready State − It is the situation when the thread is ready to run and waiting CPU cycle. - The Not Runnable State − A thread is not executable, when -- Sleep method has been called -- Wait method has been called -- Blocked by I/O operations - The Dead State − It is the situation when the thread completes execution or is aborted. - https://www.tutorialspoint.com/operating_system/os_multi_threading.htm#:~:text=Thread%20management%20is%20done%20in,run%20in%20parallel%20on%20multiprocessors. - https://www.tutorialspoint.com/csharp/csharp_multithreading.htm
39
Parallel Processing, Concurrency, and Async Programming in .NET
Concurrency is a broad concept that refers to the idea of multiple tasks executing simultaneously. This can be achieved using various techniques, such as: - [Not parallel] Time-sharing is a technique that allows multiple tasks to share a single processing unit by rapidly switching between them. From the perspective of the user, it appears as if multiple tasks are being executed simultaneously, even though each task is being executed sequentially for a short period of time. - [Not necessarily parallel] Task scheduling is a technique used to manage the execution of multiple tasks by assigning priorities to them and scheduling them for execution based on those priorities (most common thread pool- default: ThreadPoolTaskScheduler, TPL Dataflow, Asyncronous Streams...). It's possible for tasks in the ThreadPool to run on the same processing unit or on different processing units, depending on thread scheduling algorithm and the available hardware resources.) - Parallel Processing on multiple processing units is one way to achieve concurrency- concept of breaking down a task into smaller parts and executing them simultaneously across multiple processors or cores (Parallel LINQ, TPL, Threads- difficult to manually manage them, ThreadPool- automatically manages threads). When you create a task using the TPL, the task is added to the ThreadPool's queue of pending tasks. The ThreadPool manages a pool of threads (When you create a task using the TPL, the task is added to the ThreadPool's queue of pending tasks. The ThreadPool manages a pool of threads, and when a thread becomes available, it retrieves the next task from the queue and executes it. This allows multiple tasks to be executed in parallel on the available threads, without having to manage threads directly), and when a thread becomes available, it retrieves the next task from the queue and executes it. This allows multiple tasks to be executed in parallel on the available threads, without having to manage threads directly. - in async programming, tasks that involve I/O operations are executed asynchronously, which means that the calling thread can continue executing other tasks while waiting for the I/O operation to complete. ----------------------------------------------------- * I/O-bound tasks are tasks that spend most of their time waiting for input/output (I/O) operations to complete, such as reading from or writing to a disk, network communication, or user input. These tasks are typically characterized by a high degree of latency and a low degree of CPU usage. * A processor, also known as a central processing unit (CPU), is the part of a computer that performs calculations and executes instructions. It is essentially the "brain" of the computer. *A core is a processing unit within a CPU that can execute instructions independently. A CPU can have one or more cores, depending on the design of the processor. Each core can execute instructions simultaneously, which can improve performance and enable parallel processing.
40
What are the Main Types of Software Testing
Unit Testing: -The first level of testing in the software testing life cycle. It involves testing individual units or components of the software in isolation. -The objective is to verify if each unit is working as intended and meets the specified requirements. Integration Testing: -This level of testing involves testing the integration of individual units to ensure that they function as expected when combined. -The aim of integration testing is to identify any defects or inconsistencies that may arise when different units are brought together. System Testing: -It involves testing the entire system or application as a whole. -The objective of system testing is to ensure that the software application meets all the functional and non-functional requirements, performs as expected, and is free from defects. -Focuses on identifying defects or issues in the system that may arise due to the integration of different units or components. Acceptance Testing: -The final level of testing where the software application is tested in a production-like environment to ensure that it meets the requirements of stakeholders and is ready for release. -Acceptance testing can be performed by either the end-users or stakeholders themselves. Regression Testing: -Performed to ensure that changes or modifications made to the software application do not cause any unintended side effects or break existing functionality. -Focuses on identifying defects or issues that may arise due to changes in the software application. -Typically performed after a new feature is added, a defect is fixed, or a change is made to the codebase. Other types of testing can also be performed, such as performance testing, security testing, and regression testing
41
Important Jenkins concepts
Jenkins Master: The central server that manages Jenkins, responsible for configuring and orchestrating automation pipelines. The Jenkins master is responsible for coordinating and managing the execution of jobs. It receives requests to run jobs, schedules them, and distributes the workload to available agents. Jenkins Agent: Distributed execution component that performs tasks on behalf of the Jenkins master, either on the same machine or remotely. Jenkins Service: Jenkins server running in the background as a system service, ensuring availability and accessibility (on Win: a simple Windows service). Jenkins Jobs: Individual tasks or processes within Jenkins that are executed, such as builds, tests, and deployments. Jenkins Pipeline: A flexible, code-based approach to defining CI/CD workflows in Jenkins using either Declarative or Scripted syntax. Jenkins Plugins: Extensions that enhance Jenkins functionality, integrating with various tools and technologies.
42
What are middleware components
In C#, middlewares are components that can be used in the context of web applications, particularly in frameworks like ASP.NET Core. These components can process requests and responses, allowing you to add functionality to the application's request-handling pipeline. Middlewares are executed sequentially, and each middleware can perform specific tasks, such as authentication, logging, or routing. They are defined and configured in the Startup.cs file of an ASP.NET Core application. Examples of middlewares include authentication middleware (UseAuthentication), logging middleware (UseLogging), and routing middleware (UseRouting).
43
Dynamic programming (what, characteristics
What, characteristics: Dynamic Programming (DP) is a problem-solving technique that involves breaking down a complex problem into smaller overlapping subproblems (optimal substractures + overlapping). By solving and storing the solutions to these subproblems only once, DP optimizes efficiency and avoids redundant calculations Types: Memoization (Top-Down): Starts with the original problem and recursively breaks it down into smaller subproblems. Uses a memo (cache) to store solutions to avoid redundant calculations. Tabulation (Bottom-Up): Starts with the smallest subproblems and builds up to the original problem through iteration. Uses a table to store solutions, and there's no recursion involved - might be more efficient in terms if space complexity as it doesn't use recursion
44
Big O
Time Complexity (Big O Time): It describes the maximum amount of time an algorithm takes to complete, as a function of the input size. For example, O(n) indicates linear time complexity, O(n^2) indicates quadratic time complexity. Space Complexity (Big O Space): It describes the maximum amount of memory space an algorithm needs to complete, as a function of the input size. Similar to time complexity, it uses notations like O(n), O(n^2) to represent different growth rates.
45
Return types for async await
- concrete type: Task - type parameter: (used im generics) Task - void - methid implementing awaitable
46
.Net ecosystem platforms and versioning (.net framework, .net core, .net standard...)
.Net Framework - the initial implementation of .Net platform (2000-2018) .Net Core - the cross-platform, open-source version of .net framework .Net (.Net Core until version 4, then, starting with 5 it becomes .net 5 *) ASP.NET - web app framework (have versions for both.net platforms) .Net Standard - NET Standard: .NET Standard is not a runtime or framework itself; instead, it's a set of APIs that ensures compatibility across different .NET implementations. This means that libraries built with .NET Standard can be used in any .NET application, whether it's targeting .NET Framework, .NET Core, Xamarin Other .net implementations: xamarin, mono, unity (partial .net platforms) *With the release of .NET 5, Microsoft consolidated the different .NET implementations (including .NET Core, .NET Framework, and Xamarin/Mono) into a single unified platform.
47
.Net frameworks
Frameworks in .NET Core: ASP.NET Core: For web applications. Entity Framework Core: For data access. Xamarin.Forms: For cross-platform mobile apps. Blazor: For interactive web UIs. Razor Pages: For lightweight web development.
48
.Net ecosystem tools and runtime and Deployments
- .Net SDK: it provides tools for compiling code, managing dependencies, running tests, and publishing applications - .Net Runtime: includes the Common Language Runtime (CLR), which executes .NET code, as well as the Base Class Library (BCL), which provides fundamental classes and functionality FDD (Framework-Dependent Deployment): Relies on a shared system-wide .NET Core runtime. Only application-specific dependencies are deployed. SCD (Self-Contained Deployment): Includes the .NET Core runtime with the application- packaged with the application, making it independent of the target system's runtime. Pe Docker e recomandat FDD ca sa fie mai lightweight containerele, iar masina host sa aiba runtimeul.