Ref: Scott Hanselman
Senior Developers/Architects (Part I)
- What’s wrong with a line like this?
DateTime.Parse(myString)?
A: 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.
- What are PDBs? Where must they be located for debugging
to work?
A: 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?
A: Cyclomatic complexity is a software metric (measurement) in
computational complexity theory. It is used to measure the complexity of a
program. It directly measures the number of linearly independent paths through
a program’s source code. Cyclomatic complexity is computed using a graph that
describes the control flow of the program. The nodes of the graph correspond to
the commands of a program. A directed edge connects two nodes if the second
command might be executed immediately after the first command. This is done by
counting the number of closed loops in the flow graph, and incrementing that
number by one.For more info: 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.
A: 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?
A: 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?
A: Allows administrators to see exactly which permissions
your application needs to run, using PermViewPrevents
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.
- What does this do? gacutil /l | find /i
"Corillian"
A: 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
A: 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?
A: 135 is used by Windows RPC.
HKEY_LOCAL_MACHINESoftwareMicrosoftRpcInternet (Key) Ports (Multi Line
String Value) specifies what other ports will be open.
- Contrast OOP and SOA. What are tenets of each?
A: 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?
A: 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
“System.Xml.Serialization.XmlSerializer(Type)
System.Xml.Serialization.XmlSerializer(Type,String) “
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
- Why is catch(Exception) almost always a bad idea?
A: 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?
A: 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: 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://p2p.wrox.com/topic.asp?TOPIC_ID=16066
http://www.hanselman.com/blog/PermaLink.aspx?guid=a40c0d4f-66d0-4704-94f6-0efda4a44465
No comments:
Post a Comment