So, you wanna do some custom DataBinding?

Another cool feature of the .NET DataGrid is the ability to bind not only to Data* structures ( DataSet, DataTable, etc… ), but also custom objects and structures.

Recently, I needed to bind a DataGrid to a strongly typed collection of domain objects, hereby referred to as ‘DOs’ ( DOS, get it? )

Now, you CAN just set the DataGrid.DataSource property, as such:

     dgMyDataGrid.DataSource = DOs;

However, this will use reflection to name the columns of the DataGrid. So, if you have a property named “ObjectName”, it will show up as an “ObjectName” column. Blah….

But wait, there is a simple solution to your problem: Custom Table styles.

Create a new DataGridTableStyle object, and set the MappingName property to the type of your collection:

     dataGridTableStyle.MappingName = “DomainObject[]“

Notice the array designation. This is VERY important and the one drawback of this whole system. The collection that you bind MUST derive from System.Array in order to make use of your custom styles.

This is easy to accomplish. Let’s say your DomainObjects collection derives from CollectionBase ( as it should…. 😉 ). In order to get a strongly typed array from that collection, execute this command:

     (DomainObject[])InnerList.ToArray(typeof(DomainObject));

There you go. Now, you can create DataGridColumn objects for each column you want to display, then add them to your style. MSDN has TONS of info on this, so I won’t waste time.

Just remember, System.Array != CollectionBase or IList.

Happy Binding.

Ciao

.NET Code Access Security == No ADO.NET for you

Working on creating my first smart client.

Now, .NET has some nice no-touch smart client deployment infrastructure built right in. Simple drop the .exe onto a network share or a IIS virtual directory, and presto!. Fat client deployments for all.

I knew that there would be some security implications in going with this route, such as file access, reflection, etc… I was fine with these, since this would be a simple app.

But, lo and behold, in the default .NET security configuration, ADO.NET access is denied by default in both the Internet & Intranet zones. Internet zone makes sense, but Intranet? Aren’t most remotely accessed applications some for of data entry.

This boggled me, but have no fear, everything is configurable. We simply add a new Code Group that gives Full Trust permissions to anything strongly named with our key.

Sounds good?

One small catch is that this must be done on a per COMPUTER basis. That means, before a computer can run the application, it has to have these security settings configured for it. Big pain in the ass.

Now, onto figuring out some way to remotely run caspol.exe on several hundred workstations. Me thinks pexec.exe will come into play.

Ciao

Repeat after me: Referential integrity constraints are DB concepts.

Repeat after me: Referential integrity is a DB concept.

Recently I was discussing how to introduce a domain model into an environment that currently revolves around the database. Everything is in terms of the database. Everything.

While discussing this architectural decision with the client, I was surprised by the following question:

“How are we going to represent the foreign key constraints & referential integrity within the object? Can we set some ‘triggers’ to check for that stuff when the objects are used?”

I then had to explain that referential integrity constraints had a couple of properties:

1. They enforce normalization

2. They are automatically enforced by the database

Now, you can see from 1. above that not only is referential integrity a database concept, but it actually enforces another database concept, normalization. Now, add the fact that normalization is a OPTIONAL database concept, and you have a tough time trying to justify why it should be represented at the object layer.

As for 2., I can understand why the client would like to enforce the integrity because it prevents invalid data. This is very valid and warranted. But, since referential integrity is a database construct, it’s actually enforced by the database anyway, so as long as the constraints are setup properly, nothing will be allowed to put invalid data into the database, not a object model or a vanilla SQL statement. This alone makes it unnecessary to replicate the constraints at the object level for validation.

Also, let’s say you wanted to replicate the constraints at the object level. How exactly would you accomplish that? Either you are calling to the DB for every single column that has a constraint placed on it, in order to verify the data provided is valid, or you are constantly loading up the entire foreign key list to check against.

Either way, that’s a LOT of overheard just to validate something that will be validated ANYWAY. People need to learn that the database is not the be all and end all of a system. Even if it is, design & performance decisions that are made at the database level should not be pushed up to the developers.

Roeper's "31 movies that changed the face of cinema" list

Robert Roeper lists the 31 movies that he thinks changed cinema.

More to the fact, I think the title should have been “31 movies that changed the business of cinema”. How else can you explain number 24?

I will list each here, along with why it was on the list. Some notable MIA’s from the list include the Matrix & Pulp Fiction. But, that’s the beauty of movies. It takes all kinds.

Onto the list:

  1. Fade In ( 1903 ) – Introduced parallel narratives.
  2. Nosferatru ( 1922 ) – First real villain.
  3. Battleship Potemkin ( 1925 ) – Frame by frame finesse
  4. Stagecoach ( 1939 ) – Introduced Westerns as a viable genre.
  5. The Wizard Of Oz ( 1939 ) – First to use colors as part of story, first female villain, twist ending, pop culture influences
  6. Citizen Kane ( 1941 ) – Overlapping dialogue, low-angle shots, experimental lighting, use of newsreel footage to advance storyline, a subjective camera.
  7. Rashomon ( 1950 ) – Introduced subjective flashback story telling.
  8. Method Man ( 1954 ) – Brando’s Character actor
  9. The 400 Blows ( 1959 ) – Blueprint for disenfranchised youth movies, famous last shot: zoom in frozen shot of main actor.
  10. A Hard Day’s Night ( 1964 ) – Beatles “movie” is first music video.
  11. 2001: A Space Odyssy ( 1968 ) – Brings Sci-Fi into legimate cinema. Similar effect of Stagecoach.
  12. Easy Rider ( 1969 ) – Society’s reflection.
  13. The Godfather I & II ( 1972, 1974 ) – Blueprint organized crime drama.
  14. Deep Throat ( 1972 ) – Introduces Porn into mainstream.
  15. Blazing Saddles ( 1974 ) – First ( some say best ) spoof.
  16. Jaws ( 1975 ) – First “summer blockbuster”, first movie to have “wide release”.
  17. Star Wars ( 1977 ) – Introduces “franchise” tie-in.
  18. Saturday Night Fever ( 1977 ) – Couples soundtrack record release with movie for first time.
  19. Halloween ( 1978 ) – Slasher template.
  20. Tron ( 1982 ) – Greenscreen pioneer.
  21. Blade Runner ( 1982 & 1992 ) – First movie to have a “director’s cut”
  22. 48 Hours ( 1982 ) – Wisecracking, opposites buddy movie template.
  23. Terminator ( 1984 ) – Rental market generating buzz for a movie.
  24. Red Dawn ( 1984 ) – First PG-13 movie.
  25. Little Mermaid ( 1989 ) – Brought Disney back from dead and paved the way for other disney movies.
  26. Clerks ( 1994 ) – Introduction of independent film making.
  27. Toy Story ( 1995 ) – First movie made on computers.
  28. The Blair Witch Project ( 1998 ) – Redefined marketing. First to use Internet as marketing tool.
  29. Bowling For Columbine ( 2003 ) – Documentaries brought into mainstream.
  30. The Passion of the Christ ( 2004 ) – The most stunning financial success in movie history.
  31. The Polar Express ( 2004 ) – Fully digital actors & “performance capture” allowing Tom Hanks to play four widely different characters, including a 4 year old boy.

What makes an artist great?

There are 3 things that I consistently come back to when I have to defend why I think an artist is great.

1. Longevity

2. Periods

3. Distinct, but continously different sound.

Longevity

Though less important that the next two, there is something to be sad for an artist / band that merely remains relevent for extended periods of time. But, that could just mean that the core audience is growing up, and still buying records. So, while this is important, I will quickly move onto the next two.

Periods

This is something that is understated when it comes to musicians. Other artists in other mediums all go through periods, in which their style changes, their message changes, etc…

I haven’t seen this applied musicians as much as it should. For example:

  • Prince
  • Madonna
  • 2Pac

All of these artists remain popular today, but all have gone through significant transition periods when it comes to their lives and their music. These periods could go from clever instrument experimentation ( Price ), the reflecting ones ever changing self expression ( Madonna ), or merely the traversal of ones soul as they step through life ( 2Pac ).

What ever the basis for the periods, the fact remains that each artists goes through transitions, and these transitions are reflected wonderfully in their music. Yet, there is always the artists underlying style anchoring all of their music. Which leads into the last one.

Distinct, but continously different sound

Have you ever heard a band’s new cd and been hard pressed to not think of their previous albums? I know I have. Not that the album is bad, per say, just that you have this nagging feeling that you have heard it all before, even though it’s completely new. Some examples of this can be found in the following artists:

  • Green Day
  • Godsmack
  • Eminem

These are just a few of the artists whose albums are consistly “good”, just not consistently discernable from any previous works. In my opinion, a great artist is able to come out with fresh, new sound, while still sounding like themselves.

My most recent example of this is the new Rosi Size cd, Return To V. Now, for those not familiar, Roni Size is the premier artist in a sub-genre called Drum & Bass. The music within Drum & Bass is just that, a lot of pulsing drums and thumping bass. With Roni’s new cd, however, he chose a different path. Rather than another Drum and Bass cd, he chose to take all 18 ( yes, 18 tracks with no filler ) and insert the dynamic vocals of artists from all different genres, including Neo-Soul, Hip-Hop, R&B, and Jazz.

The result is a unique album, filled with dizzying vocals layered ontop of rhythmic drum and bass. Even through all of this, Roni Size’s presence is still there, in the forefront. You never doubt that he’s still there making all of music that has made him famous, just with some slight twists.

And that’s what I am referring to when I allude to a distinct, but different sound. Some other artists that can accomplish this:

  • Basement Jaxx
  • The Neptunes
  • The Roots
  • Nelly Furtado
  • Kanye West

Again, this is just some of my babblings, but I am curious as to what other people think makes an artist great?

Journey of 2700+ pages begins with the first 900+ page book

Neal Stephenson is some sort of masochist…

I know this may be old news, but I recently had the urge to dust off my copy of Quicksilver and give it another go. I’ll admit, it is going to be a big undertaking.

I mean, after the TOME that Cryptonomicon was, he releases a new three part series, with each book the size of Cryptonomicon?

I am sorry, but if a book weighs more than my baby, it’s too freaking big.