Showing posts with label Answers: What Great .Net Developers ought to know 2005. Show all posts
Showing posts with label Answers: What Great .Net Developers ought to know 2005. Show all posts

Monday, 16 June 2014

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.

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




What is cyclomatic complexity and why is it important?

Purpose:
  • This question tests whether a developer has ever delved into code optimization and whether they use coding metrics and tools to identify code smells and inefficiencies.
  • An ambivalence to metrics could indicate an indifference towards their craft and show a lack of passion. 

Potential Answer:
It is a metric that is used in software to measure computation complexity. Measures the number of linearly independent paths through which a program can go and the number of closed loops that it logically can form. It is important since the higher the dependency the less maintainable the code is.

What are PDBs? Where must they be located for debugging to work?

Purpose:
  • Once again illustrates a deeper understanding of what is happening under the covers of the .Net framework.
  • Also would feature if a developer ever had to do remote debugging.

Potential Answer:
Program Database File. File that contains symbolic debugging information. Debugger will look for PDBs in path of exe, followed by symbols path specified in debug settings.

What’s wrong with a line like this? DateTime.Parse(myString)?

Purpose:
  • This question tests either awareness of Globalization that would show experience in writing international systems or it is a nod to the difference between value and reference types.
  • Since DateTime is a value type it does not support a null type, meaning that if there is not error handling code this naive approach might have side effects.
  • An awareness of either of these issues is a good sign

Potential Answer:
There is no clear specification of what the locale is for the string. This means that one could be expecting a date in a certain format MMddyyyy but perhaps the string is ddMMyyyy. A better option would be to use ParseExact where you provide the format so that all the formats don't need to be checked to infer. Further more since DateTime is a struct or value type if something is wrong it will throw an exception.

When you’re running a component within ASP.NET, what process is it running within on Windows XP? Windows 2000? Windows 2003?

Purpose:
  • There was a time where the gold standard for deployment was IIS. This tests whether a developer has a working understanding of the thread model of IIS. This is important for security management and also debugging and performance tuning.
  • It shows that a developer has at least worked with deploying websites in a windows ecosystem.

Potential Answer:
The component is assigned to an application pool that runs on a worker process For IIS 5 - That ships with XP and 2000 - it is the ASPnet_wp.exe which is called the ASP worker process. For IIS 6 & IIS 7 - Which is 2003 and up - IIS 7 with Server 2008, the process to look out for is W3WP.exe

What is the difference between in-proc and out-of-proc? What technology enables out-of-proc communication in .NET?

Purpose:
  • Remoting as a topic is rather old and as such a question like this could illustrate the depth of experience or a good understanding of how distributed software development has evolved over the years.
  • A discussion of the performance penalty of marshalling and going out-of-process would be a good sign.

Potential Answer:
This is referring to .Net Remoting which allows for method invocation across application domains. It provides an abstract approach to inter-process communication. in-proc is when you are in the same application domain and is faster since out-of-proc requires marshalling and serialization between the two process boundaries.

Friday, 6 July 2012

What does this useful command line do? tasklist /m "mscor*"

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:
It will list all the processes that have loaded modules which start from the mscor libray hosted by the .net environment

How is the using() pattern useful? What is IDisposable? How does it support deterministic finalization?

Purpose:
  • Even though .Net is a managed framework it does not abscond developers from having to understand how memory management works under the hood. Being able to explain the purpose behind the IDisposable interface and supporting language features to manipulate garbage collection is a mark of a professional developer.

Potential Answer:
The using pattern or keyword is a way to allow us to use an expensive object in a deterministic or predictable manner and ensure garbage collection is done after we are done using the resource. For objects that require such deterministic collections we may opt to implement the IDisposable interface to allow for non GC based collection being invoked..

What is the difference between Finalize() and Dispose()?

Purpose:
  • Even though .Net is a managed framework it does not abscond developers from having to understand how memory management works under the hood. Being able to explain the purpose behind the IDisposable interface and supporting language features to manipulate garbage collection is a mark of a professional developer.
  • Also there is well known best practice way of implementing IDisposable that requires the use of the Finalizer. Knowledge of these language constructs suggests that the developer has a good grasp of things.

Potential Answer:
The Finalize is non public and is called by the Garbage collector whereas the Dispose method can be invoked by the user which will cause the Garbage collector to invoke the finalize method.

How does the generational garbage collector in the .NET CLR manage object lifetime? What is non-deterministic finalization?

Purpose:
  • Even though .Net is a managed framework it does not abscond developers from having to understand how memory management works under the hood. Being able to explain the functioning of the garbage collector shows an in depth understanding of the framework under the covers.

Potential Answer:
Divided into three stages. One short lived and other two long term. It assumes new objects will have shorter lifespans that older objects. Non-deterministic finalization means that the finalizer will not immediate be invoked once the object goes out of scope since it is more effecient to reclaim the heap in sections that doing it on a per case basis.

What is the JIT? What is NGEN? What are limitations and benefits of each?

Purpose:
  • Tests whether a developer has an understanding of what happens under the hood of .Net Runtime.
  • Having knowledge of NGEN shows that a developer would have been involved with code optimization exercises in the past that is a promising sign for experience and skill.

Potential Answer:
Just-In-Time compilation produces MSIL (Microsoft Intermediate Language) the first time the assembly is called, it is compiled into CPU specific native code by the .NET JIT compiler.  to have a so called portable executable which in theory one can write once and run everywhere. JIT compiles the code and stores result native code in memory at initial call and subsequent calls is accessing in-memory native code hence it is relatively efficient.

NGEN is when code is pre-compiled or pre-JITted into native code which makes for faster startup times.

Can DateTimes be null?

Purpose:

  • The DateTime struct is a good example of where the value type vs reference type dynamic comes to fore. This question tests whether the developer has an understanding of the difference between the two and why DataTime behaves like it does. Indication of in depth understanding of the framework.

Potential Answer:
No it is a value type and therefore is allocated to the stack instead of the heap. And value types cannot be null. It is a struct instead of class for those interested. What one can do is wrap the DateTime value type with the Nullable reference type to get the desired behavior... Before .Net 2.0 people used to moan about this all the time...