Home > .NET Framework > Scott Hanselman’s interview questions – Senior Developers/Architects

Scott Hanselman’s interview questions – Senior Developers/Architects

Answers to Senior Developers/Architects
  1. What’s wrong with a line like this? DateTime.Parse(myString);

    Parse converts date at any cost. What if user passes date in format MM/dd/yyyy whereas you are expecting in dd/MM/yyyy.Assume the user is passing 12/09/2006 meaning Dec 12, 2006, whereas Parse (based on the current locale) picked it up as Sep 12, 2006. The result is not something which you would like. Also Parse takes more time compared to other as it has to check for a gazillion formats. Instead if you know the format its better to go with ParseExact. Then why the hell do we have Parse? May be for the old VB customers it was an easier transition. Chec out more here or here

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

    A Program DataBase file (extension .pdb) is a binary file that contains type and symbolic debugging information gathered over the course of compiling and linking the project. A PDB file is created when you compile a C/C++ program with /ZI or /Zi or a Visual Basic, Visual C#, or JScript program with the /debug option. The Visual Studio debugger uses the path to the PDB in the EXE or DLL file to find the project.pdb file. If the debugger cannot find the PDB file at that location, or if the path is invalid, for example, if the project was moved to another computer, the debugger searches the path containing the EXE followed by the symbol paths specified in the Options dialog box (Solution Properties–>Debug Symbol Files node in VS.NET 2003). The debugger will not load a PDB that does not match the binary being debugged.

  3. What is cyclomatic complexity and why is it important?

    This calls for a separate entry in itself. http://sendhil.spaces.live.com/blog/cns!30862CF919BD131A!581.entry

  4. Write a standard lock() plus “double check” to create a critical section around a variable access.

    This calls for a separate entry in itself. http://sendhil.spaces.live.com/blog/cns!30862CF919BD131A!582.entry

  5. What is FullTrust? Do GAC’ed assemblies have FullTrust?

    Full Trust Permission Set Grants unrestricted permissions to system resources. My_Computer_Zone code group by default has has FullTrust permission. This can be changed using CASPOL.exe though.

  6. What benefit does your code receive if you decorate it with attributes demanding specific Security permissions?

    Allows administrators to see exactly which permissions your application needs to run, using PermView
    Prevents your code from being exploited beyond what permissions it absolutely needs
    Allows your application to forcibly fail instead of having to manually handle situations where it might be denied permissions it requires.
    More info can be found here / here

  7. What does this do? gacutil /l | find /i "Corillian"

    gacutil /l lists the assemblies in GAC. Find /i lists all the assemblies which have Corillian in their identity. (/i ignores case I suppose).

  8. What does this do? sn -t foo.dll

    Extracts the publick key token from the strongly named assembly foo.dll

  9. What ports must be open for DCOM over a firewall? What is the purpose of Port 135?

    135 is used by Windows RPC. HKEY_LOCAL_MACHINESoftwareMicrosoftRpcInternet (Key) Ports (Multi Line String Value) specifies what other ports will be open.

  10. Contrast OOP and SOA. What are tenets of each?

    OOP Tenets – Abstraction, Encapsulation, Inhertiance, Polymorphism. SOA Tenats – (PEACE) – Policy based negotiation, Explicitness of boundaries, Autonomy, Contract Exchange Differences: Read this nice analogy. This is as best as it can get http://blogs.msdn.com/smguest/archive/2004/01/29/64871.aspx

  11. How does the XmlSerializer work? What ACL permissions does a process using it require?

    The XmlSerializer creates a temporary assembly with two types named XmlSerializationReader1, XmlSerializationWriter1 which derive from XmlSerializationReader and XmlSerializationWriter classes. These types are responsible for DeSerializing and Serializing respectively. The XMlSerializer constructors caches the assemblies emitted if you use one of these constructors


    Its recommended to use these. So the account under which host process is running must have Write, Delete permissions on the temporary directory. This the user profile temp directory for windows applications and the app specific folder under Temporary ASP.NET Files (in the framework directory) for ASP.NET applications

  12. Why is catch(Exception) almost always a bad idea?

    When you catch an exception, you’re stating that you expected this exception, you understand why it occurred, and you know how to deal with it. In other words, you’re defining a policy for the application. However, you shouldn’t catch Exception because a StackOverflowException or OutOfMemoryException exception could be thrown at any time. Hiding these fatal problems and allowing the application to continue running will cause unpredictable results.

  13. What is the difference between Debug.Write and Trace.Write? When should each be used? Debug.Write is compiled into a release build. Trace.Write gets compiled irrespective of the build configuration chosen. Trace is useful for production debugging (can be turned on off based on config at various levels / severity). Debug is useful for development environment debugging.
  14. What is the difference between a Debug and Release build? Is there a significant speed difference? Why or why not?
    • A debug build generates a file containing debug symbols (.pdb); a release build does not.
    • A debug build generates extra instructions to accomodate the debugger (e.g. NOP instructions to assist your setting breakpoints); a release build does not include these.
    • A release build uses full optimizations when compiling which might include rearranging your code or inlining it for efficiency, a debug build doesn’t do this.
    • A debug build allocates extra memory on the heap for objects to facilitate detecting memory overwrite errors; a release build doesn’t do this.
    • A release build will thus be smaller, faster, and more efficient than a debug build.

    More Info
    http://www.hanselman.com/blog/PermaLink.aspx?guid=a40c0d4f-66d0 -4704-94f6-0efda4a44465

  15. Does JITting occur per-assembly or per-method? How does this affect the working set?

    Per-method. Since methods which are not called are not compiled at all, this reduces the working set.

  16. Contrast the use of an abstract base class against an interface?


  17. What is the difference between a.Equals(b) and a == b?

    Cannot be answered unless you have the variable declarations for a and b.
    The default implemenation for Equals on object checks for references or identity.
    There is no default implementation for ‘==’ on value types.
    The default implementation for ‘==’ on reference types checks for idenity or memory references
    More here

  18. In the context of a comparison, what is object identity versus object equivalence?

    identity comparison: check if both the instances point to the same memory address.
    equivalence: two instances are considered equal if their values represented by them are equal, they can point to different memory locations. For example:

    Person p1 = new Person();
    p1.age = 25;
    Person p2 = new Person();
    p2.age = 25;

    identity comparison of p1 and p2 should return false whereas equivalence should return true.

  19. How would one do a deep copy in .NET?

    Serialize / DeSerialize is an option, but it has a performance impact and required all the objects to be serializable.
    ICloneable is another.

  20. Explain current thinking around IClonable.

    Because the interface contract does not specify the type of clone performed, different classes have different implementations. A consumer cannot rely on ICloneable to let them know whether an object is deep-cloned or not. May be I would use something like ICloneableEx with ShallowCopy and DeepCopy as members. Read more here

  21. What is boxing?


  22. Is string a value type or a reference type?

    String is a reference type. But being immutable it gives the illusion of a value type.

  23. What is the significance of the "PropertySpecified" pattern used by the XmlSerializer? What problem does it attempt to solve?

    Nillable value types. condiitonal serialization of fields using the Property specified pattern.
    http://msdn.microso ft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlSerializationXmlSerializerClassTopic.asp

  24. Why are out parameters a bad idea in .NET? Are they?

    Out parameters can be abused however. As a matter of good programming style if you find yourself writing a method with many out parameters then you should think about refactoring your code. One possible solution is to package all the return values into a single struct.
    http://msdn.microsoft.com/vcsharp/programming/language/ask/refandout /default.aspx
    .Net doesn’t verify that an out parameter is set inside a method that uses an out parameter before an exception is called. This mean that you may use an uninitialized parameter without the compiler catching on to this. Use ref parameters instead.

  25. Can attributes be placed on specific parameters to a method? Why is this useful?

    Yes. Best example is MarshalAs attribute used for PInvoke.

Categories: .NET Framework
  1. Unknown
    November 20, 2008 at 4:25 am

    SEO焼酎インプラントキャッシング 比較レンタルサーバー美容整形不動産株式年金サプリメントビジネスマナー占い海外挙式アクセスカウンターオークションエステサイト売買バイク買取家庭教師自動車保険

  2. Unknown
    November 23, 2008 at 10:06 am

    您需要二手液晶显示屏、废旧液晶屏么?我们是不折不扣的二手液晶屏、旧液晶屏大批发商,长期大量供应可再利用的旧液晶屏。我公司提供的各种尺寸的二手液晶屏, 不同厚薄如笔记本屏,均已经过我们严格的分类,检验,测试流程。请访问协力液晶屏www.sceondhandlcd.com[bbibbcfhbadbffha]

  3. Unknown
  4. Unknown
  5. Unknown
  6. Unknown
    December 4, 2009 at 2:46 am

    http://www.batteryfast.com/hp/nc6120.htm hp nc6120 battery http://www.batteryfast.com/dell/inspiron-1100-series.htm dell inspiron 1100 series battery http://www.batteryfast.com/dell/inspiron-1150.htm dell inspiron 1150 battery http://www.batteryfast.com/dell/inspiron-5150.htm dell inspiron 5150 battery http://www.batteryfast.com/dell/inspiron-5160.htm dell inspiron 5160 battery http://www.batteryfast.com/dell/inspiron-5100.htm dell inspiron 5100 battery http://www.batteryfast.com/dell/latitude-131l.htm dell latitude 131l battery http://www.batteryfast.com/dell/vostro-1000.htm dell vostro 1000 battery http://www.batteryfast.com/dell/gd761.htm dell gd761 battery http://www.batteryfast.com/dell/nt379.htm dell nt379 battery http://www.batteryfast.com/dell/latitude-d531.htm dell latitude d531 battery http://www.batteryfast.com/dell/precision-m65.htm dell precision m65 battery http://www.batteryfast.com/dell/vostro-1700.htm dell vostro 1700 battery http://www.batteryfast.com/gateway/8msb.htm gateway 8msb battery http://www.batteryfast.com/hp/pb992a.htm hp pb992a battery http://www.batteryfast.com/hp/dv2100.htm hp dv2100 battery http://www.batteryfast.com/hp/dv2200.htm hp dv2200 battery http://www.batteryfast.com/hp/hstnn-c29c.htm hp hstnn-c29c battery http://www.batteryfast.com/hp/nc8000.htm hp nc8000 battery http://www.batteryfast.com/dell/inspiron-b120.htm dell inspiron b120 battery http://www.batteryfast.com/dell/inspiron-b130.htm dell inspiron b130 battery http://www.batteryfast.com/gateway/12msbg.htm gateway 12msbg battery http://www.batteryfast.com/hp/7400.htm hp 7400 battery http://www.batteryfast.com/dell/inspiron-b120.htm dell inspiron b120 battery http://www.batteryfast.com/toshiba/pa3356u.htm toshiba pa3356u battery http://www.batteryfast.com/hp/2510p.htm hp 2510p battery http://www.batteryfast.com/hp/f3172a.htm hp f3172a battery http://www.batteryfast.com/dell/inspiron-2200.htm dell inspiron 2200 battery http://www.batteryfast.com/gateway/squ-414.htm gateway squ-414 battery http://www.batteryfast.com/hp/hstnn-lb33.htm hp hstnn-lb33 battery http://www.batteryfast.com/mitac/bp-8089.htm mitac bp-8089 battery http://www.batteryfast.com/toshiba/satellite-m55.htm toshiba satellite m55 battery http://www.batteryfast.com/toshiba/satellite-m115.htm toshiba satellite m115 battery http://www.batteryfast.com/toshiba/qosmio-f25.htm toshiba qosmio f25 battery http://www.batteryfast.com/toshiba/satellite-m60.htm toshiba satellite m60 battery http://www.batteryfast.com/toshiba/satellite-p200.htm toshiba satellite p200 battery http://www.batteryfast.com/toshiba/pa3536u-1brs.htm toshiba pa3536u-1brs battery http://www.batteryfast.com/hp/hstnn-db17.htm hp hstnn-db17 battery http://www.batteryfast.com/acer/aspire-5520.htm acer aspire 5520 battery

  7. Unknown
    December 8, 2009 at 4:36 am

    http://www.bestcooldesigner.com/menslosangeleskings99gretzkyccmcpatchblack-p-7077.html Men’s Los Angeles Kingshttp://www.bestcooldesigner.com/menslosangeleskings99gretzkyccmcpatchblack-p-7077.html Men’s los angeles kings

  8. Unknown
    December 16, 2009 at 8:28 am

    http://mycooldesigner.com/ed-hardy-men-long-tshirts-c-17.html Ed Men Long T-Shirtshttp://mycooldesigner.com/ed-hardy-women-hoody-c-15.html Ed Hardy Women Hoodyhttp://mycooldesigner.com/ed-hardy-women-hoody-c-15.html ed Hardy Women Hoodyhttp://mycooldesigner.com/gd-tshirts-c-37.html G&D T-Shirts

  9. Unknown
  10. Unknown
  1. November 19, 2010 at 11:01 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: