I will divide all the answers to the questions into 3 subcategories:
π Must - Senior C # / .NET must know
π Should - Senior C # / .NET Should Know
π¨βπ« Could - it will be a plus if the Senior developer knows
πGeneral .NET questions
What are managed and unmanaged resources in. NET?
This question, you need to understand the difference and it is advisable to give examples of such resources if you remember a couple more nuances of how you will work with them in favor
π Must:
- Managed resources - are resources for which the Garbage collector is used to clean up.
- Unmanaged resources - are resources that are not cleaned up by the garbage collector and must be explicitly cleaned up after executing the code that used them, for example: working with a file, working with a database, etc.
π Should:
- Using IDisposable and using constructs to clean up unmanaged resources is the main approach for dealing with such resources.
π¨βπ« Could:
- Why use the safe System.Runtime.InteropServices.SafeHandle instead of a finalizer
- Why do we need the DisposeAsync () method that was added in C#, what it returns, and in what cases it can be useful when returning a ValueTask value
What is Garbage Collector and how does it work?
Unfortunately, few senior developers of the "new temper" read and understand this theory. As for me, this is a very important question and I recommend that you study it.
π Must:
- Garbage collection phases: mark phase, sweep phase, compact phase
- Understand why exactly 3 generations in GL, and not 2, 1, or N, and why generations are needed.
- Understanding what a Large object heap is and why you need it.
π Should:
- How can we configure the garbage collector for a specific application?
- What are the differences between garbage collection in server mode (SVR GC) and workstation mode (WKS GC)
π¨βπ« Could:
- what is the nuance of Finalize with GC, why does the Finalization queue slow down?
GC.SuppressFinalize(this), GC.Collect() methods
How do Equals work in C #?
This is a very easy question that shouldn't be difficult to learn.
π Must:
- How type comparison works via Equals () and == in Reference Type
- How the comparison of Value types via Equals works
π Should:
- Comparison using helper classes and interfaces (IEqualityComparer, IStructuralEquatable, IComparable)
π¨βπ« Could:
- Implementation rules for the Equals method and the equality operator (==). You can find the rules to follow in the study article I gave above.
The life cycle of a Value-type object
Many who did get to GC and read articles on how it works stop there. Forgetting that there are also Value types and their life cycle.
π Must:
- Scope functions, when and under what conditions the data of variables stored on the stack is cleared
- When the Value type is stored on the stack, and when in the heap.
Delegate in C #
π Must:
- Delegate
π Should:
- Multicast delegate
What is the difference between the new and override keywords when overriding a class method?
A junior question, the answer to which many seniors have forgotten.
π Must:
The override modifier extends the base class virtual method, and the new modifier hides the available base class method.
an example that gives an understanding of how it works:
namespace OverrideAndNew
{
class Program
{
static void Main(string[] args)
{
BaseClass bc = new BaseClass();
DerivedClass dc = new DerivedClass();
BaseClass bcdc = new DerivedClass();
// The following two calls do what you would expect. They call
// the methods that are defined in BaseClass.
bc.Method1();
bc.Method2();
// Output:
// Base - Method1
// Base - Method2
// The following two calls do what you would expect. They call
// the methods that are defined in DerivedClass.
dc.Method1();
dc.Method2();
// Output:
// Derived - Method1
// Derived - Method2
// The following two calls produce different results, depending
// on whether override (Method1) or new (Method2) is used.
bcdc.Method1();
bcdc.Method2();
// Output:
// Derived - Method1
// Base - Method2
}
}
class BaseClass
{
public virtual void Method1()
{
Console.WriteLine("Base - Method1");
}
public virtual void Method2()
{
Console.WriteLine("Base - Method2");
}
}
class DerivedClass : BaseClass
{
public override void Method1()
{
Console.WriteLine("Derived - Method1");
}
public new void Method2()
{
Console.WriteLine("Derived - Method2");
}
}
}
What is exception handling? Describe how you build error handling in your project and what is the best practice?
π Must:
try-catch-finally
throw ex; vs throw;
π Should:
Avoid throwing an exception where possible.
throw an exception instead of returning an error code
π¨βπ« Could:
Use .NET predefined exception types
When creating your custom exception, call the class New Exception
.NET Data Types, Collections, and Data Structures
What collections in .NET do you know, what is their difference, the speed of operations, data structures?
π Must:
Big o notation
Difference between Array, List
What's the difference between List > and Dictionary ?
What data structure does List use under the hood?
What collections can Linq be used with?
Operator yield
π Should:
ConcurrentDictionary, BlockingCollection, ConcurrentQueue, ConcurrentStack: how are they different from regular collections?
What is a LinkedList, what tasks might you need it for?
Speed of insertion, reading, searching for different types of collections such as List, LinkedList, Dictionary, HashSet, Queue, Stack, SortedDictionary, SortedList, SortedSet
Practical experience and understanding of how the following collection types work: List, LinkedList, Dictionary, HashSet, Queue, Stack, Set, ConcurrentDictionary, ConcurrentQueue, ConcurrentStack
How are the main Linq methods implemented under the hood like First, Where, Count, OrderBy, Distinct, Contains, GroupBy
π¨βπ« Could:
What is a graph, tree? Are they represented by many classes in .NET? For what tasks in practice can they be useful?
Immutable collection.
Dictionary
Very few people answer these questions in interviews, although everyone uses the Dictionary. What do you think, should the Seniors know all this π€?
π Must:
What data structure does Dictionary use under the hood?
How does Dictionary work, why is it faster than List?
What are collisions in Dictionary, how does it work with them?
π Should:
Why evenly distribute hash code values across a range of integers?
Dictionary key requirements
π¨βπ« Could:
What types of locks are there in ConcurrentDictionary?
What operations use Volatile.Read, Volatile.Write, Monitor.Enter, Monitor.Exit?
What mechanism is used to implement the Concurrency Level in ConcurrentDictionary?
βοΈ Asynchrony and concurrency in .NET
The chapter in which almost everyone swims, including myself, recommends paying special attention to the study of this aspect.
Tell us what you know about asynchrony. What are Async await constructs for and how do they work, what types of operations are best performed asynchronously?
π Must:
Which operations are better to perform synchronously and which ones are asynchronous (CPU bound vs IO bound)
ConfigureAwait (false) vs ConfigureAwait (true) vs without ConfigureAwait.
Synchronization context
When can ValueTask come in handy?
What is CancellationToken?
π Should:
What is the background and foreground thread in c#.
Do your tasks run in background or foreground mode by default? How to start the first and second types of tasks?
What does the await construct unfold by the compiler?
Our Task.Run and WaitAll all using the same thread pool? π¨βπ« Could:
Task.Factory.StartNew (action, TaskCreationOptions.LongRunning) as a way to start long-running tasks.
Why is the AsyncLocal class needed?
Tell us what you encountered and what you worked within parallel programming while developing .NET applications
π Must:
- Why is it better not to use async-await with CPU Bound, but it is possible to use
Parallel.For (), Task.Run ()?
Why is ThreadPool needed?
Understanding the mechanism of how a thread is taken from the thread pool and returned there and back
Know how Monitor works and why you need it
Understand how Semaphore and SemaphoreSlim works
Parallel.Invoke, Parallel.For, and Parallel.ForEach
π Should:
Understanding why the Interlocked class is needed and experience with it is very desirable.
Understanding how PLINQ works and its basic methods
Experience and understanding of how Concurrent collections are implemented under the hood in .NET
π¨βπ« Could:
AsyncLocal vs ThreadLocal
AsyncLock
SpinLock structure
Barrier class
PLINQ ParallelMergeOptions
Why would source.AsParallel (). Where (). ForAll (...) be preferred over Parallel.ForEach (source.AsParallel (). Where (), ...).
MapReduce
What is deadlock? How to write code to avoid possible deadlocks
π Must:
- Granular Locks (as implemented in SQL or ConcurrentDictionary)
π Should:
Use timeouts for locks, for example:
if(Monitor.TryEnter(obj, new TimeSpan(0, 0, 1))
{
try
{
body
}
finally
{
Monitor.Exit(obj);
}
}
Channel
π Should:
UnboundedChannelOptions
AllowSynchronousContinuations - Let's imagine that we wrote to a full channel. Accordingly, the operation is interrupted, the thread is released, and the continuation will be executed upon completion on a new thread from the pool. But if you enable this option, the continuation will be performed by the one who unlocks the operation, that is, in our case, the reader.
SingleReader - Indicates that one consumer will be used. Again, this allows you to get rid of some unnecessary synchronization;
SingleWriter is the same, only for the writer;
BoundedChannelOptions
AllowSynchronousContinuations - same as UnboundedChannelOptions
SingleReader - same as UnboundedChannelOptions
SingleWriter - same as UnboundedChannelOptions
Capacity - the number of records that can be accommodated in the channel. This
- parameter is also a constructor parameter;
FullMode
Wait - waits for free space to complete the asynchronous operation
DropNewest - the item being written overwrites the newest one, ends synchronously
DropOldest - the item being written overwrites the oldest existing item ends synchronously
DropWrite - the item being written is not written, ends synchronously
π¨βπ« Could:
ChannelReader and ChannelWriter Properties and Methods
What is the difference between Channel and ConcurrentQueue?
Channel is not Enumerable
Channel has no Peak method
π€Έ Patterns
"I love" when they begin to ask all the patterns at social welfare, what is their number and what each means, and the book definitions. It seems to be a more correct approach to ask what patterns and in what cases the developer most often used in practice, what tasks these patterns solve. Nonetheless, let's discuss below what a senior C# developer needs to know from patterns.
Tell us what principles and anti-patterns in programming you know
Principles and anti-patterns are perhaps even more important than patterns π€ͺ
π Must:
Senior .NET must know all SOLID principles
Donβt Repeat Yourself (DRY)
Keep It Simple, Stupid! (KISS)
You Ain't Gonna Need It (YAGNI)
π Should:
All GRASP principles
All antipatterns from the article above
π¨βπ« Could:
Release Equivalence Principle (REP)
Common Closure Principle (CCP)
Common Reuse Principle (CRP)
Acyclic Dependencies Principle (ADP)
Stable Dependencies Principle (SDP)
Stable Abstractions Principle (SAP)
What design patterns do you know and use in practice?
Yes, although I don't like asking all the patterns from the signor, he should know them, so that on planning or when communicating with colleagues, a bridge, a proxy or a strategy would immediately bring up a picture of the pattern in his head and why is it needed.
π Must:
Senior must know all GoF patterns and what categories they are divided into (generative patterns, structural patterns, behavioral patterns)
Why use patterns, what does it give us?
π Should:
- Senior should be able to explain GoF patterns in simple terms, better even with real-life examples.
π¨βπ« Could:
- .NET Specification Design Pattern
What architectural patterns do you know?
Senior is already very close to the Solution Architect role, so it is important to already know and understand the pros and cons of architectural patterns.
π Must:
SOA vs Microservices
MVC
MVVM
Client-server pattern
Broker pattern
π Should:
Layered pattern
Event-bus pattern
Master-slave pattern
π¨βπ« Could:
DDD
PoEAA patterns
Pipe-filter pattern
CQRS & EventSourcing
Peer-to-peer pattern
Interpreter pattern
What deployment patterns do you know?
An optional question, that's why there is no must section, but I believe that senior should be able to set up pipelines and deploy code, and therefore should know what deployment patterns are.
π Should:
Rolling Deployment
Canary Deployment
Blue/Green Deployment
π¨βπ« Could:
Multi-region deployment pattern
Multi-tenant deployment pattern
Dark Launches and Feature Toggles
π¦ Databases
SQL Where can .NET developer and without SQL π
What is CTE in SQL, what use-cases for CTE do you know?
π Must:
Common Table Expression - Common table expressions, also called WITH constructs. In fact, this is the creation of temporary tables, but existing only for one query, and not for the session.
CTE can be used for recursive calls
π Should:
Materialization of expressions when using CTE (pros, cons)
What is the difference between View and CTE?
What is the difference between WHERE and HAVING in SQL?
π Must:
- WHERE is used by the engine at the time of selection, while HAVING works with grouped rows. For example, if we need to select users where the minimum value after grouping is 3, we need to use HAVING, if we need to filter out users whose column value is equal to or more / less than something, then we will use WHERE
SQL Transactions
I advise you to study this issue in more detail, it will be very useful in practice, even if you use ORM.
π Must:
Know this ACID and CAP.
Concurrency issues using transactions and transaction isolation levels in SQL Server (READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SNAPSHOT | SERIALIZABLE).
What is the difference between Optimistic and pessimistic lock?
π Should:
- Commands: COMMIT, ROLLBACK, SAVEPOINT, SET TRANSACTION EF Core transaction initialization (explicit/implicit)
π¨βπ« Could:
- DISTRIBUTED TRANSACTION vs TRANSACTION
Scaling SQL databases
If you have not had any problems with scaling on the project, check his pulse, he may be dead β°οΈ
π Must:
Sharding
Vertical scaling
π Should:
- Using the approach of dividing the database into Leader & Follower (master-slave)
π¨βπ« Could:
Shard proxy
Cluster proxy
Indexes in SQL
Where without indices, not a single social security office passes without such questions π
π Must:
Understand the difference between clustered and non-clustered indexes
Nonclustered Indexes: Composite Index, Unique Index, and Covering Index
π Should:
Understand how an index makes searching easier
What are the disadvantages of indexes
π¨βπ« Could:
What is the fill factor in the index, why is it needed?
What is the difference between a clustered index and a covering index, provided that
- we have added all the table columns to it?
Database normalization
π Must:
Why do you need database normalization
1-3 normal DB forms
Why and when do you need to denormalize the base?
π Should:
Boyce-Codd normal form 4-6 normal DB forms
4-6 normal DB forms
SQL Full-text search
An undeservedly neglected index, I think this is one of the first indexes to learn.
π Should:
Full-text index
CONTAINS/CONTAINSTABLE
FREETEXT/FREETEXTTABLE
π¨βπ« Could:
Understanding what the full-text index looks like and where is stored in memory
Full-text batching issues
Full-text index Master merge issue
How to use Full-text search in Entity Framework Core?
functions (OVER)
π Must:
- functions do not change the selection, but only add some additional information about it. We can say that SQL first executes the entire query (except for sorting and limit), and only then calculates the window values. This is how it differs from GROUP BY, which groups data by reducing the number of rows.
π Should:
PARTITION BY
ORDER BY
π¨βπ« Could:
- ROWS/RANGE
Stored procedure / function / temporary tables
π Must:
- Understand the difference between a temporary table and a table variable
π Should:
- Understand the difference between a stored procedure and a function
π¨βπ« Could:
Temp table types:
Table variables (DECLARE @t TABLE) are visible only to the connection that creates it and are deleted when the batch or stored procedure ends.
Local temporary tables (CREATE TABLE #t) are visible only to the connection that creates it and are deleted when the connection is closed.
Global temporary tables (CREATE TABLE ## t) are visible to everyone and are removed when all connections that refer to them are closed.
Tempdb permanent tables (USE tempdb CREATE TABLE t) are visible to everyone and are deleted when the server is restarted.
What types of JOINs do you know?
Table scan, index scan and index seek
π Must:
Table Scan - scan all table rows. Does not apply if the table has a clustered index
Clustered Index Scan - scan of all rows of a table (the clustered index is a table, not a copy of the table data) Scanning can be ordered, i.e. in the order of the index key, or unordered - in the order of the index pages in the database.
Index Scan is the same as Clustered Index Scan, only the non-clustered index is scanned.
(Clustered) Index Seek - Search the index by key. It can be the point, i.e. one line is searched. And a range of keys can be scanned - the so-called Range Scan.
NoSQL
What types of NoSQL databases are there? What NoSQL databases do you know?
π Should:
Types of NoSql databases:
Wide Column Stores/Column Family databases:
Document Store
Key Value / Tuple Store
Graph Databases
Multimodel Databases
Object Databases
Grid & Cloud Database
XML Databases
Multidimensional Databases
Multivalue Databases
π¨βπ« Could:
Wide Column Stores/Column Family databases:
Hadoop / HBase
Cassandra
Amazon SimpleDB
Document Store
MongoDB
Elastic Search
RavenDB Key Value / Tuple Store
Amazon DynamoDB
Azure Table storage
Redis
Aerospike
Oracle NoSQL Database
Graph Databases
Neo4J
Infinite Graph
Dgraph
Apache Giraph
Trinity
BrightstarDB
Multimodel Databases
ArangoDB
OrientDB
- Object Databases
Versant
db4o
Objectivity
HSS Database
Grid & Cloud Databases
Oracle Coherence
GridGain
GemFire
XML Databases
eXist
BaseX
Sedna
Multidimensional Databases
globalsdb
Intersystems Cache
MiniM DB
DaggerDB
Multivalue Databases
U2
TigerLogic PICK
Reality
What are the advantages and disadvantages of NoSQL
π Must:
Lack of schema. When designing a SQL database, we define the storage architecture, this will allow us to look at the system from a bird's eye view, there are no clear schemes in NoSQL, which means that no one guarantees that every developer will not change the "storage architecture" as he pleases.
The ability to store large amounts of unstructured information.
Better scaling compared to SQL DB (peer-to-peer, master-slave, shards support)
π Should:
Many NoSQL solutions have limited functionality because they solve certain problems. Therefore, working with such databases does not require deep knowledge of SQL queries. This greatly lowers the entry threshold for getting started with NoSQL storage.
The simpler query technologies in NoSQL allow you to make fewer mistakes.
Weak support for transactions at the database level (MongoDB, for example, since 4.0 already supports transactions)
π¨βπ« Could:
As one of the drawbacks: binding to a specific NoSQL database, when using SQL, you can switch to another SQL database-less painfully, and in NoSQL, it will be much more difficult (if you do not use an ORM that builds all queries for you and supports several NoSQL databases.
NoSQL transactions, how to maintain database integrity, and what is eventual consistency?
Speed of writing and reading in NoSQL compared to SQL database.
What types of indexes in MongoDB do you know?
π Must:
Single Field Indexes
Multikey Index - is an index that is created for an array field and is used to index the content stored in the array.
Text Index
Wildcard Index
π Should:
Hashed Indexes
Index properties: TTL index, unique index, partial index,
π¨βπ« Could:
Geospatial index (2dsphere Index, 2d Indexes)
Hidden Indices
Sparse Indexes
Transactions in MongoDB
π Should:
Transactions and Read Concern: local, majority, snapshot
Transactions and Write Concern: w: 1, w: "majority"
What does ObjectID in MongoDB consist of?
An example of how ObjectID looks like: 507f1f77bcf86cd799439011
π¨βπ« Could:
4-byte timestamp value
5-byte random value
3-byte incrementing counter, initialized with a random value
What is GridFS in Mongo?
GridFS is used to store and retrieve files that are over 16 MB, such as images, video files, and audio files. By default, it uses two collections fs.files and fs.chunks.
π¨ ORM
Who are you without ORM? And with ORM, you are a senior, an expert on SQL, indexes, database inheritance, and building complex queries (irony).
What is ORM?
π Must:
- Object-relational mapping (ORM) is a technology that allows you to query and process data from a database using an object-oriented paradigm.
π Should:
- Using an ORM solves the βinconsistencyβ paradigm problem, which states that object and relational models don't work well together. Relational databases represent data in a tabular format, while object-oriented languages represent it as a linked graph of objects.
What are the advantages of ORM?
π Must:
Working with a DBMS in an object-oriented style.
DRY: Through the ORM, the model is easier to update, maintain, and reuse.
A lot of functionality is available from the "box", as opposed to writing requests with your hand.
π Should:
In most cases, you don't need to write SQL queries.
ORM is very well suited for OOP languages.
What are the disadvantages of ORM and when is it better not to use it?
π Must:
It is more difficult to trace errors and SQL queries themselves than direct procedure calls.
Potentially, the ORM may not generate SQL queries optimally, which will affect query performance.
π Should:
ORM is often slower than SQL Stored Procedures or even direct queries to the database.
The entry threshold may be higher if the project uses an unpopular ORM.
When you don't have any 1-to-1, 1-to-many, or many-to-many relationships, it doesn't make much sense to use an ORM.
If your database will have stored procedures as an interface, there isn't much point in using an ORM.
What is the difference between IQueryable and IEnumerable when working with Entity Framework?
π Must:
- The main difference between these interfaces is that IEnumerable works with the entire data array, while IQueryable works with the filtered one. IEnumerable takes all server-side data and loads it into memory and then lets you filter on the data from memory. When a database query is made, IQueryable executes the query on the server-side and applies it to filter in the query.
π Should:
IEnumerable is good for working with data in memory (lists, arrays).
IQueryable works better with database queries.
IQueryable supports arbitrary queries (using CreateQuery and the Execute method). IEnumerable does not support arbitrary queries.
π¨βπ« Could:
IQueryable supports Lazy Evaluation.
Extension methods that work with IQueryable accept expression tree objects.
Extension methods that work with IEnumerable accept functional objects.
What is the difference between Eager loading and Lazy Loading in EF?
π Must:
Eager loading allows you to specify in the request which related data to load when the request is executed. EF will translate Include () to JOIN, so only 1 database query will be executed.
Lazy loading assumes the implicit automatic loading of related data when accessing the navigation property.
Lazy Loading can slow down a lot under certain conditions. Also, cause n + 1 problems when trying to execute additional queries.
What components of the Entity Framework architecture do you know?
π Must:
Entity Data Model
LINQ to Entities
Entity SQL
Object Service
Entity Client data provider
ADO.Net Data Provider
What does the Entity Data Model (EDM) consist of?
I can't say that this is a must-have question, but if you ask and the person answers, it means that you have deeply studied the question)
π¨βπ« Could:
Conceptual Model
Mapping
Storage Model
What are the 3 approaches for organizing the interaction of Entity Framework with the database?
π Must:
Code-First
Model-First
Database-First
Which Entity States are supported in the Entity Framework?
π Should:
Added
Deleted
Modified
UnChanged
Detached
What is migration and how to accomplish it in Entity Framework?
π Must:
Migration allows you to make changes to the database as the models and data context change. It automatically updates the database schema when your model changes, without losing existing data or other database objects.
There are two types of migrations: automatic migration, and code-based migration.
How can you handle concurrency issues in Entity Framework?
π¨βπ« Could:
This can be done by enabling optimistic locking with the following code:
modelBuilder.Entity<Author>().Property(a => a.RowVersion).IsConcurrencyToken() .ValueGeneratedOnAddOrUpdate();
What are the types of inheritance in Entity Framework?
π Should:
- Entity Framework inheritance is similar to class inheritance in C #. In Entity Framework, you can map the inheritance hierarchy to one or more database tables depending on your needs.
EF supports three types of inheritance:
Table-per-Hierarchy (TPH)
Table-per-Type (TPT)
Table-per-Concrete-Type (TPC) (not supported in EF Core)
Does EF Core support transactions?
π Must:
- Each time you call SaveChanges () to insert, update, or delete data in the database, this operation is wrapped in a transaction. This way you don't need to open transactions explicitly.
π Should:
You can also wrap a block of code in a transaction using the using var transaction = context.Database.BeginTransaction (); To commit a transaction, then you need to execute a transaction.Commit ();
How to execute a transaction for multiple contexts
π¨βπ« Could:
What are Savepoints and how do I use them in EF Core?
What are external DbTransactions?
π¬ Messaging
What is AMQP?
π Should:
Know what is the difference between Queue and Topic
What are Exchanges in AMQP
π¨βπ« Could:
Exchanges types (Direct, Fanout, Topic, Headers, System) and why are they needed?
Lifecycle (Connections, Subscriptions, Queues, Exchanges)
What is Azure Service Bus, what is the difference between Service Bus and regular Queue?
π Must:
A service Bus is a message bus.
Service Bus supports Queue, topic, and Dead-letter queue. Unlike a regular queue which does not contain this
π Should:
- What is the difference between ReceiveAndDelete and PeekLock?
What is the difference between Kafka and Service Bus or another message broker
Although Kafka is used as a messaging system, it does not have the concept of queues, it is called a commit log.
π Must:
Kafka - This is a distributed commit log as a cluster of nodes is deployed there, both for resilience and scalability.
Replicated because messages are usually replicated across multiple nodes (servers).
The commit log because messages are stored in segmented, append-only logs called topics. This concept is unique to Kafka.
π Should:
- Each Kafka partition provides a file. Which guarantees the order of messages within one partition.
π¨βπ« Could:
What tasks will Kafka solve? how would you choose which to use, Kafka or Service Bus?
How do I send large messages using Kafka?
ποΈ Microservices
What methods of communication between microservices do you know?
π Must:
HTTP call
Message Broker (AMQP)
π Should:
SignalR (Web sockets)
gRPC
π¨βπ« Could:
MQTT β Message Queue Telemetry Transport
STOMP β Simple Text Oriented Messaging Protocol Service Mesh
How to implement atomicity of a transaction between multiple microservices?
π Must:
Saga pattern + eventual consistency
MassTransit + Saga
π Should:
- Correlation id + ensuring atomicity using a message broker. Essentially a kind of self-written saga.
What patterns for microservices do you know?
π Must:
Circuit Breaker
Saga pattern
Sidecar
Database per Service
π Should:
CQRS & EventSourcing
DDD
Shared Database per Service
Proxy pattern
Chain of Responsibility
π¨βπ« Could:
Strangler Pattern
Bulkhead Pattern
API Gateway
Branch Pattern (Mix from Aggregator and Chain patterns)
External Configuration
Service Discovery Pattern
How to provide security for microservices?
π Should:
API Gateways
Service discovery and restricting access to services
OAuth
What methods of hosting microservices do you know?
π Should:
Docker + k8s
Azure API Management
π¨βπ« Could:
Docker swarm
Rancher
Azure Service Fabric
π§ͺ Testing
What Test Frameworks do you know and use in practice?
π Must:
MSTest
NUnit
xUnit
What helper libraries do you know and use to write tests?
π Must:
FluentAssertions
Moq
NSubstitute
π Should:
BDDfy
Selenium / Atata
WebApplicationFactory
TestServer
π¨βπ« Could:
Machine.Specifications
SpecFlow
Shouldly
Respawn
FsCheck
Verify
Bogus
What is the difference between Integration and Unit tests?
π Must:
- During integration tests, we use real system modules (database, service, etc.), and not a "mock" version.
π Should:
- The integration test shows which specific functionality does not work (registration, purchase of goods, etc.), but it will not show the specific location of the module where the problem is. A unit test will help with this, so it is important to have good coverage with unit tests, but in the case when the system is large and there is no time to cover everything, integration tests can be an option until everything is covered by the unit tests.
What is the difference between Dummy, Fake, Stubs, Spies, Mocks objects?
π Must:
Dummy - are objects that are passed to methods but are not used. These are the parameters of the methods (unless, of course, they do not affect what we want to check in the test). Sometimes it's just NULL
Fake - objects that have an internal implementation, but usually it is very stripped down and cannot be used in production. A memory database is a good example of a Fake object.
Stubs - provide standard responses to calls made during a test, usually not answering anything other than what is programmed for the test.
Spies - are Stubs that also record some information depending on how they were called. One form of this could be an email service that records how many messages have been sent.
Mocks - are objects pre-programmed with expectations that form a specification of the calls they expect to receive. Expectations are checked through calls to the Mock object.
π§ Networking and protocols
TCP/IP
π¨βπ« Could:
- It is enough to read an article from the resources to study and at a basic level understand how TCP / IP works.
HTTP
π Must:
HTTP message structure
List of HTTP status code classes. What is each of the classes used for (1xx, 2xx, 3xx, 4xx, 5xx)
Methods GET, POST, PUT, DELETE, OPTIONS
π Should:
Methods: HEAD, PATH
If HTTP is stateless, how are there ways to exchange messages that the server can use to identify the user? (Token, Cookies)
π¨βπ« Could:
- Methods: CONNECT, TRACE
WebSockets
What are the features of web sockets?
π Should:
The web socket provides two-way communication over a single TCP connection.
It enables Read-Time communication between web servers and clients
What are the main Web Socket API events?
π Must:
Open
Close
Error
Message
What are short polling and long polling?
π¨βπ« Could:
- Short polling is a technique where the client checks the server again, for example, every 500ms.
Long polling - the server receives a request but does not respond to it until it receives new data from another request. How does it work?
The request is sent to the server.
The server does not close the connection until it has a response message.
When a message appears, the server responds to the request by sending a response.
The browser makes a new request immediately.
What is HATEOAS, what is its main idea?
π Should:
The REST client accesses a fixed URL and gets a list of possible resource actions.
HATEOAS allows clients and servers to develop independently. The client does not need to know in advance the types of resources and the mechanisms of interaction with him through the server.
What is CORS?
π Must:
Cross-Origin Resource Sharing (CORS) is a mechanism that uses additional HTTP headers to enable a user agent to obtain permissions to access selected resources from a server on a source (domain) other than what the site is currently using.
To initiate a Cross-origin request, the client's browser adds an Origin request (the domain of the site from which the request is made) to the HTTP request. For example, the page a.com/page.html tries to get data from the page b.com/cors.txt.
π Should:
The browser is responsible for checking CORS headers. It is he who rejects the request if it has not passed the CORS policy.
Policies are checked using an OPTIONS request.
HTTP cache
What types of HTTP caches do you know?
πMust:
Private cache
Public cache
Shared cache
What is ETag?
π Should:
ETag is an identifier, the value of which directly depends on the state of the resource loaded by the client.
The server can use ETag as a cache identifier to understand whether new data needs to be sent to the client or a 304 code can be returned.
How to use HTTP-based Action Cache in ASP.NET Core?
π Must:
- Using the ResponseCacheAttribute
π Should:
- You can also use the Response Caching Middleware
Load Balancer
What is Load Balancer?
π Must:
- The load balancer accepts incoming network traffic from the client. Based on some criteria for this traffic, sends these messages to one or several backend servers
π Should:
- The load balancer can operate on 3 x OSI layers: application, transport, network.
What load balancing algorithms do you know?
π Should:
Round Robin
Least Connections
Sticky Sessions
Client-side random load balancing
π¨βπ« Could:
Weighted Round Robin
Weighted Response Time
Improved Least Connections (Locality-Based Least Connection Scheduling and Locality-Based Least Connection Scheduling with Replication Scheduling)
Destination Hash Scheduling and Source Hash Scheduling
Fixed Weighting
What is the difference between Load Balancer L4 and L7?
π Must:
- Layer 4 balancers communicate at the OSI transport layer. And the 7th, respectively, at the OSI application layer
π Should:
Layer 4 Load Balancing
Plus:
Ideal for simple packet-level load balancing.
Since it does not account for data, it is fast and efficient.
More secure because packages cannot be read. In the event of a hack, no one will see the data.
Uses NAT
Supports only one connection between client and server with NAT, so your load balancer can handle the maximum number of TCP connections.
Minus:
Doesn't support content-based load balancing
Should be sticky. Once the connection is established, it goes to one backend server. All packets arriving on this connection are sent to one server. The next connection will then select a different server based on the algorithm.
Layer 7 Load Balancer
Plus:
Offers smart URL based routing
Provides caching
Physical protocol HTTP (HTTP / 1 or HTTP / 2).
Logical HTTP protocol (headers, body data, and trailers).
Messaging protocol (gRPC, REST, etc.).
Minus:
More expensive
Traffic decryption required
As far as security is concerned, you should share your certificate with load balancers. If an attacker gains access to the load balancer, they automatically gain access to all of your data.
Its proxy creates multiple connections - client proxy/proxy - so you are limited to the maximum TCP connection on your load balancer.
REST
What are the requirements for a RESTful service?
π Must:
Client-server architecture
Stateless
Caching
Uniform interface
Layered system
π Should:
- Richardson Maturity Model
π¨βπ« Could:
- Just as intriguingly as the term REST came into being, one of the creators of HTTP, Roy Fielding, described it in his dissertation.
What HTTP methods are used in REST?
π Must:
GET Requests a resource at the request URL. Can be cached locally or on the server.
POST: used to create a resource
PUT: updates by resource URL
DELETE: deletes a resource at the resource URL
OPTIONS: Indicates which methods are supported.
HEAD: Returns meta-information for a request URL.
What RPC protocol implementations do you know?
π¨βπ« Could:
gRPC
JSON-RPC
OAuth2
What is OAuth?
π Must:
- OAuth (Open Authorization) is an open standard for token-based authentication and authorization. OAuth allows third-party services such as Facebook to use the end user's account information without revealing the user's password.
What is a JWT token?
JSON Web Token, bearer token, access token whatever they call it π
π Must:
- JWT token consists of three parts: Header, Payload, Signature. They are separated by a dot.
π Should:
Header - a JSON object that contains information about the type of token and its encryption algorithm
Payload - is a JSON object that contains the data needed to authorize a user
Signature - is a string that is created using secret, Header, and Payload. This line is used to verify the token
How to invalidate JWT token in ASP.NET?
There is no magic method since the algorithm itself is built out of the box on the principles of stateless, therefore, there is no way to check and do this, but of course, there are hacks, which we will talk about below π
π Must:
If we are hacked or we urgently need to invalidate the user's tokens, we can change the secret that validates the tokens, this guarantees that the old tokens will stop working for all users.
Refresh token + short token lifetime. This method will also allow you to manage this process and add checks at the refresh token stage for certain users.
π Should:
- A more clumsy way is to hang up a global filter that will check specific users for a criterion and filter them out.
Web servers
What web servers does ASP.NET Core support by default?
π Must:
Kestrel server
HTTP.sys
IIS
Kestrel vs. HTTP.sys
π Should:
Kestrel has the following advantages over HTTP.sys:
Better performance and memory usage.
Cross-platform.
Flexibility, it is designed and patched regardless of OS.
Software port and TLS configuration
Extensibility allowing the use of protocols such as PPv2 and alternative transports.
HTTP.Sys works as a shared kernel mode with the following features that Kestrel does not have:
Port sharing
Kernel-mode windows authentication. Kestrel only supports user mode authentication.
Fast proxying via queue transfer
Direct file transfer
Response caching
π ASP.NET Core
So I can see your reaction: well, finally, at the end of the article, let's talk about C # interview questions π
What is middleware in ASP.NET Core?
π Must:
In ASP.NET Core, middleware is C # classes that can handle HTTP requests and responses. middleware can:
Handle an incoming HTTP request by generating an HTTP response.
Process the HTTP request, change it, and pass another middleware for processing.
Process the outgoing HTTP response, modify it, and pass it either to another middleware or to an ASP.NET Core web server.
π Should:
middleware can be divided into the following types:
Content-Generating Middleware - To send a response right inside the middleware. Such middleware never goes to the next one in the chain.
Short-Circuiting Middleware - this is how middleware is called, which does not always move to the next Middleware, but, according to some condition, return the answer directly inside itself.
Request-Editing Middleware - this is the name of the middleware in which we need to edit the request.
Response-Editing Middleware - this is the name of the middleware in which we need to edit the response.
What is the difference between app.Use and app.Run when adding middleware?
π Must:
app.Use allows you to call the following middleware in the pipeline
app.Run does not call the next middleware in the list
π Should:
- app.Run also does not accept the next parameter.
What is SignalR, how does it work?
π Must:
- SignalR is an abstraction over a connection. This gives you two programming models over this connection (hubs and persistent connections)
π Should:
SignalR has several built-in "transports":
WebSockets
Server-Sent Events
Forever Frame
Long polling
π¨βπ« Could:
WebSocket is the only transport that establishes a true two-way persistent connection between client and server. However, WebSocket is only supported by IIS 8 or higher, and modern versions of Internet Explorer, Google Chrome, and Mozilla Firefox.
While Server-Sent Events, Forever Frame, and Long polling, all three work on a one-way connection and are supported by most browsers.
What is Attribute routing in ASP.NET Core?
π Must:
- Attribute routes are applied to controllers and actions directly, rather than being specified globally. An example of attribute routing is: [Route("Accounts/{id}")] public ActionResult GetAccount(int id) { β¦ }
What is the difference between ConfigureServices and Configure in ASP.NET Core
π Must:
ConfigureServices - we use it when we need to add services and use them through the integrated DI, as an example, we can add EntityFramework to ConfigureServices and use it later inject through the constructor.
Configure - we use middleware to configure. In essence, we are managing the HTTP request pipeline inside the configure method.
What is wwwoot?
π Must:
- In ASP.NET Core all static resources like CSS, JavaScript, images are stored in the wwwroot folder
π Should:
The name of this folder can be changed using UseWebRoot, for example:
public static void Main(string[] args) { var host = new WebHostBuilder() .UseKestrel() .UseWebRoot("CustomFolderName") .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup<MyStartup>() .Build(); host.Run(); }
What is the difference between services.AddTransient, service.AddScoped and service.AddSingleton in ASP.NET Core Embedded DI?
π Must:
Transient: Each time the service is accessed, a new service object is created. That is, if within one request you have several calls to the service, it will be created several times
Scoped: a separate service object is created for each request. That is, if during one request there are several calls to the same service, then the same service object will be used for all these calls.
Singleton: a service object is created the first time it is accessed, all subsequent requests use the same previously created service object
π Should:
Dependency injection anti-patterns:
Control freak
Bastard injection
Constrained Construction
Service Locator
How do I write an integration test in ASP.NET Core?
π Must:
- The TestServer class is suitable for this.
What types of filters are there in ASP.NET Core?
π Must:
Authorization Filters: These are primarily used to determine if a user is authorized to complete a request. These filters can shorten pipeline execution if the request is not authorized.
Resource filters: run after authorization filters. Its OnResourceExecuting () method runs before all other filters and before model binding, and its OnResourceExecuted () method runs after all other filters.
Action Filters: Applies only to controller actions, runs after the resource filter, both before and after the controller method is executed
RazorPages Filters: Applies only to RazorPages, executed before and after the request is processed by the Razor Page
Exception filters: define actions on unhandled exceptions
Action Result Filters: The filter is applied to the results of controller methods and Razor Pages, both before and after the result is received
Cloud platforms
π Should:
Experience with one of the clouds:
Azure
AWS
Google cloud
Understanding what is the difference between:
Software as a Service (SaaS)
Platform as a Service (PaaS)
Infrastructure as a Service (IaaS)
π¨βπ« Could:
Terraform
CloudFormation
GIT
What Branching strategies do you know and use in practice?
π Must:
Git Flow (Feature Based Development)
GitHub Flow
GitLab Flow
Trunk Based Development (TBD)
Git commands
π Should:
Difference between git fetch and git pull
Fast-forward (--ff) vs No-fast-forward (--no-ff)
git merge vs git rebase
cherry-pick command
πΆ Continuous Integration & Continuous delivery & Continuous deployment
What is the difference between Continuous Integration, Continuous Delivery, and Continuous deployment
π Must:
Continuous integration
Developers who practice continuous integration merge their changes with the main branch as often as possible. The changes made by the developer are validated by creating a build and running automated tests for the build. This way, you avoid integration problems that may arise while waiting for the release date.
Continuous integration places a lot of emphasis on test automation to ensure that the application is not broken when new commits are merged into the mainstream.
Continuous delivery
Continuous delivery is a Continuous integration extension because it automatically deploys all code changes to test and/or sales env after the build phase.
This means that in addition to automated testing, you have an automated release, and you can release the application at any time by clicking a button.
Continuous deployment
Continuous deployment is another stage of evolution after Continuous delivery. Thanks to this practice, every change that goes through all stages of your production pipeline are released to your customers. There is no intervention from any of the team members, and only a failed test will prevent the introduction of a new change in production.
Continuous deployment is a great way to speed up your customer feedback loop and take the pressure off your team as there is no longer a release date. Developers can focus on development, and they see their work going live a few minutes after it's finished.
Experience with one of the CI servers:
π¨βπ« Could:
GitHub Actions
Azure Pipelines
TeamCity
Space
Travis CI
Circle CI
What are the factors of successfully built continuous integration on a project?
π Should:
Maintain the repository
Build automation
Self-testing assemblies
Everyone commits to the baseline every day
Every commit to master must be brought down
Builds must be fast
Testing on a copy of the production environment
Everyone can see the results of the last build
Automated deployment
We can also add other additional questions we need to know
Can a singleton object depend on a scoped/per-request object?
Is making DbContext a singleton in a web application a good idea?
How do you implement a method that can create a deep copy of any object?
What are the pros and cons of the immutability of strings?
How to implement the Singleton pattern in two lines of code?
How to implement custom HashSet data structure?
Can you wrap asynchronous code in a lock statement?