System.Configuration Namespace and Obsolete Functions

‘What Really Grinds My Gears’ (WRGMG) topic of the month:

Have you ever wondered why after adding System.Configuration namespace reference you see a link to System.configuration assembly (note a small ‘c’ instead of the capital one)?

And why calling obsolete functions in order to access your AppSettings through System.Configuration.ConfigurationSettings.AppSettings["myKey"] doesn’t require you adding any additional references, but using System.Configuration.ConfigurationManager.AppSettings["myKey"] requires you going to the project’s Add Reference dialog and adding System.Configuration explicitly?

The reason for that is unfortunately somewhat poor framework design, in particular backward compatibility implementation. In .NET versions starting from 2.0, class System.Configuration.ConfigurationSettings is actually stored in System.dll, and is basically a stub pointing to System.Configuration.ConfigurationManager, which exists in System.configuration.dll (note again small ‘c’).

Here is a good explanation in one of the older blog posts System.configuration.

However, as always the ultimate reference is good ole’ Reflector, which allows you to find exactly where each class is stored, and to peek inside implementation details. Such as delegated calls from deprecated stub class ConfigurationSettings (System.dll) to the new ConfigurationManager (System.configuration.dll).

Web Site Performance and JPEG Compression

As a consultant, throughout stabilizing and deployment phases, I get frequently asked to investigate performance of specific web pages or whole sites, in order to improve page rendering speed, lately more and more related to SharePoint environment.

And what I often see in breakdown of page rendering that it is not that server execution time, which lags behind and causes visual delays, but the size and amount of creative content, which was put on the web site – images and flash files. The easiest way to quickly look at the page load timing breakdown is probably by using FireBug’s Net tab, as it’s shown on this illustration.

There are many ways to optimize and enhance performance of specific web pages and web sites in general. One of the great examples of the process and approach to optimization, is documented in the blog of Microsoft SharePoint team, which has done amazing job speeding up SharePoint.Microsoft.com.

However, in this post, rather than talking about optimization in general, I want to draw your attention to one highly overlooked issue – the size of creative media content used on production web sites, specifically size of JPEG images and Flash pieces relying heavily on imagery.

Back in the days, when I was working in video encoding industry, I used to spend large chunk of my time working with different JPEG settings and libraries for motion JPEG video compression. JPEG has many different implementations, and all image editing software programs, such as PhotoShop, Picasa, Paint, etc. use their own libraries with proprietary JPEG-compression, which differs in compression speed, parallelism, and quality.

However, they all have one thing in common – a configurable characteristic of compression quality, often expressed in per centage, or 0-100. You can read more on JPEG compression quality on wikipedia, with lots of great examples and comparisons.

But I would like to compare samples, which are closer to real life situation, such a simple web site banner, and show what programs you can use to optimize image file compression.

Here’s a sample image saved with different image quality:

Original Image – PNG, Image size: 43KB
apticonlogo

JPEG Image – Quality: 100% (PhotoShop compression quality: Maximum), Size = 24KB
apticonlogo99

JPEG Image – Quality: 80% (PhotoShop compression quality: Very High), Image Size: 14KB
apticonlogo80

JPEG Image – Quality 60% (PhotoShop compression quality: High), Image size: 12KB
apticonlogo60

JPEG Image – Quality 30% (PhotoShop compression quality: Medium), Image size: 6KB
apticonlogo30

JPEG Image – Quality 10% (PhotoShop compression quality: Low), Image size: 4KB
apticonlogo10

As you can see the size differs drastically on the compression quality, and in many situations, when the images do not contain a lot of text or are related to professional photography, the quality can be lowered to reduce the size of the images. How low you should go is absolutely up to you and your attention to details. It is just important to remember to review image sizes before putting them online, and make an intelligent decision about how large do you want your image to be, and how fast you want your page to render on the screen of internet users.

The best way to review image sizes and quality if you are using PhotoShop CS editions is to choose to “Save for Web“. PhotoShop shows you image preview and quality comparison right in the save dialog:

apticonlogophotoshop

As far as free alternatives to PhotoShop go:

– if you are using Picasa, one of the ways to do that if you choose to ‘Export to Folder’, and specify ‘Image Quality’ in the dialog, opting for ‘Normal’, ‘Minimum’, or ‘Custom’ where you can specify the exact compression quality

– or you can use MS Paint, which by default already saves with relatively lossy compression settings, and which you can also override through the registry

How to Locate Assembly in GAC

Here is a simple step by step process of how to locate an assembly in GAC if you want to take a copy of it, or maybe add an additional debug information .pdb-file for remote debugging purposes.

  • open command prompt
  • change the current folder to c:\windows\assembly (%SystemRoot%\assembly)
  • navigate to GAC_MSIL folder – that is where most of the time you will find the assembly
    (the list of all other folders in Assembly, with explanation for some of them, is below)
  • find the folder name with your assembly name without extension and navigate to it
  • additionally navigate down one more folder with the version information, and your assembly should be in that folder

Structure of Assembly folder

Here are examples of what you might see in Assembly folder on different computers:

 Windows XP 32-bit workstation:
– GAC
– GAC_32
– GAC_MSIL
– NativeImages1_v1.1.4322
– NativeImages_v2.0.50727_32
– temp
– tmp

Windows Server 2008 64-bit server:
– GAC
– GAC_32
– GAC_64
– GAC_MSIL
– NativeImages_v2.0.50727_32
– NativeImages_v2.0.50727_64
– temp
– tmp

  • NativeImages… – folders used for native images, which are typically compiled by ngen.exe.
  • tmp folder used for installation assemblies to GAC
  • temp folder is for uninstallation from GAC

Here are some ‘under the hood’ details on GAC Temp and Tmp folders and Install and Uninstall of assemblies.

Opening GAC assemblies with .NET Reflector 

If you are using .NET Reflector there are two things you can do to look what’s inside that assembly from GAC:

  1. make a copy of your assembly from GAC folder to a local folder (the steps explained above) and open the assembly from that local folder
  2. edit your reflector settings file: reflector.cfg, and add the following GAC paths there, then you should be able to open assembly right from open menu:
    [AssemblyCache]

    “%SystemRoot%\Assembly”
    “%SystemRoot%\Assembly\GAC”
    “%SystemRoot%\Assembly\GAC_MSIL”
    “%SystemRoot%\Assembly\GAC_32”
    “%SystemRoot%\Assembly\GAC_64”

Visual Studio 2008 Extensions for SharePoint (VSeWSS 1.3)

This one is the biggest pet peeve about SharePoint development for me right now.

Microsoft SharePoint product team is blowing all bells and whistles, announcing SharePoint 2010, and how important it is to switch to 64-bit environment, while poor SharePoint 2007 left in the dust and crippled with the only development extension working on 64-bit, which is still in CTP phase Visual Studio Extensions 1.3 (March 2009 CTP).

VSeWSS 1.3 was promised almost half a year ago to become a final release in the spring of 2009, and later on in one of the dev blogs mentioned July 2009 release date, but up to this date there hasn’t been any final version announcement or releases yet.

Also, if you are looking for more information and code snippets, you may still find useful referring to the samples that come with Visual Studio Extensions 1.1 for Visual Studio 2005 User Guide, which have been removed from 1.3 release.

I’m keeping my fingers crossed for the new release to come soon, while blaming it all for the recession…

Structured Procrastination and Perfectionism

Yes, I’m a procrastinator. Thing that I would never admit about myself just a couple of years ago, but as you grow older and more self aware, you start accepting certain aspects of your life and own behavior, regardless of how imperfect they are. Nonetheless, it doesn’t mean that there is absolutely nothing should be done about this, and acceptance is the only form of dealing with reality.

Almost ten years ago, when I was still fresh out of the university, sitting at work on a surprisingly sunny afternoon for Belgium, aimlessly browsing internet trying to get distracted from loads of not finished work, a colleague and a friend of mine, Solodon, stopped by my desk and told me that I absolutely must read one essay. I finished it in a couple of minutes, re-reading it over and over again after, catching more details each time. Just a couple of pages long, a truly amazing masterpiece, very humorous and easy reading essay was written by Stanford professor of philosophy, John Perry “Structured Procrastination”. The essay, which in a very playful entertaining way, suddenly opened my eyes and revealed hidden pattern of my own behavior, which my stubborn and lazy mind was trying to hide away.

And here I am, many years later, on another sunny afternoon only this time in Toronto, just like the author in his original work writing this blog post instead of doing other probably more important things, subconsciously trying to escape other tasks piling up on my desk and in my inbox. And for the same main reason – striving for perfection and postponing execution of other tasks, just so they can be done later, with desired level of attention and feeling of self accomplishment. Topic, which John Perry greatly outlined in his later essay “Procrastination and Perfectionism”.

…Why am I finally doing it? Because I finally found some uncommitted time? Wrong. I have papers to grade, textbook orders to fill out, an NSF proposal to referee, dissertation drafts to read. I am working on this essay as a way of not doing all of those things. This is the essence of what I call structured procrastination, an amazing strategy I have discovered that converts procrastinators into effective human beings…

Global Economy and Stock Markets

The Baseline Scenario – an informal, but quite informative, blog providing review and analysis of the current stock market situation and global economical issues.

In particular, there a few interesting posts:
Where Are We Now? Five Point Summary
Financial Crisis for Beginners

Although you and I and most people with investments have more money in the stock market than in the credit market, the stock market is more a gauge of sentiment than an independent force in the economy. Lower stock prices make it more expensive for companies to raise equity capital, but most companies raise more money by issuing debt than by issuing stock. And when people’s investments go down, they tend to spend less, but only a little; if their 401(k) goes down by $10,000, they don’t cut back on spending by $10,000. The credit markets, by contrast, have direct and immediate effects on how companies behave; in an extreme case, no credit can mean no cash with which to make payroll.

UX Design Patterns

Just like design patterns play a key role in software development discipline, there are design patterns used in the field of user experience design (UX). Here is a great collection of design patters for information architects, as well as software developers, collected and organized in a very friendly way, with plenty of illustrations and explanations.

Free library of UX design patterns: Quince by Infragistics
http://quince.infragistics.com/

Quince (pronounced kwinse) is a rich, interactive user experience (UX) design patterns library produced for the software community by Infragistics at no charge.

Note: Terminology: With regards to other very popular acronyms, like IA (Information Architecture) and UI (User Interface), UX is actually much more general and inclusive term and discipline, whereas IA and UI are more of subdisciplines of UX. UX on Wikipedia:

In the web world, user experience is sometimes conflated with usability, information architecture (IA), and user interface (UI) design, all of which are components of it. User experience addresses and integrates all user-facing aspects of a company, from email and web sites to off-site presence in print and on other sites.