Showing posts with label Answers: What .NET Developers ought to know start in 2017. Show all posts
Showing posts with label Answers: What .NET Developers ought to know start in 2017. Show all posts

Monday, 7 May 2018

What are Portable Class Libraries?

Purpose:
  • This is a reasonable test to see if someone has any experience with the older strategies of portability in the .NET framework.
  • This perhaps does not not tell you much about a candidate since they could simply never have had a need to play with portability. But it is a good sign if someone has some experience in this domain.

Potential Answer:
PCLs allow for code sharing across platforms. They became very well known with frameworks like Xamarin and Silverlight originally. Although PCLs are supported in the .Net development environment, the defacto position at this stage of the game is that developers should support netstandard instead. The .NET Platform Standard is an evolution of PCLs and represents binary portability across platforms.

What are the 'async' and 'await' keywords for?

Purpose:
  • This question tests whether a developer has worked with multi threading. This is usually a good indicator for experience that a developer has written applications more complicated that run of the mill.

Potential Answers:
Async and await are language keywords that generate intermediate language that will free up the current thread for long running awaited calls. This is typically used for scenarios where a thread may make out of process calls and may be tied waiting for a response for example when you call a database or a service. Modern infrastructure is multi cored and this allows for more effective utilization of computing resources improving overall system performance.

Shared Framework vs. Self Contained Apps

Purpose:
  • This tests whether a developer has had exposure to .NET Core and has kept abreast with the latest developments.
  • It is also an indicator of whether the developer has any containerization experience.

Potential Answer:
Containerization has largely driven the entire need for .NET Core. AS such there are two models that are supported by the framework. The shared framework model is when mutliple apps on the same machine share the same installation of the framework that by default resides at 'c:\Program Files\dotnet'. Alternatively your app can be self contained with its own copy of the .NET core framework.

Where is .NET on disk?

Purpose:
  • Basic question that implicitly tests whether someone has had to grapple with .Net versions incongruities in environments.
  • Bonus points if the person knows that Net Core is located somewhere else and mentions self contained applications

Potential Answer:
.NET Framework = C:\Windows\Microsoft.NET 
.NET Core = C:\Program Files\dotnet

For .Net Core there are two ways to deploy, FDD (Framework-dependent) and SCD (Self-contained). 

SCD will resul in larger exe and means that it is your job to keep the .Net version up to date and to specify the plarforms that you target.

Thursday, 3 May 2018

What is JIT compilation?

Purpose:

  • This question prods whether the developer has a proper grasp of the .NET framework and is familiar with terms that surround it's implementation.
  • Familiarity with .Net constructs are a good sign that a developer knows what he/she is doing, a but its a better warning sign if a developer falters on these types of questions.

Potential Answer:
JIT refers to Just in Time Compiler and is part of the Common Language Runtime (CLR). It manages the execution of all .NET programs and takes Intermediary Language and compiles it for running as native code/instructions.

What is IL?

Purpose:
  • This question prods whether the developer has a proper grasp of the .NET framework and is familiar with terms that surround it's implementation.
  • Familiarity with .Net constructs are a good sign that a developer knows what he/she is doing, a but its a better warning sign if a developer falters on these types of questions.

Potential Answer:
Intermediate language (IL) is the product of compilation from the higher level languages like C# and Visual basic into a special purpose object-oriented programming language designed to be used by compilers for the .NET Framework before static or dynamic compilation to machine code. (It is the product of compilation of your C# code into IL that then JIT compiles into Machine code)

Wednesday, 2 May 2018

What do we mean by managed code?

Purpose:
  • This question prods whether the developer has a proper grasp of the .NET framework and is familiar with terms that surround it's implementation.
  • Familiarity with .Net constructs are a good sign that a developer knows what he/she is doing, a but its a better warning sign if a developer falters on these types of questions.

Potential Answer:
Managed code is a term that was coined by Microsoft and it is simply the computer program code that requires and will execute only under the management of a Common Language Runtime virtual machine (that is the .NET Framework, or maybe a runtime like Mono).

Explain how Garbage Collection works?

Purpose:
  • Garbage collection is a goto topic for many technical interviewers since it easily illustrates the depth of understanding of the candidate regarding the framework.
  • The question is open ended in order to see how much detail a interviewee will go into.
Scott actually points people to a great resource that explains GC really well.

Potential Answer:
.NET uses garbage collection to provide automatic memory management for programs. The GC operates on a lazy approach to memory management, preferring application throughput to the immediate collection of memory.
  • Each process has its own, separate virtual address space. All processes on the same computer share the same physical memory, and share the page file if there is one.
  • By default, on 32-bit computers, each process has a 2-GB user-mode virtual address space.
  • As an application developer, you work only with virtual address space and never manipulate physical memory directly. The garbage collector allocates and frees virtual memory for you on the managed heap.
  • If you are writing native code, you use Win32 functions to work with the virtual address space. These functions allocate and free virtual memory for you on native heaps.
  • Virtual memory can be in three states:
    • Free. The block of memory has no references to it and is available for allocation.
    • Reserved. The block of memory is available for your use and cannot be used for any other allocation request. However, you cannot store data to this memory block until it is committed.
    • Committed. The block of memory is assigned to physical storage.
  • Virtual address space can get fragmented. This means that there are free blocks, also known as holes, in the address space. When a virtual memory allocation is requested, the virtual memory manager has to find a single free block that is large enough to satisfy that allocation request. Even if you have 2 GB of free space, the allocation that requires 2 GB will be unsuccessful unless all of that free space is in a single address block.
  • You can run out of memory if you run out of virtual address space to reserve or physical space to commit.
Garbage collection occurs when one of the following conditions is true:
  • The system has low physical memory. This is detected by either the low memory notification from the OS or low memory indicated by the host
  • The memory that is used by allocated objects on the managed heap surpasses an acceptable threshold. This threshold is continuously adjusted as the process runs.
  • The GC.Collect method is called. In almost all cases, you do not have to call this method, because the garbage collector runs continuously. This method is primarily used for unique situations and testing.
The heap is organized into generations so it can handle long-lived and short-lived objects. Garbage collection primarily occurs with the reclamation of short-lived objects that typically occupy only a small part of the heap. There are three generations of objects on the heap:
  • Generation 0. This is the youngest generation and contains short-lived objects. An example of a short-lived object is a temporary variable. Garbage collection occurs most frequently in this generation.

    Newly allocated objects form a new generation of objects and are implicitly generation 0 collections, unless they are large objects, in which case they go on the large object heap in a generation 2 collection.

    Most objects are reclaimed for garbage collection in generation 0 and do not survive to the next generation.
  • Generation 1. This generation contains short-lived objects and serves as a buffer between short-lived objects and long-lived objects.
  • Generation 2. This generation contains long-lived objects. An example of a long-lived object is an object in a server application that contains static data that is live for the duration of the process.
Garbage collections occur on specific generations as conditions warrant. Collecting a generation means collecting objects in that generation and all its younger generations. A generation 2 garbage collection is also known as a full garbage collection, because it reclaims all objects in all generations (that is, all objects in the managed heap).

Objects that are not reclaimed in a garbage collection are known as survivors, and are promoted to the next generation. Objects that survive a generation 0 garbage collection are promoted to generation 1; objects that survive a generation 1 garbage collection are promoted to generation 2; and objects that survive a generation 2 garbage collection remain in generation 2.

When the garbage collector detects that the survival rate is high in a generation, it increases the threshold of allocations for that generation, so the next collection gets a substantial size of reclaimed memory. The CLR continually balances two priorities: not letting an application's working set get too big and not letting the garbage collection take too much time.

What is Roslyn?

Purpose:
  • This question prods whether a developer has a working understanding of how the .Net framework sticks together under the hood.
  • Knowledge of the internals of the framework indicate a passion for craft.

Potential Answer:
Roslyn was the code name for the .Net Compiler platform. It is a set of open-source compilers for C# and Visual Basic. Unlike traditional compilers Roslyn exposes an api layer that allows for rich code analysis to be done.

What is CoreFX?

Purpose:
  • Unlike the original CLR, the core CLR tries to be as lean as possible. As such the .Net Class libraries are actually contained in the CoreFX. This question prods the depth of the candidate's knowledge about .Net framework developments.

Potential Answer:
The CoreCLR package is actually not very useful on its own. The reason for this is because the CoreCLR package tries to minimize the amount of the class library that it implements. Only types that have a strong dependency on the internal workings of the runtime are included (e.g, System.Object, System.String, System.Threading.Thread, System.Threading.Tasks.Task and most foundational interfaces). 

For the more familiar classes and libraries (System.Collections, System.IO, System.Xml and so on)  are implemented as independent NuGet packages that simply use the .NET Core runtime as a dependency.

Tuesday, 1 May 2018

What is the CoreCLR?

Purpose:
  • This once again tests whether a developer has kept abreast with the evolution of the .Net framework.
  • A knowledge of the design goals surrounding CoreCLR and how it differs to the normal CLR will certainly show passion

Potential Answer:
Similar answer to the CLR will do.

The key differentiation here is that .Net Core code runs on a different runtime to the Full.Net (CLR).

A really good indication would be if the candidate starts talking about the realtionship between CoreCLR and CoreFX and how the CoreCLR tries to minimize as much the class libraries that is implemented to make it more portable and agile.

How to choose between .NET Core and .NET Framework?

Purpose:
  • This question one again tests whether the developer has a grasp on the industry's evolution
  • Developers should show that they understand how containerization has driven the need for core
  • Key to this description should be potential references to Microservice Architecture
  • Mentions about package support for netstandard and Core will show experience

Potential Answers:
The .NET Framework is the traditional .Net framework that targets Windows apps and Windows systems. .NET Core is a smaller open sourced cross platform framework for server apps, console apps, web applications.

.NET Core for when:
  • Cross-platform needs.
  • Targeting microservices.
  • Docker containers.
  • High-performance and scalable systems.

.NET Framework for when:
  • Currently using .NET Framework (extend instead of migrate).
  • Third-party .NET libraries or NuGet packages not available for .NET Core
  • .NET technologies that aren't available for .NET Core
  • App uses a platform that doesn’t support .NET Core.

What is .NET standard or "netstandard"?

Purpose:
  • Tests whether the developer has experience in .Net framework developments or if they have stagnated in the old framework.
  • Tests whether the developer has real world experience in .Net Core and a working understanding of how .Net Standard addresses cross platform binary interaction.

Potential Answers:
A formal specification that represents the APIs that all .Net platforms have to implement.

Common contract that all platforms work towards and as such allows interoperability between these frameworks since they are functionally equivalent.

If the developer can differentiate between .Net Standard and .Net Core it is a really good sign:

  • .NET Standard is a specification that covers which APIs a .NET platform has to implement.
  • .NET Core is a concrete .NET platform and implements the .NET Standard.

What is an assembly?

Purpose:
  • This is such as simple question that at first glance it may simply appear as an idiot test.
  • As most interview questions the interviewer is actually asking a open ended question and the candidate should use the opportunity to illustrate the depth of their knowledge, as such be sure to go into assembly versioning, GAC etc...

Potential Answers:
An assembly is an executable piece of precompiled code. It gets executed by the .Net runtime environment. It is either a DLL or EXE. A .NET program consists of one or more assemblies.

Basically the interviewer simply wants to see that the developer understands that assemblies are the building blocks of .NET Full Framework applications. It is the basic unit of deployment, allows for version control of code, allows you reuse code, provides security mechanisms to prevent access to certain code.

In .NET Core, the building blocks are NuGet packages that contain assemblies PLUS additional metadata. (If developers illustrate an in depth knowledge of .Net Core it typically shows a passion for their craft)

What is NuGet?

Purpose:

NuGet has become core to development especially with the newer versions of .Net frameworks (all building blocks are NuGet packages that contain assemblies PLUS additional metadata). Any decent developer that has configured and setup their own build pipeline would have had run ins with Nuget (for example package hell scenarios). Any ignorance in this technology may be a massive warning sign that a developer is very junior.

Potential Answers:
NuGet is the free/open-source package manager for the Microsoft development platform. It was formerly called NuPack.

The NuGet client tools provide the ability to produce and consume packages in your code of commonly used frameworks and tools. The NuGet Gallery is the central package repository used by all package authors and consumers and is always critical to the way that .Net framework class elements are packaged, distributed and versioned of late.

(If the developer talks about other Packaging solutions like Chocolately for machine level package management or NPM/Bower for web packages it shows maturity as a technologist)

What is a Target Framework Moniker (TFMs)?

Purpose:
  • This is a secret test to see if a developer has actually used different frameworks since any Core developer would have run into these and interoperability challenges.
  • As Core matures this becomes less important so it may indicate that the developer was involved in the early stages of Core's evolution which may indicate passion.

Potential Answer:
A moniker is and ID (string) that lets you refer to target framework + version combinations that you target in your apps in .Net Core.

For example, net462 (.NET 4.6.2), 'netcoreapp1.0' (.NET Core 1.0)

Choosing a TFM decides which APIs are available to you, and which frameworks your code can run on. This is important for interoperability between the different frameworks of .NET. (Related to this question is why the .NET Platform Standard was introduced, if the developer ties the TFM to the overall Framework standards management approach in .NET would be an encouraging sign)

What's .NET?

Purpose:
  • This question checks whether a developer has a understanding of the actual engine under the hood
  • Shows that they are not Code-by-Google type of developers
  • Tests whether the developer is keeping abreast with developments in the .Net ecosystem, inability to answer may indicate stagnation or ignorance.

Potential Answers:
.NET Framework is a framework developed by Microsoft. Traditionally it used to only target Windows operating systems but industry trends like containerization has led to Microsoft backed open source version of the framework (.Net Core) being developed that can target other platforms. (If the developer starts talking about .Net Standard and the purpose that is serves it is a good sign)

.NET includes a Framework Class Library (FCL) and provides language interoperability across several programming languages (languages can interact with each other and share the FCL).

.Net programs run in a software environment named Common Language Runtime (CLR), an application virtual machine that provides services such as security, memory management, and exception handling. FCL and CLR together constitute .NET Framework. (If the developer starts talking about the Common Language Specification and Common Type system it is a good sign)

At the time of this writing there are numerous Language Runtimes (A warning sign would be if the developer has made no effort to get to known other environments beyond traditional .Net framework):

  • NET Framework - Traditional .Net framework developed by Microsoft. Closed source and targeting Windows OS. 
  • Net Core - Open sourced version of .Net, can target Windows, Linux and Mac, plays nicely with containers. 
  • Mono - Original industry open source port of .Net. Mono for Xamarin is also important for brining .Net to iOS and Android

Monday, 16 June 2014

What is the CLR?

Purpose:
  • If a developer is ignorant of how the .Net framework actually sticks together it means they potentially don't care enough about their craft to understand the nuts and bolts of how things work, this means that they will be a code-by-google kind of developer that will not be a great investment.

Potential Answer:
.Net Framework provides runtime environment called Common Language Runtime (CLR).It provides an environment to run all the .Net Programs. The code which runs under the CLR is called Managed Code since it is not native code, but an intermediate language called MSIL (Microsoft Intermediate Language). Programmers need not to worry on managing the memory if the programs are running under the CLR as it provides memory management, security and thread management.

Programmatically, when our program needs memory, the CLR allocates the memory for scope and de-allocates the memory if the scope is completed.

Language Compilers (e.g. C#, VB.Net, J#) will convert the Code/Program to Microsoft Intermediate Language(MSIL) using the Common Type System (CTS) and the rules of the Common Language Specification (CLS). This MSIL code is then converted on a Just-in-time compiler to Native Code by the CLR.