转载自: http://sendhil.spaces.live.com/blog/cns!30862CF919BD131A!583.entry?wa=wsignin1.0&sa=534101846
Answers to Senior Developers/Architects
- 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 - 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. - 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 - 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 - 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. - 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 - 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). - What does this do? sn -t foo.dll
Extracts the publick key token from the strongly named assembly foo.dll - 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_MACHINE\Software\Microsoft\Rpc\Internet (Key) Ports (Multi Line String Value) specifies what other ports will be open. - 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 - 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 constructorsSystem.Xml.Serialization.XmlSerializer(Type)
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
System.Xml.Serialization.XmlSerializer(Type,String) - 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. - 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.
- 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.
http://p2p.wrox.com/topic.asp?TOPIC_ID=16066
http://www.hanselman.com/blog/PermaLink.aspx?guid=a40c0d4f