Friday, December 7, 2007

Namespace Alias Qualifier

 

I have noticed a trend with code auto-generated from Microsoft tools.

 

Here is a sample section of code as I would have viewed it in older samples:

Code Snippet

   23     [System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName = "PizzaModel", Name = "PizzaOrder")]

   24     [System.Runtime.Serialization.DataContractAttribute()]

   25     [System.Serializable()]

   26     public partial class PizzaOrder : System.Data.Objects.DataClasses.EntityObject {

 

This is the exact same code, except it includes the more recent changes that I happened to notice:

Code Snippet

   23     [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName = "PizzaModel", Name = "PizzaOrder")]

   24     [global::System.Runtime.Serialization.DataContractAttribute()]

   25     [global::System.Serializable()]

   26     public partial class PizzaOrder : global::System.Data.Objects.DataClasses.EntityObject {

 

Notice the reference to 'global::'? Apparently, Visual Studio and ultimately the compiler can potentially be confused.

 

Here is a link to the Namespace Alias Qualifier:

http://msdn2.microsoft.com/en-us/library/c3ay4x3d(VS.80).aspx

 

According to that sample, you may have a namespace TestApp and within that TestApp namespace have a constant named Console within a class named System. The example also shows a using statement referencing the namespace System. That combination is apparently deadly to the compiler and even though Console.WriteLine() exists within the System namespace; it cannot be referenced because it conflicts with the Console constant. Here is the "non-working" code:

Code Snippet

    1 using System;

    // yada yada ...

    8     class TestApp {

    9         // Define a new class called 'System' to cause problems.

   10         public class System { }

   11 

   12         // Define a constant called 'Console' to cause more problems.

   13         const int Console = 7;

   14         const int number = 66;

   15 

   16         static void Main() {

   17             // Error  Accesses TestApp.Console

   18             //Console.WriteLine(number);

   19         }

   20     }

 

To the rescue: We have the 'global::' namespace qualifier available which forces a namespace comparison to be  based on the entire namespace starting from the root. I can only assume that namespace collisions (at least for Microsoft) happen more often than we assume; especially, when code generators are involved.

It is one thing to create and compile code within Visual Studio, but its entirely different if you are creating/ managing a code generator where you can never be sure of namespace conflicts. I happen to use CodeDOM (http://msdn2.microsoft.com/en-us/library/y2k85ax6.aspx) and understand completely how this could benefit my auto-generated code.

If you auto-generate code, it may be wise to to include a global reference similar to the new trend I am noticing. If you do not, this post may be helpful to simply understand the global reference.

 

 

 

Entity Framework Model Designer

I am just making a post to my BLOG here so that I can share an issue with the layout algorithm of the model designer with users in the Microsoft forum. Essentially I am showing the the automatic layout function could be improved (IMO).

 

Here are two images of the designer after choosing 'Layout Diagram' in the model editor. The model is the AdventureWorks database.

 

EntityModel-1

 

EntityModel-2

Technorati Tags: ,,,

 

The top image shows how text is overlapped and the diagrams are crammed together. The bottom image shows the entire layout where the algorithm clearly fails to use width appropriately.

Wednesday, December 5, 2007

eBay - Worse than SPAM?

I happened to be checking on current prices for the Nintendo Wii game console and browsed the listings on eBay.

 

Here are a couple of screen shots showing the search results:

This is of the "featured items":

Wii-1

 

... and this one is from "Highest to Lowest" pricing:

Wii-2

 

WOW!! the pricing of "featured items" ranged from ~$1,700 to $20,000 US. In the regular listings, the highest priced Nintendo Wii was listed at $5 million!!!

 

I suppose we all wish that we could list an item and receive far more than its worth (like millions more and simply retire). Surely we can all expect, out of the "goodness" of someone's heart, such outrageous purchase prices - but - seriously - this is making eBay the equivalent of a rotten Email program that not only doesn't block any SPAM; it supports and promotes the creation of SPAM. Ebay's listings are simply becoming inundated with more and more garbage and finding valid items within this slue of garbage is becoming ever more problematic.

From my view, it is becoming so hard to sift through search results that eBay is becoming a joke. I am not sure what can be done - maybe a rule that forbids pricing above suggested retail without some truly valuable and tangible asset being added to the item? Maybe separating these baloney listings into a separate category?

 

Is eBay becoming too cluttered with such garbage for you as well? What are your ideas or suggestions for eBay?

Technorati Tags: ,,