For the over 10 past years I have been a strong critic of ORM concept. I feel that majority of people just don't understand the root
of the problem with ORM, don't understand what ORM is for, and even should it be there in the first place. I truly think that it should not,
the whole concept of ORM is wrong and here is why. I'll be talking in very practical terms.
What is ORM? ORM allows us to map relational entities (read "tables" with keys and references) into objects in your code. Sounds very cool.
Let me ask you a "stupid" question - why do you need to have those objects in your code to begin with? Huh? No, wait, don't close this page, keep on
reading....why? Ah...because you need to show the grid of customers then change selected customer and save it back to db.
Ok, let's start from display grid(or any kind of list, such as a treeview), so grid is object-oriented piece of software that "draws" lines on screen (or HTML)
that mimics a table, also it draws little string values in those "cells", so grid needs to get some data to draw. OK, but don't we have data in database? We do.
Can we read this data? We can. Can we read different column types? We can. Can we know what columns are in there(in database/table). Yes, we can. Can we build grid directly from database. We can. Can we do this automatically relying on database meta-data (data about columns, sizes, requirement etc...) WE CAN.
So, why do we need stupid POJO or POCO objects in between to draw grids? We do not. We need a "smart adapter", - a class that is absolutely universal -
it takes "data descriptor" (think of DataTable,DataSet,DataRow in .NET) and build grid columns including their default width, maybe even color to indicate importance, etc..
This class ("adapter") may also take custom style-rule set that will hide certain columns or make them smaller - but this is just for DISPLAY ONLY purpose.
Back in 1995 I have used client-server database and I needed to build an application with 200 data-entry screens. What I did, I created a grid-derivative that was "so smart" -
in 90% of cases I just wrote a select SQL - formed a dataSource and then grid showed it to me in design time (I used Delphi 1) where I dragged and colored columns to make them look pretty. Thats it! No Line of code was written in business layer, no line of code in the grid form, just NONE. No strings to configure, and when you add columns to database - they may or may not automatically appear in the grid for corresponding table, depending on 'AutoRebuildColumns' boolean property. It also worked much faster than Hibernate (that did not exist back then) because it did not create any redundant copies of data in memory(no POJO/POCO).
Same approach for displaying detail forms: textboxes, checkmarks, radios etc... All you need is this: allow developer to place controls on form to satisfy client's particular layout requirements,
wire-up every data-entry control DIRECTLY to database column by name (i'll explain how) and write NO BOILER PLATE CODE. If column "Sex" is required in table "Customer" then radio-button should automatically be named "SEX" and be required upon 'Save". You don't need to write any validation code, any "Validators" - this is all extra work and really not needed - everything is already explicitly defined in your database schema.
How to connect , say textbox directly to TABLE.COLUMN in database? Easy - you need to write some "framework" code that make your textbox "smart" by associating this data-entry field with particular column by STRING NAME, make a property "FieldName", and then everything should be read from metadata and applied to "object-oriented" properties of a text box, such as: Readonly, MaxSize etc... Some properties do not exist in DB, i.e. "text color" but that can be specified by developer in concrete form.
You feel what I am getting at here? Yes, AUTOMATIC DATABASE REFLECTION, with 100% CUSTOMIZATION ability by developer in every screen, but this is much more rare that just displaying/saving data back and forth in "default way" - without special customization.
Ok, now another part - working with "BUSINESS" objects. The truth is that in may cases you just don't need a business object because you are interfacing with
table that has limited functionality, column and row count (think US_STATES table). For complex objects such as "Patient Medical Record" Hibernate and the like dont do you much good anyway, reason being - you need to have 100% control over SQL code/stored procedures being sent to database, and yes HQL is a language of Hibernate, but wait, why do I need it, I already know PL/SQL or t-SQL and know it well, and it has operators that Hibernate does not even dream about (think of compilation hints, things like grouping sets, CONNECT BY etc...). So when I save 'Patient Medical Record" I certainly use CRUD-like helpers but definitely not a monster like Hibernate or MS Entity framework.
One last thought - when you use LINQ that you all love so much, don't forget that LINQ knows nothing about your collections in terms of indexes....binary searches...
consequently it is all very slow linear search ..... some food for thought.... LINQ to SQL? I'd rather use SQL to C# (its a joke).
Let's use excavator to dig swimming pool and spoon to eat cake but not vice-versa.
Read this link below, it will open you eyes!
16 comments:
This does make sense, if you think of your software pieces being considered as parts of relational model, NORMALIZATION RULES PROHIBIT repetition, so why would one repeat schema in: database, Hibernate on server, web service WSDL/SOAP layer, proxy on client, data adapter, typed data set and only then - grid on a client end.
Great rant. You know we are going to scaffolding, I guess this is what you are talking about here. After having spent 2 years writing stupid beans only to realize that type safe java objects are not really needed in majority of entry forms
agreed. our architects are brainwashed and make us use orms eveywhere. in the app that we build in java we have many mvc pages that we built orm classes for and they just lay there unnedded
louboutin outlet, michael kors handbags clearance, air jordan, oakley vault, burberry outlet online, kate spade handbags, louis vuitton handbags, michael kors outlet online, ray ban sunglasses, cheap oakley sunglasses, michael kors outlet online, toms shoes, prada outlet, true religion outlet, jordan shoes, coach purses, longchamp handbags, michael kors outlet, polo ralph lauren outlet online, coach outlet store online, nike free, tiffany and co, polo ralph lauren outlet, prada handbags, oakley sunglasses, nike air max, longchamp handbags, true religion, nike free, kate spade outlet, nike shoes, tory burch outlet, nike air max, louis vuitton outlet online, coach outlet, coach factory outlet, true religion jeans, ray ban sunglasses outlet, air max, longchamp outlet, air max, gucci outlet, louboutin, cheap michael kors, chanel handbags
lululemon outlet, ray ban, nike roshe, mont blanc, converse shoes, karen millen, michael kors, roshe run, nfl jerseys, nike huarache, birkin bag, beats by dre, mac cosmetics, hogan, louboutin, converse pas cher, ray ban pas cher, montre pas cher, michael kors, vans, north face jackets, lululemon, oakley pas cher, north face outlet, reebok outlet, michael kors, nike free, ralph lauren, nike trainers, louis vuitton, louis vuitton, hollister, hermes, timberland, abercrombie and fitch, supra shoes, new balance shoes, juicy couture outlet, mulberry, air max, lancel, hollister, north face, rolex watches, juicy couture outlet, burberry, wedding dresses, new balance pas cher, abercrombie and fitch, nike air max
ugg boots
air jordan 13
air jordan shoes
beats headphones
bottega veneta outlet
burberry outlet
canada goose outlet
chanel outlet
cheap wedding dresses
coach outlet
dansko outlet
evening dresses
hermes belt
hermes birkin
hermes outlet
juicy couture outlet
kate spade outlet
mbt shoes
michael kors outlet
mizuno running
moncler coats
mulberry outlet
soccer shoes
nike outlet store
the north face outlet
oakley sunglasses
ray ban sunglasses
stuart weitzman boots
surpa sneakers
north face outlet
the north face clearance
the north face jackets
the north face outlet store
north face jackets
the north face uk
tommy hilfiger outlet
tory burch outlet
true religion jeans
vans shoes
ysl outlet
kate spade outlet online, nike air max, tory burch outlet online, ugg boots clearance, prada handbags, nike air max, ray ban sunglasses, michael kors handbags, chanel handbags, jordan shoes, nike outlet, longchamp outlet online, gucci handbags, christian louboutin, christian louboutin shoes, burberry outlet online, ugg outlet, oakley sunglasses, louis vuitton outlet, ray ban outlet, nike free, cheap oakley sunglasses, cheap ugg boots outlet, louis vuitton, longchamp outlet, michael kors outlet online, polo ralph lauren outlet, burberry outlet online, christian louboutin outlet, michael kors outlet online, oakley sunglasses, ray ban sunglasses, oakley vault, ugg australia, cheap ugg boots, red bottom shoes, replica watches, michael kors outlet, tiffany and co, tiffany jewelry, louis vuitton outlet online, replica watches, polo ralph lauren, prada outlet, louis vuitton handbags
pandora jewelry, swarovski uk, canada goose, moncler outlet, links of london uk, coach outlet, ugg boots, hollister canada, sac lancel, marc jacobs handbags, air max, pandora jewelry, converse, replica watches, vans, wedding dress, uggs outlet, canada goose pas cher, canada goose, uggs canada, louis vuitton uk, moncler, barbour, gucci, supra shoes, moncler outlet, canada goose, canada goose outlet, doke gabbana outlet, moncler, juicy couture outlet, sac louis vuitton, canada goose, canada goose outlet, montre femme, thomas sabo uk, ugg soldes, louis vuitton, louis vuitton pas cher, moncler, swarovski jewelry, michael kors outlet online, louis vuitton canada, barbour jackets, converse shoes, ugg, canada goose outlet, ugg, ray ban, karen millen, moncler
herve leger dresses
louis vuitton handbags outlet
coach outlet store
ralph lauren outlet
ray-ban sunglasses
kobe bryants shoes
tiffany and co
karen millen uk
coach outlet online
phone cases
rolex uk
nike free 5
swarovski crystal
louis vuitton handbags outlet
ray ban sunglasses
cheap oakley sunglasses
michael kors canada
nba jerseys
mlb jerseys
michael kors handbags
mm1202
Tory Burch Flats Marc Jacobs Handbags Jimmy Choo Shoes Jimmy Choos True Religion Outlet ED Hardy Outlet
Burberry Belt Tory Burch Boots Louis Vuitton Belt Ferragamo Belt Marc Jacobs Handbags Lululemon Outlet Christian Louboutin Shoes True Religion Outlet Tommy Hilfiger Outlet
Michael Kors Outlet Coach Outlet Red Bottoms Kevin Durant Shoes New Balance Outlet Adidas Outlet Coach Outlet Online Stephen Curry Jersey Vans Outlet Ralph Lauren Outlet
Ugg Boots Sale UGGS For Women Skechers Go Walk Adidas Yeezy Boost Adidas Yeezy Adidas NMD Coach Outlet North Face Outlet Ralph Lauren Outlet Puma Outlet Polo Outlet
michael kors outlet
ugg outlet
ray bans
fitflop shoes
seattle seahawks jerseys
cheap ray ban sunglasses
kate spade outlet
los angeles clippers jerseys
adidas outlet
oakley sunglasses
chenlina20161027
michael kors handbags wholesale
salomon shoes
the north face
chargers jerseys
raiders jerseys
toms shoes
hermes belts
skechers shoes
san antonio spurs jerseys
replica rolex
michael kors handbags
golden state warriors
nike trainers
polo ralph lauren
michael kors handbags wholesale
true religion outlet
christian louboutin shoes
michael kors handbags wholesale
coach outlet online
cheap jordan shoes
This article is interesting and useful. Thank you for sharing. And let me share an article about health that God willing will be very useful. Thank you :)
Cara Mengobati radang Usus
Cara Mengatasi sakit pundak dan Leher kaku
Cara Menghilangkan Benjolan di Bibir
Obat Nyeri haid
Tips Menghilangkan Wajah kusam
solusi masalah kewanitaan
At this time I will share articles about health hopefully can be useful for everyone.
Cara Mengobati Demam Pada Anak Yang Tak Kunjung Sembuh
Obat Difteri Paling Ampuh
Cara Mengobati Kram Dan Kesemutan Pada Tangan Dan Kaki
Tips Paling Jitu Untuk Mengatasi Penyakit Demam Berdarah Dengue
Obat Luka Bekas Operasi
Obat Balas Bogo Pada Tubuh
thank you for the information provided, we are waiting for the next info
Post a Comment