Showing posts with label Level 03: Senior Questions. Show all posts
Showing posts with label Level 03: Senior Questions. 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.