Wednesday, February 23, 2005

What great .NET developers ought to know

Excerpted from http://www.hanselman.com/blog/WhatGreatNETDevelopersOughtToKnowMoreNETInterviewQuestions.aspx

What Great .NET Developers Ought To Know

Everyone who writes code

  • Describe the difference between a Thread and a Process?
  • What is a Windows Service and how does its lifecycle differ from a "standard" EXE?
  • What is the maximum amount of memory any single process on Windows can address? Is this different than the maximum virtual memory for the system? How would this affect a system design?
  • What is the difference between an EXE and a DLL?
  • What is strong-typing versus weak-typing? Which is preferred? Why?
  • Corillian's product is a "Component Container." Name at least 3 component containers that ship now with the Windows Server Family.
  • What is a PID? How is it useful when troubleshooting a system?
  • How many processes can listen on a single TCP/IP port?
  • What is the GAC? What problem does it solve?

Mid-Level .NET Developer

  • Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programming.
  • Describe what an Interface is and how it’s different from a Class.
  • What is Reflection?
  • 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?
  • What is an Asssembly Qualified Name? Is it a filename? How is it different?
  • Is this valid? Assembly.Load("foo.dll");
  • How is a strongly-named assembly different from one that isn’t strongly-named?
  • Can DateTimes be null?
  • What is the JIT? What is NGEN? What are limitations and benefits of each?
  • 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()?
  • 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?

Senior Developers/Architects

  • What’s wrong with a line like this? DateTime.Parse(myString);
  • What are PDBs? Where must they be located for debugging to work?
  • What is cyclomatic complexity and why is it important?
  • Write a standard lock() plus “double check” to create a critical section around a variable access.
  • What is FullTrust? Do GAC’ed assemblies have FullTrust?
  • What benefit does your code receive if you decorate it with attributes demanding specific Security permissions?
  • What does this do? gacutil /l | find /i "Corillian"
  • What does this do? sn -t foo.dll
  • What ports must be open for DCOM over a firewall? What is the purpose of Port 135?
  • Contrast OOP and SOA. What are tenets of each?
  • How does the XmlSerializer work? What ACL permissions does a process using it require?
  • Why is catch(Exception) almost always a bad idea?
  • What is the difference between Debug.Write and Trace.Write? When should each be used?
  • What is the difference between a Debug and Release build? Is there a significant speed difference? Why or why not?
  • Does JITting occur per-assembly or per-method? How does this affect the working set?
  • Contrast the use of an abstract base class against an interface?
  • What is the difference between a.Equals(b) and a == b?
  • In the context of a comparison, what is object identity versus object equivalence?
  • How would one do a deep copy in .NET?
  • Explain current thinking around IClonable.
  • What is boxing?
  • Is string a value type or a reference type?
  • What is the significance of the "PropertySpecified" pattern used by the XmlSerializer? What problem does it attempt to solve?
  • Why are out parameters a bad idea in .NET? Are they?
  • Can attributes be placed on specific parameters to a method? Why is this useful?

C# Component Developers

  • Juxtapose the use of override with new. What is shadowing?
  • Explain the use of virtual, sealed, override, and abstract.
  • Explain the importance and use of each component of this string: Foo.Bar, Version=2.0.205.0, Culture=neutral, PublicKeyToken=593777ae2d274679d
  • Explain the differences between public, protected, private and internal.
  • What benefit do you get from using a Primary Interop Assembly (PIA)?
  • By what mechanism does NUnit know what methods to test?
  • What is the difference between: catch(Exception e){throw e;} and catch(Exception e){throw;}
  • What is the difference between typeof(foo) and myFoo.GetType()?
  • Explain what’s happening in the first constructor: public class c{ public c(string a) : this() {;}; public c() {;} } How is this construct useful?
  • What is this? Can this be used within a static method?
Developers using XML
  • What is the purpose of XML Namespaces?
  • When is the DOM appropriate for use? When is it not? Are there size limitations?
  • What is the WS-I Basic Profile and why is it important?
  • Write a small XML document that uses a default namespace and a qualified (prefixed) namespace. Include elements from both namespace.
  • What is the one fundamental difference between Elements and Attributes?
  • What is the difference between Well-Formed XML and Valid XML?
  • How would you validate XML using .NET?
  • Why is this almost always a bad idea? When is it a good idea? myXmlDocument.SelectNodes("//mynode");
  • Describe the difference between pull-style parsers (XmlReader) and eventing-readers (Sax)
  • What is the difference between XPathDocument and XmlDocument? Describe situations where one should be used over the other.
  • What is the difference between an XML "Fragment" and an XML "Document."
  • What does it meant to say “the canonical” form of XML?
  • Why is the XML InfoSet specification different from the Xml DOM? What does the InfoSet attempt to solve?
  • Contrast DTDs versus XSDs. What are their similarities and differences? Which is preferred and why?
  • Does System.Xml support DTDs? How?
  • Can any XML Schema be represented as an object graph? Vice versa?

Tuesday, February 22, 2005

A survey of various efforts to catalog patterns for enterprise software development.

Whats the difference between Control.Invalidate, Control.Update and Control.Refresh? (.NET)

Control.Invalidate() v/s Control.Update() v/s ControlRefresh()

Before discussing each one of the above functions, let’s look at how winforms controls paint.

Windows controls paint is response to WM_PAINT messages. This message is sent when UpdateWindow or RedrawWindow is called, or by the DispatchMessage function when the application gets a WM_PAINT through the message queue. On getting the WM_PAINT message, the control paints its background and then the foreground if necessary. Double-buffering and transparency is honored while painting and then the OnPaint event is fired to give the user a chance to perform his custom painting.

With this background, let’s look at the above mentioned three functions in more detail,

Control.Invalidate( ) / Control.Invalidate(bool) / Control.Invalidate(Rectangle) / Control.Invalidate(Rectangle, bool) / Control.Invalidate(Region) / Control.Invalidate(Region, bool)

The bool parameter denotes whether the user wants to invalidate the child controls of the control on which he is calling Invalidate. The Rectangle parameter are the bounds to invalidate and the region parameter is the region to invalidate. All the overloads essentially end up calling one of the RedrawWindow, InvaliateRect or InvalidateRgn functions. If RedrawWindow is called then this may result in a WM_PAINT message being posted to the application message queue (to invalidate the child controls).

The important thing to note here is that these functions only “invalidate” or “dirty” the client area by adding it to the current update region of the window of the control. This invalidated region, along with all other areas in the update region, is marked for painting when the next WM_PAINT message is received. As a result you may not see your control refreshing (and showing the invalidation) immediately (or synchronously).

Control.Update()

Update function calls the UpdateWindow function which updates the client area of the control by sending WM_PAINT message to the window (of the control) if the window's update region is not empty. This function sends a WM_PAINT directly to WNDPROC() bypassing the application message queue.

Thus, if the window update region is previously “invalidated” then calling “update” would immediately "update" (and cause repaint) the invalidation.

Control.Refresh()

By now, you might have guessed what Refresh( ) would be doing. Yes, it calls Invalidate(true) to invalidate the control and its children and then calls Update( ) to force paint the control so that the invalidation is synchronous.

Monday, February 21, 2005

Sysinternals Freeware - Utilities for Windows NT and Windows 2000

Sysinternals Freeware - Utilities for Windows NT and Windows 2000 This site has some great system utilities. Some of these are indispensible if you are a developer. Tools that I love: .Net Reflector CPUMon v2.0 http://www.sysinternals.com/ntw2k/freeware/cpumon.shtml DiskMon v2.0 http://www.sysinternals.com/ntw2k/freeware/diskmon.shtml FileMon v6.12 http://www.sysinternals.com/ntw2k/source/filemon.shtml Process Explorer v9.0.1 (very good) http://www.sysinternals.com/ntw2k/freeware/procexp.shtml RegMon v6.12 (another very useful tool) http://www.sysinternals.com/ntw2k/source/regmon.shtml Autoruns v6.1 (very useful to see what applications are automatically loaded on your system) http://www.sysinternals.com/ntw2k/freeware/autoruns.shtml

WinDirStat Home Page

WinDirStat Home Page WinDirStat is a disk usage statistics viewer and cleanup tool for Microsoft Windows Free and very useful.

Debugging applications that arent started up directly

Very often, we have to create applications that arent executed directly. Instead these applications are started by another app. An example : Our company develops GIS tools for SocetSet and Imagine. Our application is loaded when the user clicks on a menu option in the main executable of SocetSet or Imagine. To debug our application, we normally load it up from the main applications menu. Once our app is running, we use the Attach to process option to start the debuger. Here is another more convenient method. http://weblogs.asp.net/junfeng/archive/2004/04/28/121871.aspx its using the Image File Execution option. Every application that loads checks with some registry settings. One of these is the debugger key under: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options by setting the debugger option, you can have your application automatically load the debugger - so that you can step through it. Pretty cool.

Home design Software

When we decided to buy our home (which is being constructed) I had to look quite a bit to figure out which of the myriad applications availble was worth shelling out the cash for. The one that I decided to shell out the moolah for, was Punch Software's Professional Platinum software (v8.0). I found that this software was very fast in rendering 3d views from your plans. Though my only gripe was that the user interface is not very intutive and takes some learning. Also there are no wizards that help you do the setup. For that matter the documentation is not very good too. But with some work I got my stuff working and got very good results. I think if you are the kind of person who is willing to explore the software and take on a steep learning curve - you will definetly like this software. It also allows you to design your garden and do landscaping and from some screen shots that I have seen - its pretty good - though I havent tried it out myself yet. Punch Platinum Pro The version I bought was $100. But they have another one thats about $30 cheaper and is good if all you want to do is design your home and not the garden. Other softwares that I read about: * Better Homes and Gardens Home Designer Suite http://www.homedesignersoftware.com/products/products.htm This software got the highest rankings in almost every review that I read. Heard that people who had never used design software before - found this to be very good. Check out the samples they have on the website - its very impressive * 3D Home Architect® Design Suite Deluxe 6 by Broderbund The user interface is not supposed to be very easy in this one and havent seen many people give very good reviews about this software. Checked it out only because I knew about BroderBund from way back when they used to make great PC games. I found this review to be very useful: http://www.consumersearch.com/www/software/home_design_software/fullstory.html Its very indepth and basically they recommend the Better Homes and Gardens Home Designer Suite. Also, most of these companies have demos, so it would make sense that you download them and test them out for yourself.

Multi-Monitor taskbar - UltraMon

UltraMon UltraMon is not free-ware(like Multi-mOn), but I think its definetly a much better multi-monitor taskbar. (whoever said that the best things in life are free, was definetly wrong) * it looks similar to the WindowsXP taskbar. (MultiMon's taskbar looked more like the old windows 2000 taskbar). * The extra buttons that it adds are much more cleaner and work better. (there is a button that switches the window between your monitors and another that stretches your window across your monitors) * it has a much better interface, that allow you to customize your wallpapers and screen savers and lots more. * allows you to have different wallpapers on your monitors, as well as stretch one across all your windows. * allows you to have different screensavers for each of your monitors.

Wednesday, February 16, 2005

Uninstaller does not remove all installed assemblies from the GAC

Problem: Assemblies installed by your installer into the GAC, cannot be removed upon uninstallation. (Unable to uninstall assembly or application completely) You installed assemblies into the GAC, and you weren't able to remove them using all three of the following methods 1. Using the .Net configuration manager 2. Trying to manually delete them form c:\WinNT\assembly3. using the gacutil /u or /uf option on the assembly Trying any of the above methods, will lead to a message that says that the assembly is still being referenced by another application. If you run gacutil /lr assembly, you will see that the application that is still referencing the assembly is the MSIInstaller. I found that the problem was in a value in the registry. Goto HKEY_CLASSES_ROOT\Installer\Assemblies\Global the key (default) should not have a value. (so its value should read as (value not set)) if the value is either empty or any other value, then you will not be able to remove your assembly from the GAC. Solution: Goto HKEY_CLASSES_ROOT\Installer\Assemblies\Globalclick on the key (default), hit delete. This should reset the value of (default) so that its value comes up as (value not set). After this you should be able to uninstall your assembly from the GAC. If you are creating an installer, then make the installer, delete this key from the registry. Then when the user uninstalls the application, it will remove all your assemblies from the GAC too. I have no idea why this works. Cant even give you a reason as to why .NET framework needs to look at that key to decide if it can remove an assembly from the GAC. But apps like MSN IM 6.0 insert a value into the default key, and this can mess the uninstall procedure of your app. The HKEY_CLASSES_ROOT\Installer\Assemblies\Global\ area is used to store information about shared assemblies deployed on the machine. But as far as I can see the (default) key should not be used. A good thing to know

MSDN .NET Framework Developer Center: Designing .NET Class Libraries

Design guidelines for developing classes and components that extend the .NET Framework. MSDN .NET Framework Developer Center: Designing .NET Class Libraries