Tuesday, October 25, 2005

Ajax or JavaScript Remote Scripting?

We are supporting a Microsoft™ Remote Scripting (MSRS) application at work. It's been an absolute nightmare. I am nearly two years into this application and the shear amount of patches that must go in prevent us from being able to replace the MSRS code. What's more, the MSRS code is nearly impossible to efficiently debug especially when the original developer was a hack. It's like trying to piece together a grenade after it goes off.

There are quite a few options out there since my first foray into remote scripting. When I say remote scripting I mean real remote scripting using JavaScript Remote Scripting. I first learned about his from Brent Ashley's site at Ashley IT around four years ago. It was powerful then and still is. Microsoft™'s recent release of Atlas has harnessed the potential that JSRS began.

There a some great examples of remote scripting that are worthwhile to review. These include: Google Mail, Hotmail Beta, and Microsoft's Live Office.

Monday, October 24, 2005

SharePoint Web Parts Development Guide

I built my SharePoint Web Parts development environment. I will get into why I am building this in a future post, but for now, you should just follow along and stop asking questions =)

Prerequisites
There are a couple tools you need to get Visual Studio .NET 2003 setup. The first is to get a copy of the Microsoft.SharePoint.dll assembly and copy it to your development PC. You can find the DLL on your SharePoint server located, by default, in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\ISAPI. Put it in a location you will not forget but can easily recognize its importance. I chose C:\Development\SharePoint\WebParts for mine. The second tool you will need is really not a tool, but if you want an idea about what you are developing with, get the less-than-robust SharePoint Products and Technologies 2003 Software Development Kit that Microsoft provides. Hey, some documentation is always better than none! Finally, download the Web Part Templates for Visual Studio .NET. This will get VS.NET ready with some nice templates to see some code in action.



Ready for Action
When you open VS.NET you can select File > New > Project. You will see a new option for Web Part Library. If you installation of the Web Part Templates went well your new project will load.


Otherwise, you might see an error saying that the Microsoft.SharePoint.dll could not be found and that you should reinstall the templates. In fact, I received that error. I chose to ignore and just added the dll to the project’s references.

Stay tuned for my next post...

Wednesday, October 12, 2005

Questions for C# Component Developers

  • Juxtapose the use of override with new. What is shadowing?
    • Override redefines an inherited method which was marked as virtual or abstract,and its access level must be the same as the method it overrides. New allows you to completely hide an inherited member and create a different implementation of it with whatever attributes you choose. Shadowing is another name for disabling an inherited method and redefining it.
  • Explain the use of virtual, sealed, override, and abstract.
    • Virtual marks a method as overridable. Sealed marks a class as uninheritable. Override redefines a method declared as virtual. Abstract defines a class which cannot be instantiated, or a method which must be overriden in any derivedclasses.
  • Explain the importance and use of each component of this string: Foo.Bar,Version=2.0.205.0, Culture=neutral, PublicKeyToken=593777ae2d274679d
    • Assemblyname -- used for loading. Assembly version -- also used for loading.Culture -- defines culture settings used for string translation andother locale-specific settings. PublicKeyToken -- used to uniquely identifythis assembly and prevent collisions.
  • Explain the differences between public, protected, private and internal.
    • Public:accessible from any class. Private: accessible only from within the same class. Protected: like private, but derived classes may also access. Internal:like public, but accessible only by code within the same assembly.
  • What benefit do you get from using a Primary Interop Assembly (PIA)?
    • APIA is a strongly-named assembly which defines COM interfaces for a component.Because it is strongly-named, it can be loaded into the GAC and verified against the COM component's own signature to give the component collision-protection and authorship-verification benefits when interacing with .NET code.
  • By what mechanism does NUnit know what methods to test?
    • Readingattributes defined for classes and methods via reflection.
  • What is the difference between: catch(Exception e){throw e;} and catch(Exceptione){throw;}
    • Both statements will catch and throw exception, butthe latter will preserve the original exception stack.
  • What is the difference between typeof(foo) and myFoo.GetType()?
    • The first returns the object's type at compile time; the second returns itat runtime.
  • Explain what’s happening in the first constructor:public class c{ public c(string a) : this() {;}; public c() {;} } How is this construct useful?
    • The first constructor invokes the base constructor in addition to its own functionality; this wouldbe useful if your base initialized basic field values or had other code that all other constructors would utilize.
  • What is this? Can this be used within a static method?
    • The "this" reference refers to the current object context. Static methods have no context,so it is not valid.

Questions for Senior Developers/Architects

  • What’s wrong with a line like this? DateTime.Parse(myString);
    • Doesn'tspecify a locale or format.
  • What are PDBs? Where must they be located for debugging to work?
    • Program Database files. They contain references that connect the uncompiled code to the compiled code for debugging. They must be located either in the same place as the EXE/DLL, or in your VS.NET specified symbols path.
  • Whatis cyclomatic complexity and why is it important?
    • It's a measure of the number of independent linearly executed paths through a program. It's important for judging the complexity of software and assisting in determinations of which modules should be refactored into smaller components.
  • Write a standard lock() plus “double check” to create a critical section around a variable access.
    • bool notLocked = true;
          if (notLocked) {
              lock (typeof(lockingObject)){
                  if(notLocked) {
                      notLocked= false;
                      foo= lockingObject;
                      notLocked= true;
                  }
              }
          }
  • What is FullTrust? Do GAC’ed assemblies have FullTrust?
    • FullTrust means all .NET security permissions are granted to the assembly. GAC assemblies have FullTrust by default, but that can be changed by the user's security policy.
  • What benefit does your code receive if you decorate it with attributesdemanding specific Security permissions?
    • Allows administratorsto see exactly which permissions your application needs to run; prevents your code from being exploited beyond what permissions it absolutely needs; allows your application to forcibly fail instead of havingto manually handle situations where it might be denied permissions it requires.
  • What does this do? gacutil /l | find /i "Corillian"
    • Lists all assemblies in the GAC, searching for those whose names contain "Corillian".
  • What does this do? sn -t foo.dll
    • Shows the token for foo.dll.
  • What ports must be open for DCOM over a firewall? What is the purpose of Port 135?
    • 135 for the service control manager, 1024-65535 (or whatever range the administrator has restricted DCOM to) for applications.
  • Contrast OOP and SOA. What are tenets of each?
    • OOP tries to encapsulate functionality required to operate on data with the data structure itself, making objects "self-reliant". SOAaims to decouple functionality from data entirely, using interfaces to allow functional components to operate blindly with as little understanding of the precise nature of the data they're fedas possible, allowing many types of data sets to be fed into them for the same operation.
  • How does the XmlSerializer work? What ACL permissions does a process using it require?
    • Reflects the object and reads its interfaces to serialize them. Requires the .NET ReflectionPermission, obviously.
  • Why is catch(Exception) almost always a bad idea?
    • Because itswallows an exception without doing anything with it. The only timethis should really be used is when trying risky casts that you expect to have a reasonable likelihood of failure, but always of a very specific type.
  • What is the difference between Debug.Write and Trace.Write? When should each be used?
    • Debug.Write isn't compiled in if the project isn't built with the DEBUG symbol. Trace.Write calls are compiled regardless.
  • What is the difference between a Debug and Release build? Is therea significant speed difference? Why or why not?
    • Release buildsdon't contain debug symbols and are more compact and optimized.
  • Does JIT-ing occur per-assembly or per-method? How does this affect the working set?
    • Per-method. This affects the working set because methods that aren't lined up for calls aren't loaded, reducing its footprint.
  • Contrast the use of an abstract base class against an interface?
    • Abstract classes can provide implementations for methods and properties. Interfaces only provide required declarations.
  • What is the difference between a.Equals(b) and a == b?
    • The first uses the object's equivalency constructor to see if it considers itself value-equal to the the second object. The second construct compares their memory references to determine if they are the SAME object.
  • In the context of a comparison, what is object identity versus object equivalence?
    • Identity means that two references point to the same memory address. Equivalence means that two objects share the same value.
  • How would one do a deep copy in .NET?
    • Implement the IClonable interface, and define your implementation to execute deep copies on your sub objects (possibly through IClonable interfaces). Alternatively, serialize the objectand then deserialize it into another object, but this is very slow compared to a dedicated cloning interface.
  • Explain current thinking around IClonable.
    • IClonable is preferable to using copy constructors because it is standardized and utilized by other portions of the.NET framework to generate object copies.
  • What is boxing?
    • Taking a value type and converting it to an object reference. Unboxing is the reverse process.
  • Is string a value type or a reference type?
    • It's an "illusionary value type" that masks an interface to the System.Stringreference type.
  • What is the significance of the "PropertySpecified" pattern used by the XmlSerializer? What problem does it attempt to solve?
    • Defines the specific parameters that .NET class members serialize into. Solves the issue of an XML spec needing to have slightly different names for class members than the class itself does.
  • Why are out parameters a bad idea in .NET? Are they?
    • Output parameters create uncertainty about the data which may be returned from the function, and permit the caller to potentially pass bad references which your function must validate before using. From a design standpoint, it's more elegant to define a custom class with multiple properties in the event that youneed to return multiple values from a single function.
  • Can attributes be placed on specific parameters to a method? Why is this useful?
    • Yes. This might be needed to specify remoting implementations or types for method parameters, or to provide metadata for method parameters when exporting a code library.
Mid-Level .NET Developer
  • Describe the difference between Interface-oriented, Object-orientedand Aspect-oriented programming.
    • Interface-oriented programming means defining and working strictly through interfaces.
    • Object-oriented programming means defining defining a program using relationships between objects a classes (inheritance, polymorphism etc.)
    • I've heard the buzz about AOP (aspect-oriented programming)but I have yet to study what exactly does it mean...
  • Describe what an Interface is and howit’s different from a Class.
    • An interface defines a contract without implementation. A class implements an interface.
  • What is Reflection?
    • Reflection is used to query .NET assemblies and types for information. It can also be used to create type instances, invoke methods and even emit .NET code at runtime (Reflection.Emit).
  • What is the difference between XML Web Services using ASMX and .NET Remoting using SOAP?
    • I've never used .NET remoting but I assume the difference is that remoting is not as interoperable as web services.
  • Are the type system represented by XmlSchema and the CLS isomorphic?
    • No.
  • Conceptually, what is the difference between early-binding and late-binding?
    • When using early-binding the call information is known atcompile time.
      When using late-binding the call information is only known at runtime.
  • Is using Assembly.Load a static reference or dynamic reference?
    • Dynamic reference.
  • When would using Assembly.LoadFrom or Assembly.LoadFile be appropriate?
    • For loading assemblies from given file or folder (such as plugins etc).
  • What is an Asssembly Qualified Name? Is it a filename? How is it different?
    • The Assembly Qualified Name contains the assembly name, versionand public key token and thus allows
      versioning and singing as opposed to a simple filename.
  • Is this valid? Assembly.Load("foo.dll");
    • No because "foo.dll" is not anassembly qualified name.
  • How is a strongly-named assembly different from one that isn’t strongly-named?
    • Strongly-named assemblies are signed using a private\publickey pair which helps with code verification.
      signed assemblies could be placed in thee GAC.
  • Can DateTimes be null?
    • No because it is a structure and not a class.
  • What is the JIT? What is NGEN? What are limitations and benefits ofeach?
    • JIT means Just In Time compilation which means the code isbeing compiled just before it is supposed to run.
      This means longer startup time (because the code takes some time to compile) but more efficient compilation (since the compiler has more information about the target system etc.).
      NGen is used to pre-JIT code which yields faster startup time but the compiler produces less efficient code because it has less information.
  • How does the generational garbage collector in the .NET CLR manage object lifetime? What is non-deterministic finalization?
    • It divides the objects into three generations.
      The first generation is used for short lived objects and iscollected often (its cheap to collect it).
      The other two generations are used for longer term object.
      Non-deterministic finalization means that it is not known when the object's finalizer is called since it is called when the GC decides to collect the object and not when the object falls outof scope etc.
  • What is the difference between Finalize() and Dispose()?
    • Finalize() is called by the runtime (the GC) and Dispose() is called by the user.
  • How is the using() pattern useful? What is IDisposable? How does itsupport deterministic finalization?
    • The using statement defines a scope at the end of which agiven object will be disposed.
      Using the 'using statement' helps not to forget disposing of a disposable object.
      IDisposable is an interface used to define a way to dispose of objects in a deterministic manner.
      When the 'using statement' scope ends the Dispose() method is automatically called on the given object.
  • What does this useful command line do? tasklist /m "mscor*"
    • It shows all the processes that loaded a DLL with a name matching the given pattern. In this case we will see all the processes using the .NET framework.
  • What is the difference between in-proc and out-of-proc?
    • out-of-proc requires marshaling between two processes and thus slower.
  • What technology enables out-of-proc communication in .NET?
    • Remoting.
  • When you’re running a component within ASP.NET, what process is it running within on Windows XP? Windows 2000? Windows 2003?
    • The ASP.NET worker process
Things Everyone Who Writes Code Should Know
  • Describe the difference between a Thread and a Process?
    • A process is a collection of threads (at least one) sharing the same resources (virtual memory, security context etc.). A thread is an entity in a process that can actually be executed on the CPU.
  • What is a Windows Service and how does its life cycle differ from a "standard" EXE?
    • A Windows Service is a program that conforms to the rules of the SCM (Service Control Manager). The main difference is that it does not need a logged on user to activate it.
  • 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?
    • Ok, I admit I had to check the MSDN documents for this.
      The maximum virtual memory for a 32-bit system is 4GB of which 2GB are availble to the user processes (3GB running a special configuration).
      This affects system design when when designing for memory intensive applications such as databases, enterprise applications etc...
  • What is the difference between an EXE and a DLL?
    • An EXE is an EXEcutable that contains an entry point and instructions to execute. A DLL only contains pieces of functionality to be used by an EXE (or another DLL).
  • What is strong-typing versus weak-typing? Which is preferred? Why?
    • strong-typing means a strict enforcement of type rules with no exceptions as opposed to weak-typing which allows well defined exceptions (such as assigning an int to a float in C++).
      While strong-typing can prevent many type errors, weak-typing is much more developer "friendly".
      I assumed the preffered enforcement mechanism depends on the application at hand...
  • Corillian's product is a "Component Container." Name at least 3 component containers that ship now with the Windows Server Family.
    • I really have no idea what a "Component Container" is.
  • What is a PID? How is it useful when troubleshooting a system?
    • Process Identifier. I have never used it myself but I assume it can be used to kill the process or for logging\debugging purposes.
  • How many processes can listen on a single TCP/IP port?
    • I am not 100% sure but I think the answer is One.
      The result of two or more processes listening to the same port would be erroneous since they'll be "stealing" each other's revieved information.
  • What is the GAC? What problem does it solve?
    • Global Assembly Cache. It resolves DLL hell, versioning etc...

Monday, October 03, 2005

Double Honor Points
Blizzard gave us double honor points this weekend bringing Alterac Valley back to life once again. It was nice to get back into full-scale PVP. The only problem with this, besides its brevity, was that people in the raid were averaging 8-10 honor points per kill. Am I wrong when I suggest a revamp of how the system works on a per-PVP-instance basis?

Sunday, September 18, 2005

Arathi Basin
Since the release of version 1.7, World of Warcraft has seen a major shift in battlegrounds play. The Arathi Basin offers short, fast action play for the masses. What does this mean for Alterac Valley and Warsong Gulch?

Alterac Valley has shown itself to be the place for die-hard gamers. The battles could last hours, and a character could rack up thousands of honor points in a day. Arathi has changed all that. Because of the honor system, honor points would rapidly go down after you killed the same person several times. While you would get plenty of honorable kills defending your village, honor points would be lacking, especially if you were in a raid group. Playing Arathi has shown that an hour or two can yield the same contribution points that Alterac Valley gave.

Warsong Gulch continues to be popular for the same reason Arathi is now. The short battles, and quick action, allows gamers to quickly gain reputation and access to the respective clan's items.

We are just five days into version 1.7 and there has been on single Alterac Valley battle on Magtheridon. Is this the end of Alterac Valley? What can Blizzard do to make it popular again?

Wednesday, September 14, 2005

Blogger.com Beats MSN's Spaces
Google's blogger is vastly superior to MSN's. Again, Google beats them with no ads and ease of use. What's more, you can post your blog to the ISP of your choice, or for free at blogspot.com. Hmm, maybe blogspot.com has ads? Now I have to check!