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 are the different types of joins in SQL?

Purpose:
  • This is another idiot test to see if someone has any SQL experience.
  • Not being to answer this question would be a worry.

Potential Answer:
In the very least a candidate should be able to differentiate between an inner and outer join:

The inner join is just a join = rows that match the join predicate from both tables.
And outer join will include all rows, even if the join predicate is not satisfied. If we have a left outer join, the table on the left hand side will always have a row in the result that, for each row it contains, even if there is no match in the right table.

You can shut down this path of questioning by referring to less common joins like:
Left Outer, Semi Join, Full outer join, Right outer join, Semi Outer join etc...

What is normalization and denormalization?

Purpose:
  • This question tests whether a candidate has a theoretical understanding of how storage technologies have evolved and whether they have made an attempt to understand proper database design.
  • A lack of being to awareness of these concepts may indicate ignorance of lack of industry experience.

Potential Answer:
Normalization is where we try to eliminate duplication of data, and dependency. Denormalization is just the opposite usually done for performance improvements to avoid unnecessary joins.

You can start talking about the different levels of normalization but this may bore your interviewer. Rather just allude to the fact that there are different levels and that the best practice is 3NF. Also perhaps juxtapose this with the NoSQL and BigData movements where data duplication is not as frowned upon as in the relational world.

What is the having clause in SQL?

Purpose:
  • SQL is so pervasive, yet many developers only have casual SQL knowledge. Especially with the advent of ORM technologies and NoSQL it is not uncommon to find developers that have very limited SQL knowledge.
  • That said you would be hard pressed to find an enterprise development environment where SQL does not form part of the mix. Having SQL knowledge also helps to optimize and diagnose bloated ORM generated statements.
  • This question is a simple test to see if someone has gone beyond the very basic SQL commands.

Potential Answer:
A HAVING clause in SQL specifies that an SQL SELECT statement should only return rows where aggregate values meet the specified conditions. It was added to the SQL language because the WHERE keyword could not be used with aggregate functions.

Put simpler it is like a where but works against the query that contains a group by.

SELECT COUNT(CustomerID), Country
FROM Customers
GROUP BY Country
HAVING COUNT(CustomerID) > 5;

What is the difference between a Design Pattern and Principle?

Purpose:
  • This question is less about the actual answer and more a test of the candidates ability to critically reason and express themselves in a way that makes sense.
  • A lack of understanding or uncertainty about the question would clearly illustrate a lack of theoretical knowledge and lack of interest in the actual craft they have made their profession.

Potential Answer:
Design Principle provides high level guide lines to design better software applications. Design principles do not provide implementation and not bound to any programming language. E.g. SOLID (SRP, OCP, LSP, ISP, DIP) principles

Design Pattern provides low level solution (implementation) for the commonly occurring object oriented problem.

What is a singleton pattern?

Purpose:
  • Design pattern knowledge is a good indicator of programmer competency.
  • The lowest bar and easiest example is the Singleton
  • This is basically an idiot test to see if a developer has any pattern knowledge.
  • Not being able to answer this question would be a serious concern.

Potential Answer:
The singleton pattern is a software design pattern that restricts the instantiation of a class to one object.

If you want to stand out perhaps raise how the singleton is overused and can be considered an anti-pattern when used incorrectly:

  • Introduces unnecessary restrictions when a sole instance not really required
  • Singleton makes code more complex, less useful and harder to tests
  • Debugging can be hard to figure out which code path lead to singleton's current state
  • Memory allocated cannot be freed
  • Excessive use will promote procedural programming over object orientated

What is a design pattern?

Purpose:
  • Familiarity with design patterns are a great indication that someone has a good theoretical understanding of the software industry.
  • It is usually a good indicator for passion and whether a developer cares about formalizing and mastering their craft.
  • Design pattern ignorance may show a general lack of interest in mastering their craft and suggest perhaps a code-by-google fashioned recipe coder that lacks an in depth reasoning of their designs.

Potential Answer:
As software development matured as an engineering field it was identified that like other engineering fields there are recurring problems and solutions that present themselves. So like other engineering fields software practitioners started formalizing so called design patterns. A design pattern provides low level solution (implementation) for the commonly occurring object oriented problem.

That is design patterns suggest a specific implementation for the specific object oriented programming problem. For example, if you want create a class that can only have one object at a time then you can use Singleton design pattern which suggests the best way to create a class that can only have one object.

What would be good to talk about is the fact that design patterns provide software practitioners with a common vocabulary to talk about software construction and design.

What is composition?

Purpose:
  • It is likely that interviewers will ask basic object orientation questions just to test whether someone has a solid grasps of the principles behind the the languages.
  • Not being able to answer these questions are massive red flags surrounding a developer's education and grasp of the programming domain.
  • Composition is one of those terms that throws a lot of developers for some reason and is pretty good indicator of experience.

Potential Answer:
This simply refers to when one object is made of of other types. But that is not enough, what is actually being asked is for you to juxtapose this to other types of relationships like aggregation and inheritance. So something like:

  • Classes should achieve polymorphic behavior and code reuse by their composition (by containing instances of other classes that implement the desired functionality) rather than inheritance from a base or parent class. This forces the definition of interface representing behaviors that the system should exhibit. This gives the design higher flexibility. It is also more natural to express domain out of various components than to try and find commonality through a family tree.
  • A "owns" B = Composition : B has no meaning or purpose in the system without A
  • A "uses" B = Aggregation : B exists independently (conceptually) from A

What is polymorphism?

Purpose:
  • It is likely that interviewers will ask basic object orientation questions just to test whether someone has a solid grasps of the principles behind the the languages.
  • Not being able to answer these questions are massive red flags surrounding a developer's education and grasp of the programming domain.
  • Interesting it is surprising how many developers at all levels get this question completely wrong.

Potential Answer:
In programming languages, polymorphism is the provision of a single interface to entities of different types. A polymorphic type is one whose operations can also be applied to values of some other type, or types. Put simply it is classes that share the same interface but have different functionality.

Another approach would be to talk about behavior being determined at runtime for a particular method signature.

Example used by John: DVD and Blue-ray use same interface but are implemented differently under the hood. This deferred execution based on context is polymorphism.


What is encapsulation?

Purpose:
  • It is likely that interviewers will ask basic object orientation questions just to test whether someone has a solid grasps of the principles behind the the languages.
  • Not being able to answer these questions are massive red flags surrounding a developer's education and grasp of the programming domain.

Potential Answer:
Encapsulation is used to refer to one of two related but distinct notions, and sometimes to the combination thereof:
  • A language mechanism for restricting direct access to some of the object's components.
  • A language construct that facilitates the bundling of data with the methods (or other functions) operating on that data.
What would be good is to talk about keeping classes loosely coupled, and only expose things that you want to share with other classes. Bonus points if you talk about cohesion and keeping the purpose of class very specific. If you talk about Single Responsibility theory you will certainly inspire confidence in the heart of the interviewer.

What is a delegate?

Purpose:
  • This is another really simple question that one would expect any developer to answer in a split second but amazingly many stumble. This is usually because they have a weak understanding of language mechanisms and simply code to recipes that they have learned. Or they stumble through code and trial-an-error their way through their coding life.

Potential Answer:
The most common answer is that it is a function pointer. Surprising function pointers actually refers to C and C++ concepts so an answer like this perhaps points to a rehearsed or canned answer. A better answer is that it is a special type that defines a method signature and a instance of that delegate type can be assigned to any method with a compatible signature. Put another way a delegate allows the programmer to encapsulate a reference to a method inside a delegate object.

What would be a good sign is if the developer can tie the question to real world examples. Like using delegates to pass methods as parameters.

Or perhaps talking about Action and Func and Predicates as language features that make delegate use easier. For the sake of completeness:
  • Action is a delegate (pointer) to a method, that takes zero, one or more input parameters, but does not return anything.
  • Func is a delegate (pointer) to a method, that takes zero, one or more input parameters, and returns a value (or reference).
  • Predicate is a special kind of Func often used for comparisons takes generic parameters and returns bool.

What are all classes in C# derived from?

Purpose:
  • Really simple question and it really just a litmus test to filter out the really bad candidates.
  • It is a good idea not to just answer the question simply, but actually delve into more detail and offer a greater understanding.

Potential Answer:
All classes derive and implicitly extend System.Object. This is because as a object orientated language the C# specification specifies this as a requirement. Interestingly even value types that are structs implicitly derive from System.Object. It provides a number of methods that sub-classes can override including Equals, GetType, ToString, GetHashCode, Finalize etc.. 

By having a common base class, then you can have behaviors that are universal and allows you to pass anything generically around as 'object'.

As a side note with the introduction of dynamic in C# 4.0 this has changed a bit in that it really has a class hierarchy of its own bypassing static type checking and does not necessarily derive from System.Object. See this blog

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 .NET CLS?

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

Potential Answer:
It is a sub set of Common Type System (CTS) and it specifies a set of rules that needs to be adhered or satisfied by all language compilers targeting Common Language Runtime (CLR). It helps in cross language inheritance and cross language debugging.

What are we referring to when we talk about the .NET CTS?

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

Potential Answer:
We are referring to the Common Type System (CTS)

It describes set of data types that can be used in different .Net languages in common. (i.e), CTS ensures that objects written in different .Net languages can interact with each other.

For Communicating between programs written in any .NET complaint language, the types have to be compatible on the basic level. These types are either reference or value types.

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.

What is boxing and unboxing?

Purpose:
  • Understanding the difference between the stack and the heap and how your coding actions influence what happens at such a fundamental level illustrates a deep understanding of the framework and is a really good sign.

Potential Answer:
Boxing is name given to the process whereby a value type (that is primitive types like INT32 and LONG that reside on the stack) is converted into a reference type (like classes and arrays that reside on the heap). 

Unboxing represents the opposite behavior for when a class is designed for use with objects: for example, using an List to store integers. When you store an integer in the List it gets boxed. When you retrieve an integer, it must be unboxed once again to be used.

What is the difference between Value and Reference Types?

Purpose
  • The original question only revolved around the String case that is somewhat unique in that it is a reference type that is purposely coded to be immutable (behave like a value type)
  • An understanding of memory allocation and management shows a deep knowledge of the nuts and bolts of the framework and is a good sign.

Potential Answers:

Value Type
When a variable is declared using one of the basic, built-in data types or a user defined structure, it is a value type. An exception is the string data type, which is a reference type.
A value type stores its contents in memory allocated on the stack that is a thread specific memory construct in RAM that allows for fast allocation of memory for types with a known size. When the variable goes out of scope because the method in which it was defined has finished executing, the value is discarded from the stack immediately meaning that no explicit memory management is needed.
Reference Type
A reference type, such as an instance of a class or an array, is allocated in a different area of memory called the heap that is a slower area of allocation in RAM but is more flexible in that you don't need to know the size of your allocation beforehand. Unlike the stack this memory is never destroyed when it falls out of scope and as such it needs to be explicitly managed to avoid memory leakage.
In the managed programming world like .NET, This memory isn't returned to the heap when a method finishes; it's only reclaimed when the garbage collection system determines it is no longer needed. There is a greater overhead in declaring reference types, but they have the advantage of being accessible from other classes.

Tuesday 25 September 2012

Give a few general guidelines for component design


  • Apply the solid design principles
  • Design components to be highly cohesive - Do not add mixed and unrelated functionality 
  • Components should avoid internal details of other components to promote maintainable and adaptable code
  • Understand how components will communicate with each other
  • Keep crosscutting code abstracted from application specific logic - This refers to security, communications, and operational management such as logging and instrumentation
  • Apply the key principles of the component-based architectural style
    • Reusable
    • Replaceable
    • Extensible
    • Encapsulated
    • Independent
    • Not context specific

What are the SOLID design principles?

SOLID is a acronym typically used in object-oriented design for the five basic principles of programming and design. When applied together the theory goes that the system will be easy to maintain and extend over time.
S - Single Responsibility Principle - An object should have only a single responsibility
O - Open/Closed Principle - Classes should be open for extension
L - Liskov Substitution Principle - objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program
I - Interface Segregation Principle - Class Interfaces should be client specific and fine grained. Classes should expose separate interfaces for different clients where the interface requirements differ. Many client specific interfaces are better than one general purpose interface
D -  Dependency Inversion Principle - Components/Modules should depend upon Abstractions and not on concrete implementations to allow top down design without requiring low level modules first.


What is Dependency Injection?

- High level modules should not depende on low level modules, both should depend on abstractions
- Abstractions should not depend upon details, details should depend upon abstractions

A common implementation of dependency inversion. Dependency injection involves at least three elements
  • a dependent consumer
  • a declaration of a component's dependencies, defined as interface contracts,
  • an injector (sometimes referred to as a provider or container) that creates instances of classes that implement a given dependency interface on request.
The dependent object describes what software component it depends on to do its work. The injector decides what concrete classes satisfy the requirements of the dependent object, and provides them to the dependent.

In conventional software development, the dependent object decides for itself what concrete classes it will use. In the dependency injection pattern, this decision is delegated to the "injector" which can choose to substitute different concrete class implementations of a dependency contract interface at run-time rather than at compile time.


Being able to make this decision at run-time rather than compile time is the key advantage of dependency injection. Multiple, different implementations of a single software component can be created at run-time and passed (injected) into the same test code. The test code can then test each different software component without being aware that what has been injected is implemented differently.

What is Dependency Inversion?

This is a programming style where abstract interfaces are defined external to, or independent of, any layers. Instead of one layer being dependent on another, both layers depend upon common interfaces.

What is the Facade?

Provides a unified interface to a set of interfaces in a subsystem. Facade defines a higher level interface that makes the subsystem easier to use. In a layered architecture the layer facade allows coupling between layers to the lowest possible because higher-level components only references the facade directly.

What is the Abstract Interface Pattern?

The abstract interface pattern combines the benefits of interfaces (contract for behavior) and abstract skeletal implementations (much like the Strategy design pattern from Gamma et al). In a layered architecture an abstract interface is defined for each component in a layer that is called by components in a higher level. The higher layers access the lower-level components through the abstract interfaces instead of calling the components directly. This allows for the changing of lower level components without affecting the higher level components.

Explain Fowler's Layer Super Type Pattern

When components in a layer share a common set of behaviors those behaviors are extracted into a common class or component from which all the components in the layer inherit. Eases maintenance and promotes reuse. Also reduces dependencies between layers. Example can be base type implementation checking object validity using business rules.

What is the difference between layers and tiers?

Layers are a logical grouping of functionality and components. Tiers describe physical distribution of the functionality and components on separate servers, computers, networks or remote locations. They use the same names (presentation, business, services, data) but only tiers imply a physical separation. It is common to locate more than one layer on the same physical machine.

What are the advantages of a Layered Application?


  • Clear separation of concern
  • Maintenance is easier since there is lower coupling between layers
  • You can switch out varying implementations of the layer interface
  • Reuse functionality exposed by various layers
  • Distributed development is easier
  • Distributing the layers over multiple physical tiers can improve scalability, fault tolerance and performance
  • Improves testability

Friday 27 July 2012

How does the XmlSerializer work? What ACL permissions does a process using it require?

Purpose:
  • Anybody that has worked extensively with either Web Services, APIs or Relational Mapping tools would have come across Serialization idiosyncrasies. Some may have written their own persistence frameworks or tried different serialization strategies to improve performance. This level of in depth understanding bodes well.

Potential Answer:
Creates a temporary assembly with the reader and writer type derived from the XmlSerialization equivalents in the .Net Framework. These methods do the actual serialization operation. ACL comes in with the writing of the temp assembly to the temp folder since it needs write and delete permissions to that folder.

Contrast OOP and SOA. What are tenets of each?

Purpose:
  • As a senior or architect level developer you have to start reasoning about your skills and craft from a principle point of view. Being able to hold discussions about fundamental differences between well known industry concepts is important in order to guide teams to the right outcomes and to avoid confusion. This question is an opportunity to showcase some of that deep knowledge.

Potential Answers:
Object Orientated Programming
Programming paradigm that uses objects and embraces principles such as data abstraction, encapsulation, messaging, modularity, inheritance and polymorphism.
Service Oriented Architectures
Princinples and methodologies for designing software that is inter-operable across heterogeneous spaces and it embraces principles such as Policy based negotiation, Explicitness of boundaries, Autonomy and Contract Exchange Differences.

What ports must be open for DCOM over a firewall? What is the purpose of Port 135?

135 = Windows Remote Procedure Call (RPC) - Edit registry for ports to open. Who still uses RPC, gosh these questions are old...

What does this do? sn -t foo.dll

Purpose:
  • An experienced developer would at some stage have gone into the developer command prompt to get something done. Chances are good that it may have been due to dll hell being wrecked on them. Or perhaps it could be part of setting up and Continuous delivery pipeline. Whatever it it is knowledge of these type of commands illustrates experience.

Potential Answer:
Gets the public key token for the strongly names assembly file called foo

What does this do? gacutil /l | find /i "Corillian"

Purpose:
  • An experienced developer would at some stage have gone into the developer command prompt to get something done. Chances are good that it may have been due to dll hell being wrecked on them. Or perhaps it could be part of setting up and Continuous delivery pipeline. Whatever it it is knowledge of these type of commands illustrates experience.

Potential Answer:
List all assemblies in the GAC that has a case insenstive world "Corillian" in it...

What benefit does your code receive if you decorate it with attributes demanding specific Security permissions?

Purpose:

  • This illustrates a level of defensive coding that shows experience. Explicit argument guarding is another example of a practice that shows experience.

Potential Answer:
Allows for the level of security to be seen beforehand. If code gets exploited will not go beyond the permission boundary that you specified as necessary.

What is FullTrust? Do GAC’ed assemblies have FullTrust?

Purpose:

  • Another question that prods the extent of the developers understanding of the assembly execution policies, can be a indicator of knowledge but will have a high failure rate.


Potential Answer:
Full trust = Unrestricted access to system resources and all .Net permission are granted. The GAC assemblies have FullTrust although you have the ability to change this with CASPOL tool.

Write a standard lock() plus “double check” to create a critical section around a variable access.

Purpose:

  • Any seasoned developer that has written multi threaded code would be familiar with this pattern. If the developer can tie it to both deadlock and performance reasons then it is a really good indicator.

Potential Answer:
public class SingletonObject
        {
            private static volatile Singleton _instance;
            private static object lockObject = new object();

            public static Singleton Instance
            {
                get
                {
                    if (instance == null)
                    {
                        lock (lockObject)
                        {
                            if (instance == null)
                                instance = new Singleton();
                        }
                    }
                    return instance;
                }
            }
        }