Day 1 - Arrival and PreConference Session

Technical content of this issue - 2 out of 5

Did You Miss Us?

Hard to believe it's been 3 years since the last issue of Biff's PDC Newsletter. But here it is 2008 and, like the mythical city of Brigadoon, our publication returns from the ether for our short life in this world.  Before I left, one of my newer subscribers, weary of the upcoming election, asked if there would be political commentary in the newsletter. Absolutely not - but even though we refrain from politics doesn't mean that the political blogs refrain from talking about us. Check out the latest www.DrudgeReport.com - our fame continues to grow. We must be good for the economy, because I sent the initial announcement for this year out on Sunday, October 12 and the next day the market climbed 11%.  Now that we're actually publishing be sure to watch the market tomorrow morning!

Getting Here is Half the Fun

On the way out, I flew on Virgin America for the first time. This airline rocks. I found them on the web when researching legroom on various airlines, and theirs is one of biggest of all domestic carriers. The seats are all leather, with hard plastic backs that are easy to keep clean. Each seat has a small video screen on the back, with a large range of features:

  • Watch one of about 20 cable television stations. I watched college football on ESPN 2
  • Listen to music. They have about 15 songs from 85 different artists and allow you to create your own playlist. A free shoutout to the reader that can identify the following obscure lyric from my playlist - "is that a real poncho...i mean is that a mexican poncho or is that a sears poncho? "
  • Various video games
  • Movies on demand
  • Order food

When we boarded the system was locked up and had to be rebooted - whereupon we learned that it was a LINUX system. The whole thing operated by touch screen (I should mention that  the lady behind apparently thought it was a pound screen - the only drawback of the flight). There's also power outlets and network connections under each seat - on the way home I'll see if there is Internet access from your seat.  I essentially sat in a leather easy chair and watched football all Saturday afternoon - I might was well have been home!

On to today's session (those of you who just want the fun stuff, there are new letters at the end of this issue).

Microsoft .NET Framework Data Access from A to Z

Presenter(s): Michael Pizzo, Jose Blakeley

On the Sunday prior to the official opening, the conference offers a number of pre-conference sessions. These all day sessions are a little less forward looking than the regular sessions, but are usually worthwhile. This year I started in a session that advertised "you will leave this session knowing which data access technology best fits your need; you will also get advice on how, when, and if you should migrate from existing technologies to these new ones." I stayed for about 4.5 of the 6 hours, you can judge whether they met this criteria for yourself.

The session started off with a history of data access from DB specific APIs to today's world of ADO.Net (or JDBC but they didn't mention that). I'm not going to write it all up here, it was mildly interesting but you're either old enough to remember or too young to care. It was demonstrated to me recently just how old I have become when 5 out 7 members of my current team has never seen Animal House - so there are 2 people on my team that might have a chance of remembering data access prior to the Jet database engine.

About an hour into the session we were treated to demos of ADO.Net 1.0 functionality, including DataSets and TypedDatasets - not exactly what I flew across the country to see. Then someone stands up to ask a question on the demo and took over the presentation for several minutes asking a question that was answered a couple years ago by partial classes. The other presenter finally stepped forward to help out the speaker and gently deferred the guy - I was impressed with how smoothly he handled it, he was obviously a very experienced speaker. Readers who know me can only imagine how I would have handled it… Later a guy asks "What is the advantage of TypedDataSets over DataSets?" and I'm starting to wonder if it would have been easier to see a session like this for free at a free Microsoft event in Herndon. So far this would have been a great session for TechEd '04. Some of these guys should just go out and buy a WROX book written by 37 guys with their pictures on the cover and get their answers there.

The speakers switched after about 1.5 hours and the content is got better. Michael Pizzo started by discussing reasons programming data is hard - because rectangular data normalized for data access does not map naturally to business object framework.  Not rocket science, but it's good to articulate the issue clearly every now and then. He made a list of what developers are seeking to address this problem-

  • Rapid Development (strongly typed queries and results)
  • Lower TCO (decouple application from storage schema)
  • Better Portability

He then made the assertion that applications today implicitly contain the data model - that business logic and the data model are intertwined, often encapsulated in a Data Access Layer. Still no great revelations, but at least we're talking at a deeper level and I'm distracted from watching my Fantasy Football ticker (where I'm kicking some serious behind by the way).

MMy personal point of view on his assertion - I loathe the concept of a data access layer that is wedded to the data schema, where every new entity adds new methods to the interface. One of the things I'm looking for in this session is a way to have a data layer that doesn't have 4 different methods (CRUD) for each entity in the domain. My daughter, now in high school, will recognize the literary device of foreshadowing when I mention that I'm going to be disappointed.

Microsoft's goal was to create a platform that addresses these issues while bridging the impedance mismatch between relational data and business entities. Hey, that shouldn't be too tough, it's just been attempted unsuccessfully countless times!

The Microsoft Entity Data Model

Things were going by pretty quickly here, so my descriptions and definitions are going to be a little haphazard. I've included a link or two along the way for people to get more info.

The key to the Microsoft Entity Framework is the Microsoft Entity Data Model - a relational model based on Entity-Relationship Model concepts. Some of the concepts included in the EDM are:

  • EEntity Types - Providing strong typing for entities
  • Entity Sets - Collections of Entity instances
  • Relationships (Associations) -Named relationships between entities
  • Association Sets - Instances of associations
  • Entity Containers - Contain EntitySets, AssociationSets

The goal is to create a language/schema that can be used to map business entities to relational tables. More info on this can be found here. The EDM for a domain is defined by XML according to an XML schema.

EntitySQL

EntitySQL is a SQL dialect for manipulating the Entity Data Model. Some of the features it provides are-

  • SELECT VALUE - using this in your code results in getting a typed object from the framework rather than a DataRow
  • Entity construction - Create entities based on the DataRow
  • TType Operations - From what I could tell, this allows you to create an entity of differing types depending on a data in the row. For instance, say a person table holds developers and salespeople. The EDM can be written to map a data row to either object based on the value in the IQ column.
  • Relationship Navigation - this allows you to navigate up or down a hierarchical tree based on the Relationships.
  • Manipulation of Keys - I didn't catch what this was for.

So those are the conceptual definitions allowing access to the Entity Framework technology, at this point he started discussing the architectural elements of the technology stack supporting it.

At the bottom is regular old ADO.Net. Even with cool new access technology, sooner or later we need to actually talk to a database so let's use these relatively well suited, stable, well performing constructs.

IImmediately above ADO.Net is the EntityClient Data Provider. This layer provides the conceptual schema of the data and translates between the flat data in the DataReader and the hierarchical data.

Next on the stack is Object Services, where the conceptual schema of the EntitlyClient Data Provider is converted to entities (objects) using technologies like .Net reflection.

Finally, at the very top comes LINQ to Entities.

Entity Designer

It wouldn't be a new Microsoft technology without a cool dev tool that reduces everything to drawing pictures without having to write any actual code so the sales group can do demos. For creating the EDM we have the Entity Designer. In the Entity Designer there are two ways to create your EDM-

  • Reverse engineer a model from an existing database
  • Create one from scratch by dragging entities onto the window and adding properties, relationships, etc.

You can't yet create a database schema from a completed EDM, but that has been promised in version 2. The look of the tool is very predictable, think of any other object/schema visual editing tool you've seen from Microsoft and that's pretty much it. Note that the tool is not the EDM, the EDM is the underlying XML, which can be edited by hand as well when the limitations of the tool are reached. Limitations? What limitations? Thankfully he was nice enough to list several of them-

  • No code first schema generation - this is what I mentioned above
  • No Complex types - I didn't catch what this means
  • No Abstract types - I didn't catch what this means
  • No Multiple Entity Sets per Type - I didn't catch what this means
  • Practical limitation of ~120 entities - This is self-explanatory
  • No design support for SSDL ( ) - I didn't catch what this means
  • Must manual edit XML
  • Refresh overwrites manual changes - one reason why serious apps seldom use the pretty picture tools
  • Lack of automatic pluralization support - Doesn't automatically create an employee object when you create an employees collection
Demo

He did a demo next, and although I won't go into the specific details, it did reveal a couple points that I thought were important.

He demonstrated the Entity Framework implementation of lazy loading and eager loading. Lazy loading has to be explicit, there's no wrapper in the entity that automatically gets the child object and if you have some way to explicitly get it an exception is thrown. The getter on the parent can implement the lazy load very easily, however, so it did not seem to be much of a drawback.

The eager loading was a different story. You can instruct the framework to include specific child entities and the SQL that the framework generates will automatically get all the specified children as well. He displayed the SQL generated and it spoke to 2 issues. First - eager loading is done in a single round trip to the database. This is a major difference from nHibernate. Second - I hope the automatically generated SQL is pretty good, because I don't know how much influence you have over it.

Finally, unlike some of the LINQ extensions, this works on Oracle.

At this point the first presenter got back up and displayed an agenda slide that showed the rest of the session was going to be introduction to LINQ with lots of wizard demos, etc. I've seen LINQ demos on my side of the continent, so I decided to migrate to a different session.

Design for Performance in .Net

Mark Friedman

I just walked in to the last couple hours of this session and got a couple nuggets of information that I will relate without trying to string them together with a catchy narrative.

The presenter commented on watching the Garbage Collector counters in PerfMon and said his opinion of a healthy app had about a 10 to 1 ratio between the different generations of GC. For instance, if you're seeing 1000 generation 0 collections, a good number of generation 1 would be 100 and generation 2 would be 10. If you are drastically off from this (eg 1 to 10 instead of 10 to 1) you have serious issues with the size and lifetime of your allocations.

He asserted that the most important factor in poor performance is network latency (I assume he talking about web apps). He said round trips that are quick in your test environments on your local networks are the things that get slow when you deploy in the wild (eg - the JavaScript is the same, the server is the same, the download size is the same, etc.)   My impression has been the the number of database round trips is the most common performance problems on web apps (I've seen it many times) - but those are performance problems you see in the lab.  His take on bad performance in the wild was interesting - note that he explicitly said he was talking about latency, not bandwidth.

He brought up MSDN and it took about 15 seconds to finish coming up. He used a tool called the Visual Round Trip Analyzer, which gives graphical view of data gathered by the Network Monitor (I have links to both below). It showed graphically exactly what was being loaded and in what order, including things being downloaded simultaneously on different sessions. Turns out there were 540 round trips to get all the included files and items. The graphical tool painted a pretty ugly picture of what was going on.

Link - Visual Round Trip Analyzer
Link - Network Monitor

Caching: His comment was that the ASP.Net caching facilities are complex facilities that may require considerable monitoring & analysis to achieve optimal results. You can't just turn a switch and get magic results. There's an extensive discussion of caching on the P and P page - Caching Architecture Guide for .Net Framework Applications

Ever have several w3wp.exe processes running and don't know which one is which web site? There used to be no way to tell, but in IIS 7.0 there is a command, "appcmd list WP" that will display this information.

Letters! We Get Letters!

For new readers, we always try to close each issue by answering some of our voluminous mail (where "voluminous" means "I hope we get some mail"). This year we actually have some mail before the conference even starts.

SH from CA admits - "Yes!!!! I didn't realize how much I've missed the PDC newsletter until now."

LW from MD reveals - "I love the newsletter! My life has been so empty without it!"

Geez, when I hear hard luck stories like these I feel bad that the PDC was canceled in '07 and you had to wait an extra year. I know in troubled times like these, folks tend to cling to their Biff's PDC Newsletter. Maybe I should have just pretended there was a PDC and made a bunch of stuff up (wait - making a bunch of stuff up is what I do anyway). - Ed.

DC from MD confesses - Count me in for the newsletter! I've defected to the java side but I'm sure it will be interesting anyway. Go Java!! :)

Parents, it's apparently too late for DC, but learn from this. Spend time with your kids, teach them right from wrong. Otherwise you may open your Outlook to read your Microsoft Live Hotmail account and get a shock like this. I'm verklempt. - Ed.

PO'C from VA brags - I'm excited to receive my reduced price subscription to Biff's PDC Newsletter. When I collect a whole set, I'm going to recreate them with my home calligraphy kit and give them to my nieces as Christmas presents.

PO'C, I would remind you that BPN is copyrighted material and the hope of a meager settlement from a nuisance lawsuit is all the keeps me going. We could negotiate some sort of deal if you could get me a framed copy of Day 3 in time for Mothers' Day. - Ed.

If you have anything you want to say, any technical questions or any comment that gives me the opportunity to make an even moderately witty retort, send your mail to editor@biffspdcnewsletter.com.

Tomorrow the Big Show begins!

Biff
Government Bailout Acquisition Specialist, Biff's PDC Newsletter