Posts

Showing posts from May, 2010

Yet once more into the breech (of altered programming logic)

Once upon a time, long long ago, I wrote 8-bit programs in Tiny-C with absolute addressing being the only reality.  Then we had Borland Turbo-C with relative addresses and the joys of relative assembly jumps. Enter Windows and the joys of locking and unlocking memory blocks that you must allocated and manage yourself. Then came Visual Basic which evolved into .Net CLR and decreasing awareness of what is happening under the hood.   With VS2010 including F# and enhanced parallelism in .Net4, we actually have to go retro a bit – back to the world of having to understand the hardware. CPU speeds are no longer increasing – I have an old laptop from six+ years ago that ran at 3.2 GHz. This year I updated one of my machines off-the-shelf from Costco.com, an I7-920 with 4 cores and hyper-threading (8 CPUs appears in Task Manager) and 12 GB of DDR3 RAM. This week I ordered from Costco a Phenom II X6 (Yes – 6 REAL CORES) for one of my daughters.  This CPU will (according to YouTube demos) o

Are baby-boomers better learners/developers than Gen-X and Gen-Y?

Part of software development is learning. Part of learning is being corrected. I read this interesting article the other day, Young adults believe in the age of entitlement, claim researchers in the Telegraph. It reflects similar news pieces that I have seen on CBC’s National and PBS. “the 20-somethings of today have ‘an automatic, knee-jerk reaction to criticism,’ and just dismiss it.” It’s explains why I have seen solid advice ignored – the older generations would actually take it, or, enter into a discussion (or argument) about the basis of the advice.  Having a good discussion with supporting documentation is an excellent way to improve software quality – everyone learns.    The article also cites a separate study due to be published in the Journal of Management, “Generation Y care most about high salaries and lots of leisure time – two apparently incompatible goals” So we are talking about a generation of developers that expect a 35-40 work week instead of the

500 Words

As a professional blogger on MSDN, I have been contemplating the length of a blog post; I came to the conclusion that they should be right around 500 words.   When mentioning this to another blogger, he told me that the length should match the subject. At first glance makes perfect sense. If you have a more complicated subject, you are going to have a longer post. However, I disagree. If you have a more complicated subject, you need to split it into a multi-part series of posts published over a period of days.   My stance is that the length needs to match the channel not the subject. An analogy is a television commercial on a national network channel. No matter what the message or subject, the channel dictates that the commercial only be 30 seconds. Some commercials are 60 seconds, and some of my blog posts are 1000 words. However, none of the posts are 5000 words, just like there are no five minute commercials. The audience has an expectation of length and you lose them if t

Easy fix for duplicate keys in a resource file (resx)

Today I was cleaning up some RESX files by doing some renaming (to conform to a naming conventions) and ran into the classic duplicate mnemonic problem that arise. With hundreds or thousands of mnemonic in a resource file this can become very time consuming. RESX files are not case sensitive which adds a little joy to the process…   I tossed together a utility that eliminates all of these duplicates and also sorts the mnemonics in the physical RESX file. This made reviewing a lot easier – so here’s the code in case you need it, just provide the folder holding the RESX files and you are done.   using System; using System.Collections.Generic; using System.IO; using System.Xml; class Program { static void Main( string [] args) { if (args.Length < 1 ) return ; DirectoryInfo di = new DirectoryInfo(args[ 0 ]); foreach (FileInfo fi in di.GetFiles( " *.resx " )) { XmlDocument dom = new XmlDocu

Computers as a Vocation or an Avocation?

My grandfather advocated this advice (and likely further back, perhaps to the 1850's -- since the evidence supports it)...  " Always separate life-goals into vocation and avocation. An avocation is what you want to do. A vocation is what puts bread and butter on the table. When you mix the two into one, you end up being a starving artist living in an attic in a rooming house. For vocation, look at what you can do better than other folks (you may not like doing it -- that does not matter, being free to do your avocation compensates); look at what is new (there will be less competition, faster promotion and higher pay) and find the best combination. That is where you should focus for your vocation.  Don't ask the older generation for advice here -- they will give you their reality when they were your age. " An example of this is the horde of people that want to become game developers….  they have mixed up vocation and avocation.   So what is your avocation?

Getting a Great Screen Shot

Image
I have been doing a lot of technical blogging and writing lately; in doing this I need to take screen shots of dialog boxes, browser screen, etc… Good screen shots can break up text, make the blog post visually appealing, and help the reader navigate through the task you are writing about. I wanted to share a few of my tricks on getting a good screen shot. Alt – Print Screen My preferred way of getting a good screen shot is to use the print screen button, usually located at the top right of your keyboard. This is great for capturing the whole screen. However if you just want to capture the active dialog use Alt-Print Screen . This doesn’t require any cropping. It is almost impossible to correctly crop with the Aero theme in Windows Vista or Windows 7, because it is hard to tell where the borders of the dialog end. Use Notepad as a Background When taking screen shot on Windows Vista or Windows 7 using the Aero theme you can see the applications behind in your title bar. To avoid

Quick check of a developer’s HTML skills

Today, I got pinged to offer some comments on two developers who both coded up one equivalent page as an evaluation of their skills. The question is how to determine their relative skill levels. One approach is to read code and see if they happen to use the style that you like – but that is quasi-nepotism. You may not hire someone with a better style because you just don’t realize it. You will inbreed a specific coding style…   I decided to do push all of the pages through various validation engines. The logic is simple --- someone that codes close to standard is likely the more experienced in conforming to standards and best practices. So I pushed the pages through the URLs below and got the results shown below.   URL Dev #1 Dev#2 http://jigsaw.w3.org/css-validator/ 9 errors 5 warnings 1 error http://validator.w3.org/ 0 Errors 50 errors http://validator.w3.

What “it depends” says about your architecture skills

The other day while reviewing a paper, I came across a classic-developer rhetorical expression “it depends”. I immediately recall David Hill’s prolog in a Pattern and Practices foreword. “There is an old joke, told amongst mischievous developers, that in order to be considered an architect you just need to answer every technical question with "it depends" – Q: What’s the best way to implement authentication and authorization in my solution? – A: It depends; Q: How should I implement my data access layer? – A: It depends; Q: Which technology should I use for my solution’s UI? – A: It depends. Q: How can I make my application scalable? – A: It depends. You get the general idea.” From http://msdn.microsoft.com/en-us/library/ee658082.aspx I think we can gain some insight on this usage by the following analogy:   There’s the mountain range of it depends ahead of us. We go and hit a local public house (i.e.pub) “ Coureur des bois ” and talk to the locals about crossi

Enumerating all of the CSS Classes on a site

One of the projects that I’m working on needs to have an appendix listing all of the CSS classes used on the site, ideally with a cross reference for which page(s) it occurs on. There is no utility build into VS that will extract this (and since some of the class elements may be originating on controls, it’s hard to conceive of such a VS utility). My solution was simple: Create a page that links to all of the pages in the site Create a console utility that walks the pages and then extracts all of the CSS class name found. This is actually very simple to do using: System.Web.WebClient to get the HTML HtmlAgilityPack ( http://htmlagilitypack.codeplex.com ) to handle the HTML as a Xml Document. I store the data in a data table and then save is as XML for subsequence use (for example creating a table in an appendix) Here’s the code – enhance as needed. using System; using System.Net; using System.Data; using System.Collections.Generic; using HtmlA

Making a Screensaver On Windows

Image
Recently I was tasked with making a screensaver to run on Windows and it had to run on Windows XP, Windows Vista, and Windows 7. I decided to do it with WPF as that is my new favorite technology. So like all good developers I pulled up my browser and searched for somebody who’d done it already. After a little prodding, I found several articles with relevant code samples , a few MSDN pages and some other interesting stuff. I had my screensaver built shortly after.   Then came time to make the installer for the screensaver, a standard Windows installer is no big deal. This one just needed to add a couple of registry entries for the screensaver file to make it the default and copy the output file (an executable renamed with a . scr extension) to the appropriate folder. When I ran this everything worked beautifully, except now the dropdown that lets you choose your screensaver in the display properties only displays the filename of the output file, but on older Windows versions (pr

Altering Master Page CSS Class on a page by page basis

The joys of a master page is that it gives uniformity across a website. If the customer wants to alter the look of a master page item on a specific page, it could get painful. Often the solution is the inclusion of additional conditional code in the master page. This solution is a spaghetti code approach.   A better solution is to tag the body of the master page with the name of the page, for example: < body <% =PageSelector % > >   With this code behind: public partial class Default : System.Web.UI.MasterPage { public string PageSelector { get { string filename = Request.AppRelativeCurrentExecutionFilePath.Substring( Request.AppRelativeCurrentExecutionFilePath.LastIndexOf( @" / " ) + 1 ) .Replace( " . " , string .Empty) .Replace( " aspx " , " Page " ); return String.Format( " ID='{0}' " , filename