Why Object Relational Mapping?


OR mapping keeps the code in your application encapsulated and clean, and it makes it easy to manage changes in the database. By building an OR mapping component, your database logic will be encapsulated and hidden away from the rest of your system. Because the logic of loading and saving your object rests entirely in the OR mapping subsystem, the code in the rest of your program uses only clean object-oriented code. It also makes it far easier to make changes to the database later without having to alter every place you reference the data.

The core issue is short-term vs. long-term laziness. Using short-term laziness would probably put SQL queries directly in your Web pages and just use SqlDataReader objects to work with your data. Past the initial implementation, this method makes your code hard to maintain. If you add a column to the database, you'll have to find every reference to that table in your application and update it. Also, as the need to use the same table on multiple pages arises, you'll find yourself copying and pasting large sections of code to get the same functionality on these new pages as well.

Long-term laziness means taking the upfront time costs associated with building out the object relational mapping for your table. It will definitely take you longer to initially produce these objects, but in the long term it will mean much less work.




Applied ADO. NET(c) Building Data-Driven Solutions
Applied ADO.NET: Building Data-Driven Solutions
ISBN: 1590590732
EAN: 2147483647
Year: 2006
Pages: 214

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net