Interview Flashcards

1
Q

Class vs Struct vs Record

A

Class is a reference type, struct is a value type, record is a reference type. The record is immutable used primarily for DTOs and one way operations. Classes can be inherited. Structs cannot be inherited.

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

Value type vs reference type

A

A value type is most commonly stored on the stack. A reference type is stored on the heap type of memory. Depends on the context the variable is declared. Local value types are stored on the stack. Objects of reference variables are stored on the heap. If the value is declared inside a class it will be on the heap.
TLDR: Value types and reference types go to a different type of memory.

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

Abstract class vs interface

A

Abstract classes can contain implemented methods and interfaces can’t. C# 8 interfaces can have default implementation. Abstract classes cannot be instantiated but can have all members of classes (props, methods, ctrs, fields)
Abstract classes are used to define a base class while interfaces are used to define an implementation. Classes can implement multiple interfaces while can inherit from only one class.

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

OOP principles

A

Encapsulation, abstraction, inheritance, polymorphism
Encapsulation - data implementation is done through public methods and enclosed in classes
Abstraction - classes don’t need to know the actual implementation of other classes they need to be based on their abstractions, abstract classes or interfaces
Inheritance - inheritance provides the ability for classes to reuse code from upper base classes. It also provides the ability to polymorphism
Polymorphism- This is the so called overloading and overriding of methods. Overloading is achieved same name, different number of parameters, overriding is achieved through overriding virtual methods.

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

Managed vs unmanaged code

A

Code that executes under the control of the runtime is managed code and is eligible for garbage collection. Unmanaged code is code that is not under control and has to be disposed of. COM components, ActiveX interfaces and Windows API functions are such examples. Unmanaged code is executed by the OS directly

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

Const vs readonly

A

Const is assigned value in compile time. Readonly is assigned value in runtime.

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

IDisposable pattern

A

Basic Dispose pattern - implementing IDisposable and in the Dispose method dispose of any resources. Because finalizing methods in unpredictable you need to check whether the Dispose method is called from Dispose(bool) or it is called from the finalizer in order to avoid disposing of something already disposed of

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

Garbage Collection

A

Background process that collects unused references and frees up memory. There are three conditions that trigger garbage collection:
Low physical memory, low memory on the heap or gc.collect

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

Garbage collection generations

A

Gen 0 - youngest objects, short lived objects
Gen 1 - short lived objects buffer to long lived objects. If the gc does not free enough memory from gen 0 objects it collects from gen 1 and then goes to gen 2.
Gen 2 - long lived objects here, static data for example that lives during the whole process.
LOH (Gen 3) - objects larger than 85 MB objects in this gen are collected with gen 2 objects

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

.NET Framework vs .NET Core / 5,6,8

A

.NET Framework is a development framework offers API development MVC etc. / .NET Core is a platform that includes ASP.NET, UWP / .NET Core is an open source platform / .NET Framework is not open source
.NET Core is cross platform it can run on all platform and supports all kind of development / NET Framework is used solely for windows development. / .NET Core is shipped as a collection of Nuget Packages / .NET Framework is installed as a single app installer
Offers scalability and performance with comparison to Framework /
Core is compatible with all operating systems /
.NET Core comes up with a very lightweight CLI, it can be used in IDE
.NET Framework is heavy on the CLI
.NET Framework has the Code Access Security

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

.NET Standard

A

.NET Standard is a set of APIs compatible with all .NET versions . If you need a portable library that’s compatible with Framework, Core and Xamarin then use the .NET Standard.

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

async and await

A

IO bound operations and CPU bound operations
Waiting for some data -> io bound operation
Expensive computation -> cpu bound operation

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

Task.WhenAll and Task.WhenAny

A

Multiple tasks return when the unwrapped results of all tasks
when any returns the

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

Blocking the current thread with Task

A

Task.Wait or Task.Result, Task.WaitAll, Task.WaitAny, Thread.Sleep

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

Task vs Thread

A

A task can have multiple processes, a thread is just a process
A Task returns a result / Tasks can be chained / Tasks propagate exceptions / Tasks are using Thread Pool threads
A Thread is a lowlevel single process

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

Concurrency vs Parallelism

A

Concurrency is running on a single CPU while Parallelism is running on multiple processors

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

Array vs List

A

Array is fixed size, List doubles its size and allocates its memory /
Arrays generally have better performance, Arrays need to have default values

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

LinkedLists

A

LinkedList is a data structure every element is chained to the previous one and the next one. LinkedLists contain members that have pointers to each other but can allocate different parts of the memory unlike arrays.

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

EF core load related entities

A

Eager loading -> include / initial query
Explicit Loading -> the related data is loaded at a later time /
context.Entry(blog).Collection( –load some prop–)

Lazy Loading -> the related data is transparently loaded when the navigation property is accessed / LazyLoading requires using a package Microsoft.EFCore.Proxies /lazy loading loads the entities only when accessed

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

Gang of Four Design Patterns

A

Creational, Structural, Behavioral patterns

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

Structural Patterns

A

Composite Pattern
- abstract root class
- implementation of “leaf” class that inherit from the root class

22
Q

Abstract Factory

A

Abstract Factory
-One class that is the abstract factory
-There are different factories that are implementation of the base abstract factory
-These implementations have public methods offering different interpretation

23
Q

FactoryMethod

A

Factory Method
-Abstract Product and Implementations of abstract product
-Abstract Creator and an implementation of the creator
-The implementation of the creator utilizes the implemented creators

24
Q

Singleton Pattern

A

single instance across the application

25
Q

Mediator Pattern

A

Abstract mediator and a concrete mediator
Abstract colleagues and concrete colleagues
Colleagues are registered in the the mediator. A typical example is a chat client. The mediator is a typical behavior pattern

26
Q

RESTFUL Services

A

The service is based on the Client-Server model.
The service uses HTTP Protocol for fetching data/resources, query execution, or any other functions.
The medium of communication between the client and server is called “Messaging”.
Resources are accessible to the service by means of URIs.
It follows the statelessness concept where the client request and response are not dependent on others and thereby provides total assurance of getting the required data.
These services also use the concept of caching to minimize the server calls for the same type of repeated requests.
These services can also use SOAP services as implementation protocol to REST architectural pattern.

27
Q

REST API best practices

A

-Define API operations in terms of HTTP methods
GET, POST, PUT, DELETE
-Conform to HTTP semantics - media types / non-binary types the types is json or xml / for binary types
-Filter and paginate data
-Support partial responses for large binary data
-Use HATEOAS / hypertext as the engine of application state
-Versioning a RESTful web API

28
Q

CLEAN architecture

A

In circles - Entities/Use Cases;Business layer /Controllers/Web Devices;DB;External

29
Q

REST API OPTIONS
REST API HEAD

A

-returns info about the api endpoints and content-type
-returns info about a resource

30
Q

SOLID

A

Single Responsibility
Open - Closed principle
Liskov substitution
Interface segregation
Dependency inversion

31
Q

Liskov substitution

A

Subclasses should be substitute for their base classes
subclasses commonly change the implementation of certain method applying more restrictive measures. This can be solved by introducing a shared interface between the classes.

32
Q

AWS EC2 instances

A

virtual machines ec2 autoscaling

33
Q

AWS Load Balancer

A

directing traffic

34
Q

AWS lambda functions

A

without any access to the underlying architecture, resources are allocated solely by aws

35
Q

git merge vs git rebase

A

rebase creates commit for every commit in the base branch

36
Q

AWS SQS and AWS SNS

A

Simple queue system, simple notification system

37
Q

Amazon ECS (Elastic container service)

A

highly scalable docker containers

38
Q

Amazon EKS (Elastic kubernetes service)

A

Docker containers but orchestrated by kubernetes

39
Q

AWS Fargate

A

containers but solely manage by AWS without access to the containers themselves

40
Q

Clustered vs non-clusted indices

A

clustered index can be only one used to sort data
non-clustered index is a structure separate from the data rows and has pointers to the actual data

41
Q

ACID SQL term

A

Atomicity Consistency Isolation and Durability
Atomicity is either everything is committed or none,
Consistency - data is consistent
Isolation every transaction runs in isolation without knowledge of other transactions
Durability - changes are saved even after system failure

42
Q

SQL Sharding

A

Sharding is a technique that splits data into separate rows and columns held on separate database server instances in order to distribute the traffic load. Each small table is called a shard. Some NoSQL products like Apache HBase or MongoDB have shards, and sharding architecture is built into NewSQL systems.

43
Q

IQueryable vs IEnumerable

A

IQueryable is used for querying the data in out memory.
IEnumerable pulls the data and then queries it in memory
IQueryable is executing a select query server side with all filters.

44
Q

Circuit Breaker Pattern

A

In usual faults in the system it is better to use the retry pattern
In other possible scenarios the circuit breaker is the exact opposite of retry.

Circuit breaker acts as a proxy for operations that might fail. The proxy should monitor the number of recent failures that have occurred and decide whether to allow the operation to proceed or simply return an exception.

The pattern has several states Closed, Open, Half -Open.
Closed is success, Open is for failures, half open gives a chance for the system to fix itself.

45
Q

Domain Driven Design

A

Ubiquitous Language - use of common language that is shared between experts and domain members
Bounded Contexts - divides large systems into distinct contexts each with its own specific model and terminology
Entities and Value Objects - Entities represent objects with unique identities, while value objects are objects that are defined by their attributes.
Aggregates - clusters of associated objects.
Domain Events - Represent meaningful state changes within the domain.

46
Q

Sagas pattern

A

Problem: Each service has its own database. Some business transactions span multiple services how to update the database

Solution: If a transaction spans multiple services. It is a saga. Sequence of local transactions. Each local transaction updates the db and publishes a message or event to trigger the next local transaction in the saga. If a local transaction fails then the saga executes a series of compensating transactions that undo the changes.

This is like compensating for ACID transactions but for microservices.

47
Q

Dictionary and HashMap how they work under the hood

A

dictionary is a collection of key value pairs
hashtable is a collection of key value pairs based on their hash value

hashtable is non-generic collection. you can have different types of key-value pairs
dictionary requires types and can store only one type
data retrieval is slower because of boxing unboxing

48
Q

Distributed Transactions

A

A transaction or a system of transactions that span over several microservices.

49
Q

HashSet

A

Stores only unique elements

50
Q

IoC vs Dependency Inversion

A

Inversion of Control (IoC): Inversion of Control is a design principle that refers to the reversal of control flow in a software system. It involves delegating the control of the flow of execution to an external component or framework, often through the use of design patterns such as the Dependency Injection pattern. In IoC, the control flow of a program is shifted from the application to a container or framework, which manages the creation and lifecycle of objects and controls their interactions. This promotes loose coupling and allows for greater flexibility and testability within the application.

Dependency Inversion: Dependency Inversion is a specific principle within the broader concept of Inversion of Control. It refers to the practice of designing software modules and components in a way that high-level modules do not depend on low-level modules directly, but both depend on abstractions. This principle encourages the use of interfaces or abstractions to define the interactions between modules, rather than concrete implementations. By depending on abstractions, the higher-level modules become independent of the lower-level implementation details, enabling easier maintenance, extensibility, and testing.