Random Disconnected Diatribes of a p&p Documentation Engineer
OK, I might as well admit it - I'm a mobile technology dinosaur. My mobile phone is obviously of no use at all these days because the only thing you can do with it is make and receive phone calls. As I discovered a couple of weeks ago while on a brief touring holiday around England by car, I'm no longer fit to use facilities such as motels and travel lodges. I'm officially a second-rate citizen in our high technology mobile device-enabled world.
Why? Well, as an ex Boy Scout, I thought it would be a good idea before we set off on our travels to print off a list of phone numbers for the reservation centres of the major motel and travel lodge chains so we could just phone and book a room at the nearest one as we roamed unpredictably across the country taking in museums, preserved railways, public gardens, beautiful scenery, and ducks (at the Slimbridge Wildfowl Trust if you were wondering about that last one).
So, would you believe that almost none of the usual motels or travel lodges publish a central reservations number on their web site any longer? Of course, there are plenty of interactive online maps showing the locations, with the pop-up details I need for each one. But if you follow the link to book by phone, it starts off by telling you to open a web browser and access the reservations page. Yeah, that will work when I've only got ten buttons on my phone and a less-than-one-inch-square screen. Of course, I could just print off a list of all that company's locations, but the list doesn't include phone numbers or addresses. It's just links to other pages on the Web site.
I suspected that the world of mobile phone technology was leaving me behind a while ago when I tried to buy a replacement clamshell-style phone for my wife because her very nice Motorola RAZR V8 had decided to fall apart (obviously an event that was in no way connected to dropping it onto a tiled floor). But there is nothing like them available. Everything is big screen, full color, web-enabled, and too big to easily carry in your pocket.
So is there a future where a mobile phone will be just a phone? Or is it that mobile phones will no longer need to actually be a phone at all. We'll just use Voice over IP (VoIP) for the increasingly rare occasions when we actually want to communicate using speech; and the web for everything else. I suppose they'll have to think up a new name for such devices. Maybe we can call them IPads.
Of course, I could just buy a mobile dongle for my laptop and take the whole caboodle everywhere with me instead. I just looked on the Web site of my current phone supplier to see if I could buy a broadband dongle for when we go to Cyprus. But when I entered my postcode it said they "didn't recommend use in my location", so I can't use it at home. And, further down the page, it says that they don't support use outside of the UK at all, so it's no use for my upcoming trip to Cyprus either. It sounds like the only time I could use it is if I drove to my nearest town here in England and sat in a car park. One that is in a "recommended location", obviously.
Or maybe I should just stay at home until December, and buy a Windows Phone 7 when they finally appear...
Well I'd have to say I haven't had so much fun for ages. Playing with familiar stuff (and some less familiar stuff) has revived my joy of writing complicated algorithms and creating useful utilities. It's almost like being back in the old days of creating COM components for classic ASP web sites to do the things that VBScript couldn't do. I even got to write some more VBScript - and, yes, it was a politically correct circumstance 'cos I was executing it through Windows Script Host.
Over the past few months I've been revisiting some old utilities I created - in some cases years ago - that would actually be useful again. For example, I now have a dual failover Internet connection (ADSL and cable) so if the ADSL fails, which it does fairly regularly, I don't get to know that the local village and parish web sites I host are offline until the condescending emails start to arrive.
So I revived an old web site checking utility and updated it to VS 2008. By running it on an internal machine, and going out on the cable and back on ADSL, it gives me a proverbial nudge when the ADSL line is down. It just needed some fettling to resolve a few poor code practices applied at the time, a few extensions to make it do additional things, and a UI makeover to make it seem less amateur (though with my design skills, I probably only managed to make it contemporary with the late 20th century).
However, prompted by this flush of success, I expanded the log file monitor that I threw together some time ago to try and fend off the DNS amplification attacks I was suffering at the time. Now it monitors DNS, WWW, and SMTP logs with a broad range of search options. It can also send email notifications and execute scripts or programs. I use this feature to execute the aforementioned VBScript script to automatically create and manage IP address blocking rules in Windows Firewall (WFWAS).
Finally, I decided to tackle the problem of synchronizing specific sets of files between two machines. Yes, I know there are several ways you can do it in the O/S and with other utilities, but I wanted to be able to view and control the process in several specific ways. It comes about because I have a computer that contains the set of folders and files synchronized with Team Foundation Server (TFS), but I tend to work on other computers with individual subsets of these files. It's also made more complex by the fact that the files are read-only in TFS when not checked out, and the file date controls whether files are updated in TFS when you synchronize.
The idea was to be able to see the two sets of files (local and TFS) with information about the date/time, archive status, relative path, read-only setting, and easily see which were newer than the equivalent in the other location. I also wanted to be able to copy, synchronize, merge, delete, and set the last-modified date with one click. The result saves me loads of time and effort, and probably helps to avoid errors when managing the files. OK, so I probably won't be subjecting the source to a proper code review, but there are only a few bits left in there that I'm embarrassed about.
If you want a copy of any of these, you can download them here. I've even included the VS2008 source code so you can see what they are doing - as long as you promise not to show it to anyone (or laugh)...
But I suppose the real reason for all this rambling scribble is that, during the process, I realized just how much fun basic task programming really is. It's like discovering the old home computers all over again, but much easier this time round. It really is amazing how .NET and the powerful framework classes save a ton of effort. I'm by no means a virtuoso programmer compared to most of my learned colleagues, but having things like complex conditional statements, capabilities such as generic lists, and features such as simple file and folder handling functions available really makes it easy to concentrate on the algorithmic logic rather than worrying about file modes and array indexes.
And, because my history in languages pretty much follows the evolution of Pascal, Delphi, classic ASP, VB for Applications, and Visual Basic as far back as version 1.0, I'm still most comfortable using VB.NET. While almost everything I do in my p&p day-to-day work is C#, I still find VB easier to read and write, and I love the way it does all the magic indenting and formatting for me. And, of course, it runs just as fast as C# (as long as you write good code) so I now only feel like a one-and-a-halfth-class citizen in our wonderful world of technology, rather than the second-class citizen I was before the advent of .NET.
What continues to amaze me, however, is how - after I agonize about every minor instruction I need to add to make the algorithms work, and every extra conditional statement they require to cope with the increasing complexity as I decide to add yet another configuration option or code tweak - they still seem to execute in the blink of an eye. I mean, you'd expect that parsing a web log file when the decision tree takes up a whole page in Visio would take a week to run. Or than reading two folder trees to build the lists of files and doing all kinds of comparisons before displaying them in two DataGridView controls would leave you time to make coffee, eat the remains of that cold pizza, and finish the crossword as well.
But, with the memory and processing speed available on modern computers, everything just seems to fly. I'm expecting it to splutter and crawl like a caterpillar in custard, but instead it dances like a cat on a hot tin roof. Even my VBScript script that updates Windows Firewall runs so fast that the screen update can't keep up with it. I ran it three times wondering why it wasn't working, and only discovered it was when I looked at the log file...
Maybe I'm picking up some good programming habits from the plethora of clever code I encounter every day in my proper job. Perhaps the constant exposure to design patterns, extensible code techniques, and the latest features of the framework are gradually permeating my aging brain. Or is it just that a quad-core Xeon box with 8 GB of memory can eat any code I throw at it without even blinking? Does replacing my complex sets of arrays with generic lists of custom classes, and my Ands with AndAlsos in the appropriate places, really have any discernable effect on execution time? Or am I just pandering to the typical programmers' paranoia of wasting any of those valuable execution cycles?
But there is always that wonderful warm glow inside when, after pondering over recalcitrant algorithmic constructs for ages, it all works as though it was written by somebody who actually knows what they're doing. And, anyway, I have to stop writing now. I need to think up some more exciting new and totally unnecessary features to add...
Which is the best way to prevent intrusion attacks on your server from the network? What is the largest size of application XAP file you can deploy to a Windows Phone 7 device? When should you cache the data used by your application in memory? How many magicians does it take to change a rabbit? Obviously the correct answers are "Unplug the network cable", "400 MB", "Always", and "None, it's just a trick".
Or are they technically "correct"? Can you equate "best" with "basically, the server's not working any more"? Certainly it's the most positive and reliable way to protect your server, but it's somewhat lacking in practicality in terms of a non-broken network. And what about Windows Phone 7 users who rely solely on their phone supplier for connectivity? The maximum size of a XAP file you can download without using Wi-Fi or a USB cable is 20 MB. And, of course, caching a 3 GB collection of data transfer objects when your computer has only 2 GB of memory may not provide better performance...
All this comes about because we decided to include the now highly fashionable "Check Your Understanding" section in all of the chapters of our new Windows Phone 7 Developer Guide. I can't say I'm a huge fan of these sections as they add to the effort of creating the guidance - though I do agree they are useful. I used the ones in our recent Parallel Programming with Microsoft .NET guide to figure out if I actually did understand any of the topics in each chapter. Mostly I patently didn't, but that's a different issue for which I can't blame the authors.
So, anyway, having agreed to include them in our latest tome I had to figure out the appropriate style and content. I started by watching some TV programs that supplement their income by offering cash prizes for answering a simple question. Based on this, we'll be including a knowledge check such as:
Which of the following is a well-known computer operating system?
OK, maybe more research is required. So I check out the program for people who want to be millionaires. How about:
What does the computing abbreviation "AMLCD" stand for?
So, you see, it's not as easy as it might seem. And how many questions should there be? How difficult should I make the questions? Will they actually help people to understand the content of the chapters? Can I include one or two stupid answers to liven it up? Will all this asking questions about questions finally result in a stack overflow error?
In the end we decided on six questions per chapter, multiple choice from four possible answers, and medium-level in terms of difficulty or obscurity. Such as:
Which of the following programming techniques are permitted in a Windows Phone 7 application?
The next step is to provide the answers. Annoyingly, I haven't found a way to display them upside down at the foot of page 97 using HTML - but that's the production department's problem, not mine. All I need to do is supply the text for the answer. And it's obvious that the answer to the previous question is "None of the above". Easy! And I've reinforced the reader's understanding by checking that they will remember these limitations when they start designing their Windows Phone 7 applications.
But, unfortunately, the dreaded cyclic dependency factor now comes into play. One of the major things I learned from working on the Microsoft Application Architecture Guide guide a year or so ago was that, for any question you ask an architect, the answer will always be "it depends". And the same applies, it seems, to most other computing-related stuff.
Looking back at the question above, you would have to agree that "a" is not permitted. The requirements for Windows Marketplace certification clearly state that your application must work on any device that meets the Windows Phone 7 specification, and extended memory is an optional feature of the phone. Except, elsewhere, it says that the maximum memory usage for a WP7 application is 90 MB unless the device has more than 256 MB of memory installed. But then it says that the application must run anyway, and only take advantage of extended memory when it is available. So, in a round-about way, it seems that "a" actually is not permitted.
What about "b" and "c"? These are both definitely not permitted, so we're OK there. Except that I was told that OEMs developing Windows Phone 7 devices can use C++ and native (so technically unsafe) code. So if you were feeling picky, you could dispute that part of the answer we provide. But, in general, we're still OK I reckon.
And so, finally, is "d" permitted or not? Well, it seems the issue is that the Marketplace submission process unpacks the XAP file you provide, scans the code to determine the security permissions it requires (for things like using the microphone, camera, location service, etc.), and then recreates the manifest file in the XAP so that it lists only those actually used by the application. This means that Marketplace can list the phone features the application uses with confidence that only these can be used in the code.
But the Marketplace code scan does not find types that are discovered and instantiated using reflection. Therefore, if you use this approach to locate and instantiate a type that requires security permission, and the application manifest does not include that permission, your application will fail with a security permission error. However, if you have already referenced the type using the normal approach the manifest will contain the required permission, and so the app will run. Technically, the programming technique described in "d" is not "not permitted", but rather it's "discouraged" because it is likely to cause the application to fail in most cases.
So, even though I wrote the question, I actually got the answer wrong. I told you this was harder than it looked...
I can't help wondering what people will actually make the effort to go and see in a hundred years time. What are we creating now in terms of engineering marvels or wondrous architecture that our grandkids' grandkids will pay money to visit? Compared to the places we went on out recent tour of England, what will be worth visiting - or even still be there - in the twenty-second century?
Yes, I know stuff like the Pyramids (and Stonehenge here in England) have been around for a lot longer than 100 years, as have most cathedrals and the natural wonders such as the Grand Canyon and (on a somewhat smaller scale) Cheddar Gorge. It's probably safe to assume that people will still be making the trip to visit these and other similar sights a hundred years from now.
But there is so much relatively recent history that attracts millions of visitors each year, but seems to capture only a brief instant in time. In particular, here in England, the incredible feats of the Victorians and Edwardians who changed our landscape and created the forerunners to many of today's architectural and engineering achievements. You only have to look at the railways, the canals, bridges of all kinds, the iron steamships, the factories and mills, the huge country houses and palaces, and the wonderfully landscaped estates and gardens.
So what will we leave as the epitaph for our own brief instance of time? What have we created in the last hundred years that deserves to be part of our heritage? Will people in 2110 walk around a cruise ship marveling at the five swimming pools and luxurious dining facilities? Will they stroll along abandoned motorways/freeways reminiscing about the cars and trucks that used to thunder up and down them all those years ago? Will they stand in abandoned departure lounges wistfully remembering the gaily colored aircraft that used to ferry people to foreign destinations?
And what about architecture? Will any of our fabulous suspension bridges survive for 100 years? Will our modern houses and commercial buildings be worth visiting in years to come? Have we really built anything that will astound people in the future with its daring use of materials and leading edge construction methods? Or, alternatively, seem as quaint and picturesque as an "Olde Worlde" country village?
And what about monuments to our technologies? Maybe people will peer into the derelict clean rooms of our semi-conductor factories and be amazed at the massive size of our silicon chips. Or stand in the tunnels of the CERN accelerator in Switzerland and hear stories about the search for particles that their kids now routinely create in school physics lessons. Perhaps they'll visit the now deserted motor car plants and be appalled at the working conditions that prevailed. They might even organize tours of our neglected hospitals and listen in horror as the guide explains the medical procedures that were common in the twenty-first century.
Yet, somehow, I don't see it. I wonder if there was a special period in time when things were changing so fast and with such incredible impact that we cannot even come close to now. OK, so we've changed the world dramatically in our own time with electronics and networks, and our knowledge-based economies. Maybe all we'll have for people of the future to visit is massive datacenters, and lots of pictures and videos on the Internet...
I previously thought that the reason you used to see miles of cassette taped entwined in the bushes at the side of motorways was because the driver discovered that his or her Mother had accidently put a "James Last Plays Christmas Carols" tape back in the driver's Black Sabbath or Pink Floyd cassette box. Needless to say, that kind of disaster when hurtling along the M1 could obviously engender a malicious and wholly illegal "chuck it out of the window" process. But it seems I was mistaken.
According to the Surrey Advertiser newspaper (a local rag available in the southern part of England) nefarious devil worshippers are intentionally recording dark and dangerous spells on cassette tape and then diligently encircling sections of the Queen's Highway with it to initiate a huge crop of accidents and other unfortunate occurrences. In particular, at junction 9 of the M25 they have prompted a noticeable increase in the number of motoring accidents and suicides from people jumping off the footbridge. A group of believers from the Pioneer Engage Church even organized regular vigils and prayer meetings to "cleanse the benighted interchange".
Now I'm fairly open to wild new theories and improbable suggestions. I mean, I even accept that information technology can create a paperless office. And that sat-navs actually do use satellites circling way above the earth rather than reading the location from barcodes in the white lines on the road. But I'm finding it hard to believe that the magnetic properties of cassette tape are sufficient to overcome the Earth's residual magnetism at a level sufficient to affect human behavior. Especially as we're repeatedly told that holding a powerful microwave transmitter right next to your ear is not the least bit dangerous.
As an aside, I just watched a program by Stephen Hawking about how time works that said the clocks in the GPS satellites need to be manually adjusted as they gain a billionth of a second every day. This is, it seems, because the effects of gravity make time run slower close to the Earth than at the satellites' altitude. Supposedly, if they didn't do it, your sat-nav would be out by six miles every day. Maybe the reason I still get lost some days is because the guy who winds the knobs took a day off sick.
So, anyway, the Surrey Advertiser soon received several disbelieving responses to its article, including one from a reader who (perhaps through intimate knowledge of the practice) pointed out that most evil spirits these days use MP3 players because they are far smaller and more convenient to carry when crossing into the dark realm and back again. More likely is that, when our intrepid band of believers analyzed the contents of the tape, they accidently played it backwards and by sheer luck hit upon the bit in Led Zeppelin's Stairway to Heaven that supposedly includes satanic phrases recorded in reverse.
But maybe it's the reason that people hang old CDs on strings to scare birds away from their vegetable plots. It probably works best with heavy rock music ones. I suppose I could subject the theory to scientific test by burying a hard drive containing all the satanic album tracks I've collected over the last forty or so years under the hedge at the front of our garden, and counting the number of people who fall over as they pass by...