Tuesday, March 13, 2007

Mid level developer - Qs from Scott Hanselmans Computer Zen

I hope to write all the answers. Watch this space!

Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programming.

Interface Oriented programming

= Programming to an Interface.

Object oriented programming = Using the object oriented concepts such as Encapsulation,Inheritance,Polymorphism

Aspect oriented programming = <>


Describe what an Interface is and how it’s different from a Class.

Interface has no implementation.

Classes have implementation and they may implement the Interface.

Interface is a good way to design a software since it defines a contract for the classes.

What is Reflection?

Reflection provides objects that encapsulate assemblies, modules, and types.

You can use reflection to dynamically create an instance of a type, bind the type to an existing object, or get the type from an existing object.

You can then invoke the type's methods or access its fields and properties.

Example

Imagine,you are in visual studio IDE (Integrated devolopment environment) and as you type "object." you would see all the methods,properties and events associated with that object.

An other example would be an Object browser.The code attached here,loads all assemblies and displays each class,its contructors, methods, properties and events in tree view.

What is the difference between XML Web Services using ASMX and .NET Remoting using SOAP?


Are the type system represented by XmlSchema and the CLS isomorphic?


Conceptually, what is the difference between early-binding and late-binding?


Is using Assembly.Load a static reference or dynamic reference?


When would using Assembly.LoadFrom or Assembly.LoadFile be appropriate?

LoadFile method is supported only in version 1.1 of the .NET Framework

Use the LoadFile method to load and examine assemblies that have the same identity, but are located in different paths.

Do not use LoadFile to load assemblies that you want to execute. LoadFile does not load files into the LoadFrom context, and does not resolve dependencies using the load path, as the LoadFrom method does.

LoadFile is useful in this limited scenario because LoadFrom cannot be used to load assemblies that have the same identities but different paths; it will load only the first such assembly.


What is an Asssembly Qualified Name? Is it a filename? How is it different?

An assembly's name is stored in metadata and has a significant impact on the assembly's scope and use by an application.

A strong-named assembly has a fully qualified name that includes the assembly's name, culture, public key, and version number.

The runtime uses this information to locate the assembly and differentiate it from other assemblies with the same name.

For example, a strong-named assembly called myTypes could have the following fully qualified name:

"myTypes, Version=1.0.1234.0, Culture="en-US", publicKeyToken=b77a5c561934e089c


In this example, the fully qualified name indicates that the myTypes assembly has a strong name with a public key token, has the culture value for US English, and has a version number of 1.0.1234.0.


Is this valid? Assembly.Load("foo.dll");

No this should be loaded with a fully qualified assembly name


How is a strongly-named assembly different from one that isn’t strongly-named?

A strong name consists of the assembly's identity—its simple text name, version number, and culture information (if provided)—plus a public key and a digital signature

Strong names guarantee name uniqueness by relying on unique key pairs. No one can generate the same assembly name that you can, because an assembly generated with one private key has a different name than an assembly generated with another private key

It helps in avoiding DLL hell.

Can DateTimes be null?


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

JIT comes into play during EXECUTION of the code.

Before you can run Microsoft intermediate language (MSIL), it must be converted by a .NET Framework just-in-time (JIT) compiler to native code, which is CPU-specific code that runs on the same computer architecture as the JIT compiler.

JIT compilation takes into account the fact that some code might never get called during execution. Rather than using time and memory to convert all the MSIL in a portable executable (PE) file to native code, it converts the MSIL as needed during execution and stores the resulting native code so that it is accessible for subsequent calls

NGEN

The Native Image Generator (Ngen.exe) is a tool that improves the performance of managed applications.

Ngen.exe creates native images, which are files containing compiled processor-specific machine code, and installs them into the native image cache on the local computer.

The runtime can use native images from the cache instead using the just-in-time (JIT) compiler to compile the original assembly.

http://msdn2.microsoft.com/en-us/library/6t9t5wcf(VS.80).aspx is a good link on comaprison between NGEN and JIT


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


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

Finalize

Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.

Finalize operations have the following limitations:
The exact time when the finalizer executes during garbage collection is undefined. Resources are not guaranteed to be released at any specific time, unless calling a Close method or a Dispose method.

The finalizers of two objects are not guaranteed to run in any specific order, even if one object refers to the other. That is, if Object A has a reference to Object B and both have finalizers, Object B might have already finalized when the finalizer of Object A starts.

The thread on which the finalizer is run is unspecified.

Dispose


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


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


What is the difference between in-proc and out-of-proc?


What technology enables out-of-proc communication in .NET?


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

Adda is the Bengali for discussion.Bengali is a language like English.