Random Thoughts of a Scatterbrain.
 Monday, October 15, 2007

Random DevTools Entry: #016

10/15/2007 11:34:20 AM (Eastern Daylight Time, UTC-04:00)

I've come across a small number of AJAX animation progress generators and a few pages with a fixed listing of generators, but Ajaxload is by far the best one I've found so far:

Very well designed (and useful) little utility.

Science: It Works, Bitches!

10/15/2007 10:39:06 AM (Eastern Daylight Time, UTC-04:00)

On a recent late spring trip, my wife and I visited Hyannis, Massachusetts.  During some free time, we had a chance to walk down to the beach and take a stroll.  We were greeted at the beach by a thick mist and an unbelieveable wind blowing off of the ocean.

About a week or so later, I was reading some articles regarding how Edward Kennedy pulled the NIMBY card regarding the erection of a massive array of wind turbines off of the coast of Hyannis as a source of alternative energy.

The benefits for the region seems clear:

Environmentalists say the $770 million wind farm -- enough to power 3 out of every 4 homes in New England's most coveted vacation region -- would be a crucial step toward clean, renewable power, without burning a single barrel of Middle Eastern oil, and at a time when scientists are issuing increasingly urgent warnings about the effects of global warming.

But the opposition from the politicos seems to be avid.

Massachusetts' Republican Gov. Mitt Romney and Democratic Sen. Edward Kennedy, whose family compound in Hyannis would look out at the wind farm -- have warned that the unsightly turbines would depress property values and damage the local economy, which relies heavily on tourism.

I guess some would consider an array of wind turbines to be "unsightly".  But to me, it is a stunning view of progress and scientific achievement of the highest order; it is a beacon into the future in which we learn to live with nature and not in spite of it.

So the question is, how can we effectively tap the awesome power of wind in a cost effective manner without touching a nerve with the NIMBY crowd?

Enter Shawn Frayne's windbelt concept.  It is an idea so simple in its execution and so elegant in its design, that it's nearly indistinguishable from magic (of course, there's solid science behind it as well).

Frayne’s device, which he calls a Windbelt, is a taut membrane fitted with a pair of magnets that oscillate between metal coils. Prototypes have generated 40 milliwatts in 10-mph slivers of wind, making his device 10 to 30 times as efficient as the best microturbines.

Science: It Works, Bitches!

 Tuesday, October 09, 2007

How Did I Miss This?!?

10/9/2007 7:34:55 PM (Eastern Daylight Time, UTC-04:00)

With the release of .NET 3.5 and Visual Studio 2008, Microsoft will also release selected bits of the .NET Framework source code!  With comments intact no less!kermitdancing_4.gif

To me, this is good news; very good news I mean, there are a variety of reasons, but mostly because I know that most people don't have the time, motivation, or energy to work through a book like Framework Design Guidelines.

My hope is that the Microsoft team, in doing so, will spur a movement within development teams to adopt better programming standards which are more aligned with the Base Class Libraries in naming, design, and architecture.  It should, hopefully, serve as a model to how things should be done in the post VBScript/VB6 days.

I just cringe sometimes when I dig into our codebase and find crazy things like methods not named as verb phrases, partial classes because a single file was getting too big (total abuse of partial classes instead of considering an object oriented approach to break down a large class), weird class names, catch blocks which have no code, and so on.

So for me, this is certainly good news and I hope to continue to form better practices as I get the opportunity to dive into the code.

Another Call for the Death of DRM

10/9/2007 9:51:38 AM (Eastern Daylight Time, UTC-04:00)

This time, coming from a Yahoo! exec (with a spine), Ian Rodgers.

If the licensing labels offer their content to Yahoo! put more barriers in front of the users, I'm not interested.  I won't let Yahoo! invest any more money in consumer inconvenience. I will tell Yahoo! to give the money they were going to give me to build awesome media applications to Yahoo! Mail or Answers or some other deserving endeavor. I personally don't have any more time to give and can't bear to see any more money spent on pathetic attempts for control instead of building consumer value.

Ian highlights perhaps what is the most compelling force behind the proliferation of MP3s:

History tells us: convenience wins, hubris loses. “Who is going to want a shitty quality LP when these 78s sound so good? Who wants a hissy cassette when they have an awesome quadrophonic system? Who wants digitized music on discs now that we have Dolby on our cassettes? Who wants to listen to compressed audio on their computers?” ANSWER: EVERYONE. Convenience wins, hubris loses.

So, when will the industry finally get it?  Meanwhile, it may just be time to dump iTunes for Amazon's DRM free offerings instead (by the way, I'm in love with Amazon Prime).

Check for additional commentary at TechCrunch.

The most puzzling aspect of this whole MP3 revolution has been why the industry has been slow to adopt and embrace it. 

For one, it reduces the physical limitations of distribution and shelf space.  No trucking of boxes of CDs, no need to hire a bunch of teenagers to stock your store shelves, no worries about running out of stock...it seems like it would be a media company's dream come true. 

On a second point, as countless others have pointed out, CDs inherently contain no copy protection scheme in place.  In addition to this fact, the CD is typically a much higher quality source than most MP3s...why haven't we seen the RIAA crack down on the likes of Sony, Teac, Maxell, and the various resellers and manufacturers of CD-R media? 

A third point to consider is that the media companies are absolutely silly in ignoring the potential marketing data that can be mined.  Embracing digital distribution, with the right agreements and systems in place, allows them to track and profile every paying customer!  Make a deal with Apple, Amazon, Yahoo!, other distributors and consumers: we'll go DRM and lower prices, but you must provide aggregate data about the customers that we can slice and dice to repackage for marketing purposes. 

The irony is that the P2P paradigm that started the MP3 revolution that is driving the music and movie industry nuts is likely to also be the same paradigm that will allow them to thrive in the current world of digital distribution.

 Monday, October 08, 2007

Random DevTools Entry: #015

10/8/2007 4:10:06 PM (Eastern Daylight Time, UTC-04:00)

The best devtool ever? Or the best devtool ever?  You decide; I present the fantabulous Terminals.

Once you've lived with it, you can't live without it.

It addresses several shortcomings with the default RDP/Terminal Services client in Windows, namely:

  • Lack of support for tabbed viewing of connections (who likes to have 5 different Remote Desktop windows open?).  Terminals supports tabbed browsing of Remote Desktop connections.
  • The need to save one .rdp file for each connection...what a pain in the butt!  Terminals supports saving of the client connection information for you automatically.  Not only that, it can add configured connections to a toolbar for easy access (instead of hunting down saved files).
  • Lack of tools for connectivity testing.  With the default MSTSC, it requires you to jump to the command line to run ping and other utilities when testing for connectivity.  Terminals has it built in!  Awesome.
  • No support for connection groups.  Quite often, when working with VMs or remote machines during development, you have to access the same group of machines at the same time (for example, a server and a client).  With the default MSTSC, you have to manually start the two connections or write a batch file to open them at the same time.  Terminals has a grouping feature which allows you to initiate grouped connections automatically.

During development, even with VMWare running locally, I prefer to use a terminal services connection instead since it's way more responsive to user input.

Terminals is definitely awesome.  There are still a few issues like auto-scaling and auto-resizing which don't work quite right yet, but otherwise, it is fantastic.  Note that it also doesn't support connecting disks and printers and what not (maybe next release).

 Thursday, October 04, 2007

Serializing Inheritance Chains With WCF

10/4/2007 1:42:26 PM (Eastern Daylight Time, UTC-04:00)

During a recent code review, I noticed that a colleague was sending me service entities from his WCF service with flags for the data type.  This itself wasn't so bothersome to me, but what did bother me was that the model he was sending back was violating one of the basic rules of object oriented programming: encapsulation (well, inheritence and abstraction, too) by mashing all of the data types into one type differentiated by a property.

Having worked extensively with XML serializers and XSD.exe generated code, I suggested that instead of mashing all of the objects into one definition -- with all of the different properties -- build one abstract definition and define a hierarchy of classes that inherit from the abstract class.

This worked out great since the family of objects all had a very obvious common base, but now the question turned to how to notify the runtime serialization engine to include the concrete types when returning abstract types from an operation.

I had imagined that the .NET 3.0 team would have made the process more "automagic" and use reflection to find inheriting classes instead of requiring the explicit declaration of inheriting classes.  As I soon found out, such is not the case as my proxy classes didn't include any of the inheriting classes; the proxy definition only contained the definition for the base class.

The answer is the KnownTypeAttribute which must be used to decorate the class definition of the base class (in my case, an abstract class).  One attribute must be added for each inheriting type which must be serialized across the wire.  For example:

[DataContract]
[KnownType(typeof(Invertebrates))]
[KnownType(typeof(Vertebrates))]
[KnownType(typeof(Mammal))]
[KnownType(typeof(Reptile))]
[KnownType(typeof(Human))]
public abstract class Animal {
	// Base class definition
}

Notice that the entire hierarchy has to be "flattened" and included in the declaration for the root base type. The DataMemberAttribute only has to be applied once on any property in the base class.

 Monday, October 01, 2007

The Slow Death of DRM

10/1/2007 12:27:50 PM (Eastern Daylight Time, UTC-04:00)

I've been in a somewhat heated debate with my once CEO and now VP regarding the effectiveness (or rather, the ineffectiveness) of DRM and how the media companies are really just screwing themselves (whilst also screwing customers) by not adapting and accepting digital as this generation's radio.

I've always held the stance that DRM is a useless encumbrance to legitimate users of the content while providing merely a false sense of security to the copyright holders; those who want the content bad enough will circumvent the DRM somehow.  In the end, regardless of how good the DRM is, the simple fact is that the end product must be output at some point in time.  The content can always be captured as output from some trusted system (though some quality may be sacrificed).

Time and again, we've seen that the application of DRM is a fruitless effort in the cat and mouse game with hackers that the hackers have won every time.  Witness:

In his open letter, Steve Jobs comments on DRM and states:

Imagine a world where every online store sells DRM-free music encoded in open licensable formats. In such a world, any player can play music purchased from any store, and any store can sell music which is playable on all players. This is clearly the best alternative for consumers, and Apple would embrace it in a heartbeat. If the big four music companies would license Apple their music without the requirement that it be protected with a DRM, we would switch to selling only DRM-free music on our iTunes store. Every iPod ever made will play this DRM-free music.

Why would the big four music companies agree to let Apple and others distribute their music without using DRM systems to protect it? The simplest answer is because DRMs haven’t worked, and may never work, to halt music piracy. Though the big four music companies require that all their music sold online be protected with DRMs, these same music companies continue to sell billions of CDs a year which contain completely unprotected music. That’s right! No DRM system was ever developed for the CD, so all the music distributed on CDs can be easily uploaded to the Internet, then (illegally) downloaded and played on any computer or player.

I tend to think that a technology visionary like Jobs "gets it".  He understands that it is quite likely that no perfect DRM system can ever be created but in an effort to use these imperfect DRM systems, the only people that are being punished are legitimate consumers of the media by being locked into proprietary stacks of players, online stores, and digital media.

He also touches upon an oft ignored point: the CD, a digital source, itself does not contain any form of DRM.  It's true that the designers of the format perhaps did not foresee a world digitally connected and able to distribute 650MB worth of data in mere seconds (BitTorrent),  but that does not absolve the fact that they're plugging the crack in the dam while ignoring the gaping hole.

It is my view that the actual number of people who actually rip and distribute music from CDs and DVDs are a very small percentage of all consumers.  Meanwhile, there is a much larger percentage of consumers who get their copies illegally from these sources via peer to peer and file sharing networks.  And yet a larger percentage of people are actual legitimate consumers who plunk down the full price of the CD or DVD in stores and take it home with them.

What the music industry should be concerned about is not that marginal percentage of sources (those who hack the DRM systems or use the resultant software to rip and distribute the content - this group will continue to do so, indefinitely), but the much larger portion of the consumer population that illegally downloads the output of these providers even in the face of the minor threat of legal action.  The question of course is how they can reach this consumer (or at least a large proportion of this consumer).

The secret seems to be offering a "fair deal" to the consumers.  I can still remember the days when CD singles cost $5, 6, 7, even 8 dollars!  Of course, what is "fair" is arbitrary and, as my VP would say, "determined by the market" (what he seems to disregard is that the music industry was guilty of price fixing to artificially inflate the cost of CDs instead of allowing for the market to decide the fair price), but clearly, this price seems absurd!  Of course, then the question is, what is fair?  Is iTunes' $0.99 model, "fair"?  It's difficult to say since "fair" is relative to the consumer.  To some, $25,000 is "fair" for a cell phone while to others, $250 seems absurd for a cell phone (obviously different products, paying for brand, etc.; but the essence is that they are functionally equivalent in damn near every way).  Price is not the only factor: consumers, as Jobs noted, expect that once they've paid for the content, they can reuse it (not redistribute it) in their cars, on their cell phones, on their portable music players, and so on.  In the consumer's eyes, DRM is but a nuissance driving them to find DRM free, illegally distributed versions of the content.

Today's news that's buzzing around the Internet community is the upcoming release of Radiohead's next album.  Most of the buzz centers around the fact that this is the first major artist/group to release their music completely independently...no music labels involved.  Not only that, this is the first mass live experiment in determining "fair" pricing in terms of music and media:

From Time:

There's no label or distribution partner to cut into the band's profits — but then there may not be any profits. Drop In Rainbows' 15 songs into the on-line checkout basket and a question mark pops up where the price would normally be. Click it, and the prompt "It's Up To You" appears. Click again and it refreshes with the words "It's Really Up To You" — and really, it is. It's the first major album whose price is determined by what individual consumers want to pay for it. And it's perfectly acceptable to pay nothing at all.

It will be an interesting experiment indeed; the results of which, if shown to be successful, will shake the music industry to the core as other artists start to adopt the model.  The music industry has been put on notice: adapt or die.

Will Radiohead be successful?  Will they earn a dime?  One thing is for sure, they will gain a new audience of listeners who would otherwise not have been willing to purchase a CD for $16.00, but will surely download and sample the new tracks for free or for a nominal price.  But from this, it's easy to predict that Radiohead will surely increase sales of their previous albums as a new set of listeners discover the group because they've opened their content to the consumer.

It is the same with Internet radio stations, where the absurdity over the proposed rates to be paid by Internet radio stations was just recently put on hold.  In the age of HD radio broadcasts and radio-to-computer devices, what sense did it make to treat Internet radio any differently from traditional FM radio and even satellite radio?  Like traditional broadcast radio, Internet radio serves the same purpose in that it allows consumers to discover artists that would otherwise not have been given a glance (every CD I've purchased in the last 5 years has been a result of hearing the artist or group on an Internet radio station first).  It's simply that I'd rather listen to music from my computer than from my stereo.  To the consumer, the nuances of distribution and control of the media are irrelevant: the consumer just wants to listen to the music and it's really no different than an HD radio broadcast.

The media companies need to adapt and embrace technology.  They need to study how consumers want to use the content.  They need to understand that the old models won't work anymore in a connected world where content is expected to be transferrable with little hassle and reusable by the consumer (just as a CD should play in your car, in your desktop stereo, on your computer, or from a portable CD player (do people still use those?)).

 Saturday, September 29, 2007

Less Painful Windows Service Development

9/29/2007 12:11:08 PM (Eastern Daylight Time, UTC-04:00)

When developing Windows services applications, one of the most painful aspects is testing.

Sure, you can test individual component libraries separately with unit tests, but what about deploying and testing the system in an actual runtime environment?  What if your components are dependent on live communications (for example, two components that communicate via TCTP/IP bindings in WCF)?  You could use mocks, but at some point, testing the interactions of the full system will be necessary.

Typically, this is a painful process of either using installers to install and uninstall the service or manually starting and stopping an installed service to replace component library assemblies. 

The pain can be alleviated by using automated batch scripts on the post-build event.

ECHO Checking for existing deployment...
IF EXIST "
\\<server>\<deployment-target>" GOTO COPYFILES
GOTO SHOWNOTICE

:COPYFILES
ECHO Found deployment; copying output files...
ECHO Stopping Windows Service...
SC
\\<server> STOP <service-name>

:: COPY FILES HERE....

ECHO Starting Windows Service...
SC
\\<server> START <service-name>
ECHO Started Windows Service.
GOTO END

:SHOWNOTICE
ECHO Did not find deployment target...
GOTO END

:END
ECHO Completed build...

In this example, I'm deploying to a remote server on the local network (but it would work just as well on a local deployment).  I came up with the script a while back after I got tired of stopping services, copying binaries over by hand manually, and starting services when testing some appliactions that I was building.  This technique still requires a one time initial install to deploy the Windows service, but on subsequent builds,

  1. It checks to see if the deployment target exists,
  2. If so, it stops the service and replaces the binaries (I've left that script out since it's particular to any given deployment),
  3. It restarts the service.

I find this particularly useful for testing WF applications in custom Windows services based runtimes and for testing WCF applications in custom Windows services based runtimes as it allows me to install the service once and redeploy the component binaries with each build with ease.

 Friday, September 28, 2007

Programmathon VII Day 5, 6 - Extended Edition

9/28/2007 12:32:08 AM (Eastern Daylight Time, UTC-04:00)

Getting lots of work done.

Today, day 6, we planned to go out to the Red Butte Cafe to get some buffalo burgers.  Brad even called ahead to ask, before we embarked on a 30 minute journey, whether they still sold buffalo burgers.  Not only that, he specifically asked if the buffalo burgers are actually made from buffalo meat.

Unfortunately, when we were seated and finally prepared to order, we were all disappointed by the fact that they no longer served buffalo burgers.  We had to settle for tamer fare.  You can just see the disappointment on Jim's face.  The quest for buffalo burgers will have to wait till next time.

 Thursday, September 27, 2007

Dynamic SQL: Yea or Nay?

9/27/2007 2:42:01 PM (Eastern Daylight Time, UTC-04:00)

I've always been on the side of stored procedures in the classic debate over the merits of dynamic SQL.  In reality, I can only think of one good scenario where dynamic SQL at the application layer should be used: programmatic batch inserts.

I won't go into the performance debate, since there are tons of articles that already cover this area, but rather, I'd like to discuss the usability and development and architectural aspect of it.

In almost all other cases, it seems like the best choice is to have the application not generate dynamic SQL and use a stored procedure...always.  There are certainly times when dynamic SQL is necessary, for example, when generating selects against a dynamic table structure, but in those cases, the variable portions of the query can be parameterized into the stored procedure and the procedure should generate the dynamic SQL.

Some would argue that if the underlying data models change, the application layer will usually be forced to change are ignoring other aspects of model changes that don't necessitate application model changes.  These include performance tuning, filtering by table JOINs and reuse of the data logic in nested stored procedures or functions.

When working with compiled code like .NET, the core issue is that fixing query errors involves a recompile and redeploy, which in most cases, is much more difficult than just fixing a completely disconnected (but not completely decoupled since there is a quasi-interface (the return result type and structure)) stored procedure.

For example, if a dataset today contains data from table A and tomorrow it needs to include data from table A and B (let's say they both contain the same elements, but one is used for archives), it would be easy to update the procedure to UNION the results from the two datasets without affecting the application layer.

This isn't the only scenario, for example, let's say the requirement changes and now the data needs to be filtered by another table.  It would be easy to add a new INNER JOIN to the query without affecting the application layer.  Not only that, it also allows for the recombination of fields (for example a user name field today only needs to show first and last name, but tomorrow, it may need to show the middle initial as well - this change can be done at the database level and not affect the application or UI layers).  It can also make it easy to change the underlying table structure so long as the return data isn't expected to change: it provides a layer of decoupling between the application layer and the raw data storage.

In addition, having a stored procedure allows for easier testing of the data layer without the added overhead of having to execute the application runtime and walk through the debugger line by line just to figure out if the return data is correct; it is much more efficient to simply execute the query and simulate the use case to find if the data that is returned is correct.  It becomes much easier and much less painful to simulate data access tests since they can be run, observed, and analyzed nearly instantly.

In larger organizations with dedicated DBAs, stored procedures have the added benefit of allowing SQL experts to add performance tuning to eek out extra performance without requiring the application to be rewritten or recompiled.  Again, we see this decoupling of the application layer from the data layer.  Of course you could always have templated SQL stored in XML files or something that would get rid of that recompile, but it is still likely to necessitate more redeployment if the application in question is distributed.  This key point is not to be taken lightly since -- as an example -- an error in string formatting may require the replacement of binaries and services across dozens of servers.  Not only that, testing in such a scenario still requires interaction with the application layer, adding to the possible failure points, time required, and general development pain.

My own conclusion is that using dynamic SQL (including LINQ) creates too tight of a coupling between the application layer binaries and the underlying data store; it's great for RAD and testing, but in any application of significance (especially in highly distributed environments), dynamic SQL at the application layer seems like it's a maintenance and testing disaster waiting to happen.

RSS 2.0 Atom 1.0 CDF