Welcome to U E T - C S . org Sign in | Join | Help

Osama Abbas

the Answers to Life, the Universe, and Everything
the demise of Facebook

I hate social networking.

Not because I'm opposed to the concept, but because of retards, weirdos, groupies and attention seekers. These are a curious lot who will wander from one social network to another looking for attention by creating, joining and advocating "groups" based on as mundane of subjects as their favorite flavor of ice cream. A race for artificially large "friend" lists ensues, and all usefulness of the relationship network of the social networking site is lost. But I'm not writing this post to whine about these people. I'm writing to protest their onslaught on Facebook.

I'm not a member of Orkut, never was and never will be. Neither did I ever join Myspace or the dozens of other social networks popping up every week. Why ? because by the time I got interested in social networking, the retards had already entrenched themselves there. I realize the power and usefulness of the social network and the only network with some sanity left was Facebook. So I joined. It was wonderful.

Back then, Facebook revolved more around the 'Me' than the 'Us'. There was more emphasis on a detailed and flexible user profile and all connections and relationships were based on real world ones. Networks and groups were based on Location, School, University or Workplace, all concrete bases for expressing relationships between people. The result of this 'restriction' is that the a person's profile and identity is much more 'authentic' than other social networks. This basically stopped / slowed the onslaught of people flooding in and creating ad-hoc groups and identities and lead to a far greater confidence in the system. A clean un-intrusive, no-nonsense interface and clever use of AJAX led to a very user friendly experience. All was good in the land of Facebook.

And then Facebook opened its gates. Ever since the site opened up its API to third party developers, there's been a flood of countless useless apps. The retards are flooding in and Facebook profile pages are beginning to resemble MySpace ones. People have dozens of apps on their profiles, most of them useless. The site has become slow, and there's now a deluge of useless notifications generated by applications being used by friends in my list. There are 'Walls' and 'Super Walls', people 'Poke' and 'Super Poke' each other for no productive purpose at all. Friends lists have started to grow into the hundreds, and Facebook has started turning into Myspace.

I simply adore the profile management capabilities of Facebook and I'm slowly trying to consolidate all my online profiles into one place. But the way things are going, I'm not sure how long my last online social refuge will last.

the Case of the Annoying J# Redistributable

Ever since I started using VS 2003, one thing that always ticked me off was why the J# redistributable was a pre-requisite for installing VS. If I don't want to use J# in any shape or form and there clearly isn't a dependency on it in the IDE then there's no need to install useless bits on my machine.

Today I was installing VS 2005 again and realized that the problem still hasn't gone away. I can still see a 114 MB J# Redistributable Package in Vista's Programs and Features list.

Doing some research I came across Aaron Stebner's blog who was once in the VS setup and deployment team and he's answered this complaint in quite an amount of detail. It also gives an insight into Microsoft's mentality of using customers as beta testers, making rushed releases and then fixing bugs over time with Service Packs and Hotfixes, but I'll leave this discussion for another time.

The explanation given is :

We considered putting the J# redist functionality into the .NET Framework 1.1, but rejected that for several reasons.  Then we considered including it in the main VS setup tree, but also rejected that because it is needed at runtime in addition to design time and we couldn't tell people to install a part of VS on their clients' machines in order to enable J# applications to work correctly.  We also tried to propose that the J# redist installation package be installed if the user chooses the J# programming language in the VS tree, and then the IDE could install it on demand or provide UI to guide the user to install it themselves if they really needed it.  This presented usability issues, caused an additional barrier to entry for J#, and also caused problems with administrative deployment scenarios where the end user was not an administrator when they were using the IDE and could therefore not install products themselves.

Source 

First of all, who uses J# anyway. It was a failed (and lame) attempt at hijacking Java. I forgive them for trying to push the J# bits through VS 2003, but after its spectacular failure in years afterwards, they should've just accepted their mistake and once and for all gotten rid of it.

And then along came VS 2005, totally redesigned from the ground up, tons of new tech, holding so much promise, but it turns out they STILL haven't removed the darn annoyance. So what explanation do they have to give this time ?

 " .... you can see that if the J# or Visual Web Developer language tools features are selected during setup, the J# redistributable will also be installed for you as a chained component.

The next question that has come up is one that I haven't addressed in that previous blog post - why does Visual Web Developer require the J# redistributable?  At a high level, the answer is that you are able to develop web applications in any number of programming languages, including J#, so therefore the J# redistributable is installed in case you decide to develop your web applications in J#.

That answer leads to one additional question - why can't you just install Visual Web Developer C# support or something like that if you know ahead of time that you are not planning to develop web applications in J#.  If you look at the feature tree for VS 2005 setup, you will see a single item under Language Tools named Visual Web Developer.  However, this feature is not sub-divided any further, so it is not currently possible to install only the pieces required to install Visual Web Developer C# support, Visual Web Developer VB support, Visual Web Developer J# support, etc.  We determined while developing VS 2005 that it would be very time-intensive and error-prone to try to sub-divide the Visual Web Developer features on a language-by-language basis, and that it would only have questionable benefit to the end user.  Therefore, we had to make a trade-off and the decision was made to live with the side effect of installing the J# redistributable package if the user chooses to install Visual Web Developer during VS 2005 setup (even if the user does not choose to install the J# language tools)"

Source 

In other words, we were too lazy or incompetent to properly partition functionality for multiple languages so we decided the users wouldn't mind if we installed useless crap on their machines.

You know, you wouldn't be in this mess in the first place if you quit flogging the dead horse that is J#, concentrate on C#, VB.NET and other potential first class citizens of the .NET framework (like IronPython).

But all is not lost, it seems they've finally come to their senses and J# won't be included in the amazing goodness that is to be VS 2008. I say good riddance. Nobody likes you J#, so please stop bothering us all and GO AWAY !

IE layout engine mystery

I was looking into some browser quirks today and came across some interesting but confusing information.

The layout engine used by IE7 to render pages is named Trident. MSHTML or Trident was first introduced with Internet Explorer 4 way back in 1997. Over time Microsoft has been improving it and incrementally adding better standards support but its still old code and an old design.
Mozilla's Gecko and Opera's Presto are FAR superior to IE7 in terms of standards support and CSS compliance and yet MS keeps on flogging a dead horse.

What I found out today is that Internet Explorer 5 for Mac used a new layout engine called Tasman which was hailed for having the BEST support for web standards in its day. This was later embedded in a number of Microsoft apps like MSN Explorer and in the Office 2004 for Mac email client. But IE still keeps on using the same old Trident engine. Moreover Expression Web uses an entirely new rendering engine which MS is declaring to be the most standards compliant on the market. Plus, Office apps like Word etc. use their own HTML rendering engines (which suck).

WHY didn't Tasman replace Trident in IE7 is beyond me and I wont try to contemplate what Microsoft plans for IE8, but these guys should know that Mozilla will be using Cairo in Firefox 3.0 which promises a number of improvements over Gecko. Opera already passes the Acid2 test with flying colors.

MS needs to consolidate its efforts on ONE rendering platform and at least try to catch up to Firefox in terms of usability and features. IE7 was a sloppy job. I had hoped SO much that with the whole Vista momentum they'd finally fix IE7 but it turned out to be a big disappointment. And I'd like to clarify I'm no Microsoft hater, my workstation runs Windows XP, I code in C# and love Visual Studio. What hurts me is that my entire tool set consists of Microsoft products but when I need to browse, I simply cannot imagine using IE7. Its Firefox all the way !

As for IE8, I don't expect it to rock ... I'm just hoping it does suck as bad as IE7.

Enterprise Library 3 released !

Enterprise Library for the .NET framework 2.0 and 3.0 has finally been released. Some of the highlights are :

  • Validation Application Block. Allows you to centrally define validation rules using configuration or attributes, and easily validate data from anywhere in your application, including deep integration with Windows Forms, ASP.NET and WCF.
  • Policy Injection Application Block. Provides a powerful approach for separating cross-cutting concerns from business logic using declarative policies that are attached at runtime to methods on your objects.
  • Application Block Software Factory. Dramatically simplifies the process of building application blocks and providers through the magic of guidance automation.
  • Visual Studio-integrated Configuration Editor. Edit Enterprise Library configuration files directly within Visual Studio.
  • Environmental Overrides. Use the configuration tool to specify configuration settings that are common or different across multiple environments, and merge this information into configuration files to be deployed with your applications.
  • WCF Integration. Easily integrate the Logging, Exception Handling and Validation Application Blocks into service interfaces built using Windows Communication Foundation.
  • Pre-compiled, strong-named binaries. No need to compile and strong name the code unless you want to manage and evolve the code yourself.

 You can download the bits here.

ASP.net ListBox woes ...

Today I was working on a WebUserControl that basically contained two ListBoxes. One contained a list of items available and the other had all the selected items. A problem came up where when I selected an item in the available items list and tried to copy it to the other list, the SelectedIndex reported by the ListBox would be wrong. I tried every trick I could to fix it but the mysterious problem persisted. What puzzled me even more was that I had made a similar control a few days back and it worked flawlessly !

After a couple of hours of trial and error, I stumbled upon the real cause of the problem :

Every Item in the list has two properties, called Text and Value. Text dictates what is to be shown in the ListBox and Value basically acts like an index value. What I observed was that in my case, the Text values were unique but the Values were repeating for a number of items. Given the current circumstances, it was allright to have similar values for multiple items. The problem lies in the ASP.net ListBox which does not like this kind of condition. I had to wrangle with multiple joins to use a different column to bind to the ListItem Value .. but this eventually solved my problem.

Moral of the story :
If your ListBox is acting weird, check your value bound column for repeating values.
 

Pipes in .NET !

I always thought IPC through pipes was a UNIX only thing. Infact its one of those things Linux fanboys try to bring up in every Linux vs Windows discussion. Today I was shocked to know that pipes have been in Windows all this time !

I found out on the BCL Team's blog today that they released a wrapper over the Windows Pipes functionality back in the October 'Orcas' CTP !

These classes will be found in the System.IO.Pipes namespace and will provide interprocess comm. using two types of Pipes :

Anonymous Pipes

Anonymous pipes are character-based and are half-duplex.  They cannot communicate over the network and support only a single server instance.  These pipes are most useful for communication between threads or between parent and child processes where the pipe handles can be easily passed when the child process is created.

Named Pipes

Named pipes are far more powerful than anonymous pipes.  They can be duplex, over the network, and can support multiple server instances of a single name, making them ideal for quick-to-build, and easy to connect to, multithreaded servers.  Furthermore, they support message based communication so that a reading process can read varying-length messages precisely as sent by the writing process.  Finally, named pipes support impersonation allowing connecting processes to use their own set of permissions on remote servers.

So then comes the question, in the presence of this new API, how does WCF tie into the equation ? Well according to a comment posted on the blog :

" This is not part of WCF at the moment.  Pipes are a lower level channel the WCF could be built on top of. WCF actually has its own internal pipe implementation that it uses to achieve IPC.  In the future, WCF may switch to using the public pipe implementation that we're now providing. "

The BCL team seems to be doing a GREAT job and the upcoming release of .NET is packed full of amazing goodies. Infact I also found about a new obscure but very useful feature called the "Application Addin framework" that will make development of plugin enabled and extensible applications a LOT easier (will be discussing in detail later).

Microsoft HD Photo

I first came across HD Photo when Microsoft announced it would be releasing an image format to replace the ubiquitous but aging workhorse called JPEG. Back then it was called Windows Media Photo. The first thing that put me off me was the sheer lameness of the name which seemed to be going down the same path as the Windows Live branding scheme. It was a closed format and tied to Vista. There was no way this was gonna dethrone JPEG.

But recently, Microsoft did something very unexpected. They submitted the spec to ISO for ratification, opened up the format, removed licensing restrictions and renamed it to HD Photo.

Wanting to know what all the hoopla was about, I decided to look it up.

What I found out was good :

1) Supports both lossy and lossless compression.

2) Supports High Dynamic Range encoding. What this basically means is that it uses more bits per pixel thus allowing a wider dynamic range of brightness in images. I think this is gonna give the same benefit over JPEG as JPEG(16 million color) had over the GIF(256 color) format, only this time instead of providing a wider color range, its gonna provide a wider intensity range. Plus it provides a wide range of pixel formats allowing flexibility for both high-end and consumer uses.

3) It was designed for lightweight processors and low memory implementations. The entire algorithm only uses integer math (adds, shifts, limited multiplications and no divides) thus allowing implementation in low power ASICs and eventually into digital cameras.

3) Its a container type format like TIFF allowing one file to contain many images. This one container can also contain EXIF and other meta-data. The alpha channel is itself a separate image embedded with the parent container. This scheme allows creation of n-channel images.

4) Another feature which I really liked is that one .hdp file will be able to contain mip-maps of the main image thus allowing less-capable devices to load lower resolution versions from the very same file.

5) One of the best things I liked about this is that you can start viewing the image without loading the whole file into memory. Allowing cropping and zooming to take place very efficiently.

6) And the biggest benefit of all would no doubt be the compression ratio which is about 2.5 times that of JPEG while providing a higher PSNR. 

All in all my skepticism was totally unfounded. Microsoft has clearly done a good job here and most of the licensing ambiguities have been cleared up.

While JPEG has served us well over last two decades, I think its time to move on. JPEG was designed and created in an era of constrained system resources and limited bandwidth. The world has changed much since then and everyone seems to have a digital camera these days.

Adobe is pushing their new Digital Negative format but that seems to be a replacement for the proprietary RAW formats used by camera manufacturers.

HD Photo definitely has a market out there. Its now up to Microsoft to utilize the opportunity and not mess up. That would be a win-win for everyone.

VB.net Optional Parameters

When I was young (about a year or so ago ... ) I used to look at Optional parameters and say : wow .. this is so cool ... instead of writing 4 overloads for this function, I can simply write one master function with optional parameters. Convenient !

Later on in life, while going through a mid-life crisis, fixing VB.net code written by another programmer years ago, I came across a function that not only used optional parameters, but was also overloaded, plus had multiple versions with slightly different names. Refactoring this function made me go insane as the number of permutations was simply overwhelming ! That was the point where all love for O.Ps was gone.

During my relatively wiser years, I wondered, how does this feature work exactly ?
The first thing that came to mind was that the compiler automatically generates overloaded functions in IL at compile time.

I WAS WRONG

Passing the assembly through ILDASM revealed that [opt] is a supported feature of the runtime and C# does not support it (this is probably more of a design decision than a technical limitation).

OK. So optional parameters are an A class feature and not an LSD laced candy VB.net hack* .... I still think they're bad. There are a lot of reasons behind this but basically I feel it breaks the element of good design in your code, creates ambiguities and makes code harder to refactor or convert into other languages.

In my senile years, I'll probably shake my stick at all these new fangled language features and curse at them but for now ... lets all please just avoid them.

* is LSD addictive ? 

Reflector 5 Released !!!

Lutz Roeder has done it again .... a shiny new version of Reflector has been released ..

Thanks go out Scott Hanselman for the heads-up ! 

The new version comes with a ton of great new features detailed in this PowerPoint document.

Hurrah ! 

INVENTION !!!

wow .. I just invented my own tag line ......

 Licensed to INT 21,4C

(Hint : INT 21,4C is the interrupt routine used to KILL a process ..... ) 

I googled up to see if someone else had already come up with something like this ....

so far ... my originality is holding up ....  Comments plz :P

Why the Japanese lagged in the PC revolution ...

I've always wondered why the Japanese, being the most technologically advanced nation in the world, never really got into the computer business.

I mean ... these are the largest electronics manufacturers in the world and they dont even have a single well-known microprocessor manufacturer ! ( well not exactly valid because Sony, Toshiba and IBM are now marketing the Cell processor ... )

But still, if they had entered the market during the 80's we would definitely have been using super efficient, high quality systems today, running cutting edge sushimitsu processors with cool anime wallpapers pre-loaded. 

Anyway .... looking around, I finally found a paper written by Jiro Kokuryo from Keio University, Japan that details the reasons for this common perception. Its an interesting read. Link

 

some DataSet discoveries

I needed to clone an existing Dataset into a new one today and was faced with two choices which the DataSet provided me :

1) DataSet.Clone()

2) DataSet.Copy()

As usual Google came to the rescue and and I found out the following :

The Clone() method copies the structure of the DataSet, including all DataTable schemas, Relations and Constraints. But it does not copy any data.

The Copy() method copies both structure and Data.

More info here

Another thing was the difference between DataSet.Clear() and DataSet.Reset()

Found out that Clear() just removes data, whereas Reset removes Data, Tables and Relations.

Char literals in VB.net

I created a char variable in VB.net and needed to assign a single character to it.

Sounds simple doesn't it ?? Try doing it with Option Strict On

By default the following code will execute without problems :

      Dim charVariable as Char = "x"

Here we are assigning a string literal to a char variable. VB.net allows this as it performs type checking and casting at run-time. So the string literal "x" is automatically cast to char.

But with Option Strict On , strict type checking is performed at compile time and the code above will be highlighted as erroneous.

Now here comes to weird part, in C# you can write a char literal like so : 'x'

But you cant write a char literal like this in VB because the hyphen is used for comments.

So, as I found out , in order to assign a char literal to a char in VB.net, you need to append a format specifier to the literal like so :

        Dim charVariable as Char = "x"c

[Note the small c after the literal.]

This is the answer to the problem !!!

WMI

I got to work a bit on Windows Management Instrumentation the other day .....

Well, most people don't know about this so I'll just paste a definition from Wikipedia :P

"Windows Management Instrumentation (WMI) is a set of extensions to the Windows Driver Model that provides an operating system interface through which instrumented components can provide information and notification."

Basically its a set of APIs provided by Microsoft allowing you to monitor and control a lot of administrative aspects of your system.

Most of you have probably interacted with this through the MMC in Control Panel -> Administrative Tools

Before WMI, programmers had to hunt the registry for scraps of information about the system, and if their required information wasn't there, they would have to write low-level assembly to get detailed specs like Processor speed or hard drive volume information.

Now, all this info is exposed through a set of standard classes which is a great plus.

Allright ..... time for the juicy stuff .....

I'll start off by getting processor info from the system.

The first step is to add a reference to a .net assembly called System.Management to your project

Obviously, you would also need to import the same namespace into the class where you need to perform this action.

From here on, the code is pretty straightforward.


public string GetCPUId()
        {
            string cpuInfo =  String.Empty;
            string temp=String.Empty;
            ManagementClass mc = new ManagementClass("Win32_Processor");
            ManagementObjectCollection moc = mc.GetInstances();
            foreach(ManagementObject mo in moc)
            {
                if(cpuInfo==String.Empty)
                {// only return cpuInfo from first CPU
                    cpuInfo += mo.Properties["ProcessorId"].Value.ToString();
                    cpuInfo += "\n";
                    cpuInfo += mo.Properties["Manufacturer"].Value.ToString();
                    cpuInfo += "\n";
                    cpuInfo += mo.Properties["Caption"].Value.ToString();
                    cpuInfo += "\n";
                    cpuInfo += mo.Properties["MaxClockSpeed"].Value.ToString();
                    cpuInfo += "\n";
                    cpuInfo += mo.Properties["L2CacheSize"].Value.ToString();
                    cpuInfo += "\n";
                }            
            }
            return cpuInfo;
        }


you can also get other useful information like volume information from the hard drive :

     public string GetVolumeSerial(string strDriveLetter)
        {
            if( strDriveLetter=="" || strDriveLetter==null) strDriveLetter="C";
            ManagementObject disk =
            new ManagementObject("win32_logicaldisk.deviceid=\"" + strDriveLetter +":\"");
            disk.Get();
            return disk["VolumeSerialNumber"].ToString();
        }

or the MAC address from your Network card :


        public string GetMACAddress()
            {
            ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
            ManagementObjectCollection moc = mc.GetInstances();
            string MACAddress=String.Empty;
            foreach(ManagementObject mo in moc)
            {
                if(MACAddress==String.Empty)  // only return MAC Address from first card
                {
                    if((bool)mo["IPEnabled"] == true) MACAddress= mo["MacAddress"].ToString() ;
                }
                        mo.Dispose();
            }
            MACAddress=MACAddress.Replace(":","");
            return MACAddress;
            }



 ... thats all folks !!!

Have fun !

... more EntLib goodness ...

I love Microsoft's Enterprise Library . I implemented a basic caching framework in our app at work some time ago using their Caching Application Block.
Today it was decided we needed to take it one step further so that it should monitor cache stats such as hit ratio, object count etc and adjust the expiration policies accordingly.

Seemed like a lot of work .... until I found out that EntLib creates a number of performance counters that can be queried using WMI. So I tried it out and it works like a charm !

You can monitor stats for the Caching Block in real-time using the Performance monitoring app in Windows, or query the data programmatically from WMI.

More Posts Next page »