Showing posts with label Level 01: Junior Questions. Show all posts
Showing posts with label Level 01: Junior Questions. Show all posts

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 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 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

Tuesday, 1 May 2018

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.

Friday, 6 July 2012

What is the GAC? What problem does it solve?

Purpose:
  • Any developer that has written and deployed a non trivial, multi environment system would have come into contact with the GAC, frequently for frustrating reasons.
  • A lack of knowledge about the GAC might indicate a lack of experience in writing professionally deployed multi environment code.

Potential Answer:
GAC stands for Global Assembly Cache. It is a machine-wide code repository or cache where the registered assemblies must have a strong name and version number. This is required to the problems of versioning, and what has become known as DLL hell when libraries become out of date with updates etc...

How many processes can listen on a single TCP/IP port?

Purpose:
  • The greatest strength of the .Net framework is the richness of the Framework Class Library that abstracts away a lot of detail from a developer.
  • This question tests whether a developer has a deeper understanding of how networking works at a OS level and whether they have socket programming experience.
  • If the developer struggles with this question is may be wise to delve into the basics of network communication and typical port allocations.
  • Generally if one is going to write distributed applications a developer should at least have a working knowledge of how it works at a wire level.

Potential Answer:
Usually only one although one could write a master process that notifies others and using some type of method to distinguish between client requests.

What is a PID? How is it useful when troubleshooting a system?

Purpose:
  • Any developer that has had to debug a multi-threaded applications will know how hard it can be to track an issue. In order to isolate the problem one has to be able to using the debugging tools that allow for the freezing of certain threads and selective debugging of others.
  • This is very simple prod to see if a developer has experience in debugging multi threaded applications and could be the start of a much deeper conversation about multi threading.

Potential Answer:
Process Identifier which is a unique Integer that identifies the OS process construct uniquely which helps with debugging and tracing in multi tasked applications.