This Blog


Favorite Posts


June 2006 - Posts

  • Guide to ORMs, part 1

    Yesterday evening I went along to the monthly meeting organized by what might grandly be called the Colorado Springs Delphi User Group. I say "grandly" because in reality it's all the people who were left over when meetup.com decided to charge for their services and everyone agreed that it wasn't worth it and we could just email each other to confirm the meetings.

    The sad thing is that it seems no one there is using Delphi for substantial new work any more. Several still say that they're using it for experimental type stuff and the majority have existing codebases in Delphi that still need maintaining, but usually new work is now being done in C#. Now certainly it may be that my sample size is way too small to draw any conclusions from this, but I think DevCo (the codename of the future company that will soon be responsible for Delphi) is going to have some work on its hands to stem the tide of defection brought about by Borland's seemingly lackadaisical marketing and promotion of Delphi.

    Anyway, this post is not about that (I'm collating information for a later larger post), but about ORMs. One of the attendees reported that he was using XPO (eXpress Persistent Objects) in his latest application and was enjoying the experience, never having used an ORM before. I was thinking about it on the way home and given that I tossed in a heavy duty post yesterday on the topic I think I'll do a series of posts about ORMs and XPO and discuss where we're heading with this library.

    Why ORMs? What are they for? What are their benefits, their limitations?

    Well, first you've got to look at the different worlds of the database and of the application, especially of the features and of the languages we use in both domains.

    The relational databases we use (SQL Server, Oracle, Access, and the like) store data as rows in tables. (Note to the relational theory purists: I'm not going to use the standard terms like tuples, attributes, and the like in this article, but instead I'm going to stick to the common names.) Each row contains a bunch of values in columns, with the assumption that these values all relate to the entity described by the row. So, in a Customers table, for example, each row is a single customer, with column values that describe that particular customer (name, address, contact, what have you). The columns of course have the same type of data (and the same meaning of that data) for each row in the table. All this seems pretty easy enough.

    Now, the thing is that we assume something more about each row: that each row is unique. Indeed some database engines enforce that sense of uniqueness by insisting on each table having a primary key, where each row has a unique value that identifies and isolates it from all the others. In general (although it doesn't have to be done that way), the primary key is identified by a single extra column (sometimes referred to as the identity column) that's tacked on just for the primary key. So we have things like Customer ID, Order ID, and the like. These tend to be integer values, although sometimes people use GUIDs instead.

    So, each row in a table defines an entity (customer, order, order line, etc) in our system, and it's uniquely identified by a key value.

    We use a language called SQL to access, maintain, and retrieve data from our database. SQL is a language that was designed to make it easy to identify rows in a table (or tables) and return them as a complete set to the caller. The caller can also specify that only certain columns are returned rather than the entire row or rows. So, viewed from a height of 50,000 feet, SQL is a language than returns sets of rows of data, or for inserting, changing or deleting data in tables in the database. SQL is not a language for displaying UI or for doing financial calculations or for creating reports or anything like that.

    That kind of work is best suited to a high level application language. These days, I'll qualify that even further, by saying that it's an object-oriented language, like C#, VB, Delphi, Java and the like. These languages use class models and instances of those classes (usually called objects) to do the work. So we write classes like Customer and Order and give them properties like name and address and order date and so on. We can also create lists of these kinds of objects as other classes, like CustomerList and OrderList.

    Hmm, superficially at least, it looks like we have a one-to-one mapping between objects in our object model and rows in our database. A row in the Customers table has a column called Name, and our Customer class has a property called Name too. It looks as if we can just use an object for a row that we've read from the database. Where's the problem?

    The first problem is this. In a database, a row is uniquely different from any other row in the same table. The primary key enforces this. We can never create two rows that have the same identity; in other words, no two rows can have the same key.

    What does this translate to in the object world? Well, big problems that's what. You see, in our application programs one object is different from another if they have different pointer addresses on the heap. So I can create two Customer objects, both with Customer ID of 1 and they will be different objects.

    (OK, I'm skating on thin ice here. Talking C# now: if I compare two objects -- that is, typed as System.Object -- with the equality operator then I'm going to be comparing their addresses on the heap. If I use X.Equals(Y) instead, a virtual method gets called that presumably checks the internal state of both objects to see if they're equal. But only if I took the time to write code that does the checking of course.)

    So we've already run into the first problem in what's known as the object-relational impedance mismatch: the problem of identity.

    We'll look at some others next time.

  • Suddenly, ORMs are hot!

    Interestingly, a couple of important events happened in the ORM (object-relational mapping) space this week. You know how it is, you wait forever for a bus and then two come along at once.

    The first one is the launch of a new community site by Roy Osherove called ORMappers.com. In the words of the founder: "This site is about sharing our knowledge about tools, technologies and techniques related to [object-relational mappers], in the hope of helping developers everywhere deal with the subject, thus making the world a better place, leading to peace, prosperity and love between Java, .NET, Visual Basic and C++ developers everywhere."

    A grand objective you must admit. Now, this will be an interesting site for me since we, Developer Express, have a library in this space as well: eXpress Persistent Objects, or XPO to its fans (the trendy fans call it xpo, of course).

    ORMs are slowly but surely getting better and better at what they do; that is, providing a mapping between an object model on the one hand and a relational model on the other (the SQL-driven database, in other words). ORMappers.com aims to help developers choose between the various offerings (which, of course, depend on your language of choice) and I hope a community does grow around it with some worthwhile help.

    And then, bam, like the smell of napalm in the morning, comes a highly-charged article by Ted Neward called "The Vietnam of Computer Science". In it, he tries to use the problems of the war in Vietnam as an allegory for what's happening in the object-relational mapping area. To quote: "[ORM technology] represents a quagmire which starts well, gets more complicated as time passes, and before long entraps its users in a commitment that has no clear demarcation point, no clear win conditions, and no clear exit strategy."

    To be honest the parallels between ORMs and Vietnam were not that interesting for me. I felt the comparison detracted from the important point that Ted was making, in that ORMs, whether you write one from scratch or use an off-the-shelf one, are currently a leaky abstraction between the object-oriented world on the first hand and the SQL-defined relational world on the other. If you ignore the first many paragraphs about the history of Vietnam (interesting as they are: he summarizes the situation well), he's written a very cogent argument about the issues that developers (and ORMs, for that matter) have to face when writing database applications and how the problems can multiply. I liked the way that he recognized that, sometimes, the problems encountered are political in nature and are not technology-related.

    His summary is a good one and well worth reading. He recognizes that, no matter what, "objects-to-relational mapping is a necessity in a modern enterprise system" and then proceeds to give six possible solutions to the ORM quagmire.

    One thing that struck me though was this: although one of the summary points was "integration of relational concepts into the languages" (and mentioned LINQ as a big step in that direction), he did not have "integration of object-oriented concepts into the database and into SQL". How long before the object-relational impedance mismatch goes away because SQL Server, say, can be run as an OODBMS (object-oriented database management system)?

  • Last minute important installation notes for CodeRush 2.0

    If you're doing a fresh install on a machine that never had CodeRush 1.x on it, then you can skip the rest of this message and enjoy your morning coffee and watch the world go by.

    If you're installing CodeRush  2.0 on a machine that previously had CodeRush 1.0 installed, follow the steps below to ensure that you get the new 2.0 templates (this is essentially a re-post of information that has appeared in threads on our newsgroups). There is also a six-minute training video that takes you through these steps (click the "Merging Templates" link on the http://www.devexpress.com/CodeRushTraining page).

    1. If you've modified existing templates or added your own custom templates, make sure those are inside their own category folder (it's okay to have subfolders inside). If you have not touched the existing templates, then you can skip ahead to step 7.

    2. Inside the Templates options page, select the folder that holds your templates, and then right-click this folder.

    3. Select "Export Folder..."

    4. Give the folder a meaningful name (e.g., "MyBasicTemplates.xml" or "MyCSharpTemplates.xml") and click Save.

    5. Repeat steps 2-4 for any additional languages you work in (use the Language combobox at the bottom-left of the options dialog to view templates for other languages).

    6. Click OK to close the Options dialog.

    7. Exit Visual Studio.

    8. Inside Windows Explorer, navigate to this folder:

    C:\Documents and Settings\{Profile}\Application Data\CodeRush for VS .NET\1.1\Settings\Editor\Templates

    Where {Profile} is the name you logged in as.

    9. Inside this Templates folder, create a subfolder and call it "Backups".

    10. Move these four files into the newly created Backups folder:


    Be sure to *move* these files. When CodeRush starts and attempts to load templates, it will look for these files. If not found, CodeRush will load templates from the installation folder (inside C:\Program Files). That's how you will get the new 2.0 templates.

    11. Install the latest version of CodeRush if you haven't done so already.

    12. Start up Visual Studio. If you skipped ahead to step 7 earlier, you're done. Otherwise, continue on to import your templates....

    13. From the DevExpress menu, select "Options...".

    14. In the tree view on the left, navigate to this folder:


    15. Select the "Templates" options page.

    16. Right-click the templates shortcut list and choose "Import Templates...".

    17. Select the files you exported in steps 2-4 and click Open.

    18. Repeat steps 16-17 for each language file exported earlier.

    19. Click OK on the Options dialog to close it.

  • CodeRush and Refactor! Pro 2.0 released!

    I apologize for the dearth of posts in the last week. It's as if I played a cruel joke: announcing that we would be releasing the latest major versions of CodeRush and Refactor! Pro at TechEd, going there and then nothing. Sorry about that, but if you've ever been to TechEd you know that it's hard to get anything extra-curricular done.

    The short story is we released version 2 of the new products today, now available on www.mydevexpress.com

    The long story is perhaps more mundane. The entire week that Mark Miller (the Chief Architect of the IDE productivity tools) and I were in our booth in the Expo Hall showing off the new features, the guys in the dev team back at base were doing the usual final building and testing that's of so much importance in creating such a quality product.

    Of course, there were a couple of moments when something major went wrong and the team suddenly had this panicked phone call from Mark or myself asking them to fix a showstopping bug (the worst was freezing VS2005 in the middle of a demo on Monday morning - it was fixed by that afternoon).

    The funniest non-bug we had was Mark suddenly losing his voice to a nasty throat infection the very first day. It was a baptism by fire: I had to provide the commentary during a demo while Mark typed at the demo PC. If you know Mark, keeping up was, shall we say, a challenge and that's before you take into account the performance of both CodeRush and Refactor! Pro. The audience seemed to enjoy our interplay as well, especially when Mark went off-script and showed some other cool feature that I didn't even know existed. The "Cools" of the audience were augmented by my "Cool" utterances too.

    After some stellar work by the team, all tests (well over 11,000 automated tests by now) passed, the build was ratified by the entire team and we kicked it over the fence to the guys who do the final checking and uploading. If you are a current customer, have at it: you can download it from www.mydevexpress.com.

    For those who've read my previous post (if you haven't, it would be a good idea to do so to understand the new subscription license model), please note that the free 90-day subscription starts today, Friday, June 16, and will end Thursday September 14.

    (A reminder: all current customers get a free copy of version 2.0 of the products whose licenses they've already bought. They also get a free year-long subscription from the original date of purchase. If that subscription has already run out or will run out within the next 90 days, we're extending it for free until Thursday, September 14, 90 days from today. You will get all updates to your product until that date.)

  • CodeRush 2.0 and Refactor! Pro 2.0: Ch-ch-ch-changes

    Deep underground in the Nevada desert, in the Developer Express high-security development labs bunker, the CodeRush and Refactor! Pro team have been toiling away on a new version of both Visual Studio productivity tools.

    In fact, it turns out they've done such an amazing job that we in HQ are in a bit of a quandary. You see, there is so much new stuff, so much new functionality, so many productivity enhancements that we have no choice but to call the new releases version 2.0.

    Over the next few days, we're going to be announcing some of the new features that have made it into both products, as well as uploading some cool new videos to show it all off. The release date is really close now: it'll be early next week. Just as a taster, how about these: Refactor! Pro 2.0 has more than twice as many refactorings as ReSharper 2.0; CodeRush 2.0 has a revolutionary next-generation template engine that delivers a significant boost in power, productivity and efficiency.

    (By the way, those “revolutionary next-generation” words describing the new engine weren’t made up by some out-of-touch marketing executive; we can't afford one. Those came straight from the architect’s mouth. When you see the mind-blowing power first hand, you’ll agree. But perhaps even more importantly, CodeRush 2.0 ships with an interactive training window, one that makes accessing all this newfound power easy, even for first time customers. Heck, I just wish they'd let me write some code around here then I could use it all for real...)

    Of course, if you are going to TechEd next week then by all means come round to our booth for the announcement and to see it all. It'll be easy to find us: our booth will be the one with developers three-deep in front of it all going "Ooooh" and drooling. Tissues will be available.

    Together with these new version 2.0 releases, and in concert with our stated policy to move to subscription licenses for all our products, we are going to take this opportunity to change how customers license CodeRush and Refactor! Pro.

    With version 2.0 of CodeRush and Refactor! Pro, new customers will be purchasing a subscription license. That means that you will be able to use the product whose license you purchased for evermore, but that you will only get updates for the 12 months from the date of purchase. After a year, customers will have to purchase a maintenance subscription for the next year, and then once a year after that.

    For CodeRush 2.0 (which, of course, includes Refactor! Pro 2.0), the initial year costs $249. For Refactor! Pro 2.0, it's $99. The maintenance subscription for subsequent years is much less, $100 for CodeRush and $40 for Refactor! Pro. (Note though that we're still finalizing the details for the renewal subscriptions, so don't take these numbers as gospel. Stay tuned.) Of course, those customers with DXperience Enterprise will get all this as part of that subscription anyway.

    Now, we realize that our current customers deserve some break here. So current licensees of CodeRush and Refactor! Pro will get a free upgrade to the version 2.0 releases, as well as a free 90-day subscription from the date of release, or a one-year subscription from the date of purchase, whichever ends later (Updated: 10:35pm 6-Jun-06). We believe that subsequent versions of these productivity tools after version 2.0 are going to be so good, you'll be buying the renewal subscriptions before the end of the 90 days just to keep up with what we've got planned. And, yes, we'll let you know later what that is.

    So, all in all, these are exciting times for CodeRush and Refactor! Pro customers. Look out for more announcements and news over the next few days. Now, if you'd excuse me, I've got to download the latest build from our internal servers...


Chat is one of the many ways you can contact members of the DevExpress Team.
We are available Monday-Friday between 7:30am and 4:30pm Pacific Time.

If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383


DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

Copyright © 1998-2017 Developer Express Inc.
All trademarks or registered trademarks are property of their respective owners