.NET Flashcards

1
Q

What is .net core?

A

An open source framework used to build applications from web applications, native applications etc. Most frequently coded using C# language which is an object orientated language that encompasses many modern programming disciplines.

static typing > compiler can do checks on types at compile type rather than run time.

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

Describe the middleware vs filters in a .net core web application?

A

Middleware operates on on every request / response. e.g Authentication or Localization middleware

MVC middleware > Filters operate at the MVC layer, authorization, action filter and have access to access routing / MVC context

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

How does routing work in .net core?

A

Conventional routing - useEndpoints - Controller/Action/id

Attribute routing - defined in the attribute

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

Authentication and authorization .net core

A

.NetCore use middleware for authentication which can be setup on startup.

Configure services add authentication such as JWT authentication, validate authority and other token parameters.
Configure method used for http requests useAuthentication

Authorization allows you to set Policies. I have used that for specific roles or they have given context.

Takes a Policy Name, define requirement, generally used a role requirement in terms of what roles are allowed etc. AuthorizationHandler then defined to handle the requirement and registers on startup. We can then access the handler context for the user ClaimsPrincipal. Essential access the custom claim to access json object with roles.

On controller / action we can define an Authorization Attribute

context.Succeed
Complete Task

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

What is Threading?

A

An analogy usually helps. You are cooking in a restaurant. An order comes in for eggs and toast.

Synchronous: you cook the eggs, then you cook the toast.
Asynchronous, single threaded: you start the eggs cooking and set a timer. You start the toast cooking, and set a timer. While they are both cooking, you clean the kitchen. When the timers go off you take the eggs off the heat and the toast out of the toaster and serve them.
Asynchronous, multithreaded: you hire two more cooks, one to cook eggs and one to cook toast. Now you have the problem of coordinating the cooks so that they do not conflict with each other in the kitchen when sharing resources. And you have to pay them.

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

What is async await?

A

Async await is the mechanism to manage long running operations / I/O or DB calls with indeterminate timeframe. The advantage of this is that it enables the state machine which allows the current thread to be freed up in order to perform another Task (single operation). This enables and supports vertical scaling in terms of maximising the resources in a given server.

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

What testing tools have you used in .net core?

A

In terms of testing frameworks I have used both nunit and mstest. In terms of mocking I have used nsubstitute and moq. AutoMoq for setting up test objects.

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

What is DI?

A

Dependency Inversion Principle (suggests a solution)

High level modules dont depend on lower level modules both depend on abstractions
Abstraction dont depend on details, details depend on abstractions

Maintainable, loose couple, testable code

IOC - Inversion of Control

IOC - is the mechanism to apply the principle that allows higher level modules to depend on abstraction rather than concrete implementations of lower level modules

Dependency Injection - design pattern to implement IOC allows you to inject low level component into your high level component

Register it, resolution at runtime and disposition lifetime

IServiceProvider > IServiceCollection

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

What are using blocks?

A

used to outline the scope of unmanaged resource to ensure its memory is freed up as soon as possible. Generally used with the IDisposable interface in order to outline how it should be disposed.

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

Abstract class vs interface

A

An abstract class allows you to create functionality that subclasses can implement or override. An interface only allows you to define functionality, not implement it.

extends is for extending a class.

implements is for implementing an interface

A big impediment to software evolution has been the fact that you couldn’t add new members to a public interface. You would break existing implementers of the interface; after all they would have no implementation for the new member!

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

What is deferred execution?

A

Deferred execution means that the evaluation of an expression is delayed until its realized value is actually required. It greatly improves performance by avoiding unnecessary execution.
It is executed when the query object is iterated over a loop.

IQueryable queries out-of-memory data stores, while IEnumerable queries in-memory data

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

Constant vs readonly

A

A const is a compile-time constant whereas readonly allows a value to be calculated at run-time and set in the constructor or field initializer. So, a ‘const’ is always constant but ‘readonly’ is read-only once it is assigned.

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

Virtual / abstract / Override

A
Abstract Method
Abstract Method resides in abstract class and it has no body.
Abstract Method must be overridden in non-abstract child class.

Virtual Method
Virtual Method can reside in abstract and non-abstract class.
It is not necessary to override virtual method in derived but it can be.
Virtual method must have body ….can be overridden by “override keyword”…..

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

what is web assembly

A

open web standards no need to recompile c# code download app assemblies, and ,net runtime.
Blazor web assembly bootstraps the .net runtime and loads the assemblies for execution

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

What is EF Core?

A

Entity Framework core is a lightweight, extensible data access technology which can serve as an ORM. This allows developers to work the entities in code rather than SQL.

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