Thursday, July 13, 2006

Domain modeling or data modeling

Domain modeling or data modeling?

(a) Users do not care “objects”. They care UI, and the fact that the data on the UI are saved in databases. So, by definition, UI and the key data are the “business language”; objects are not.

(b) The pragmatic inevitability of Anemic Domain Model http://www.martinfowler.com/bliki/AnemicDomainModel.html-- OK, just in case I am not clear enough, I am saying that although sounds terrible, anemic domain model is a good thing. -- Just as others pointed out, OR mapping encourages this. Again, a lot of people believe it is a bad thing (and therefore, OR mapping is a bad thing!), I believe it is a good compromise.

(c) Part of the reason of (b) is that > 80% of the function of an application is “data CRUD”; so, why bother domain model.

(d) Because of all above, domain model can be “skipped” at least for smaller projects; for larger projects, it is certainly a good exercise. However, even in the latter case, the first-cut of the major database tables should be done first; therefore, the key objects should be “copied” from data model. The key reason is, of course, users (see (a)). This is crucial. You may find ways to “bypass” the data modeling phase, and say that you start with a “domain model”. However, if you think of the reason how you get the major objects done, it is always “we need those key data”! OK, the value of being honest to ourselves? – Time saving: > 90% of the domain model can be done within one or two days, after data model is done. And data model is much easier to do, because you can get help from users directly. You may say, how about the rest 10%? – Those are the low-level objects, they are implementation oriented; and we should not talk about them with users anyway.

(e) Fit can fit in perfectly, even when we do not use domain modeling. The key is data.

108 comments:

  1. Nice post. After reading your post, I wrote this post.
    http://vikasnetdev.blogspot.com/2006/07/domain-driven-design-vs-data-driven.html
    I reached the conclusion that Domain Driven Design is like automated unit testing for project with multiple releases. It is very important and cost effective in long run. Doing Domain Model Design before Data Model Design or in parallel has some benefits. But important thing is whether you do it at all or not before you jump to coding

    ReplyDelete
  2. Nice posting. We are close to see the light :-)

    1. I agree the importance of “custom classes” – I just use “one table, one class” rule for 80% (or 70%) of the application.

    My point is that if we have done the 70% first by “copying” the data model, it is a much faster and therefore a better approach. My understanding is that you feel it is just a possible option, while I believe it should be formalized as a necessary first step.

    2. I agree that we need “controller” or “process” class layer. As a matter of fact, in CSLA, I was the last straw of the people of asking Rocky about it and prompted Rocky to post the “workflow” (or “process”) class solution in CSLA. Frankly, to me, putting business logic UI is not just a crime, but a felony crime.

    However, I must say that “domain modeling” per se is not the issue here -- I have sensed that we have a terminology issue here: in my mind, “domain modeling” per se does not include the “process” class part. To me “domain modeling” is about those “entity classes” (i.e., anemic domain model). Actually, this is implied in those J2EE architecture diagrams, and also implied in MS’s SOA/application diagrams (they are obviously from J2EE anyway).

    However, I know this kind of terminology difference can make reasonable discussion impossible; so, let’s put it aside.

    My point is, how about we use data modeling, and by assuming “one table, one class” most of time, we get a “free” entity model. Then, we assume there is another layer, and we use common sense/”best practice” to design/implement the “business logic” layer. I put “design/implement” here, because most of the time, the “controller”/”process” is straightforward – that is, once you get used to the “anemic domain model” – again, I believe the horrible name refers an actually good compromise: if you do SOA, you got to have “anemic domain model” (the best you can do in SOA is to translate the shallow logic in “anemic domain model” into javascript).

    By doing the above, I can successfully avoid “domain modeling” – “See, Mom, no UML!”

    3. You may say, come on, you are doing it in your mind; be honest to yourself, man! Yes, let’s drive it deeper in the same spirit of being honest to ourselves. The real thing is – by the way, thank you for quoting the example -- this really shows that a good example is better than thousand pictures ;-) -- that I do not believe users will say “Delete the rows. OK, whatever”. No, a real user will never say that – that is, under “normal” situations.

    Yes, a bad developer will use data modeling incorrectly, and confuse users to such a degree that a user will say “whatever” to whatever. However, that can have in “domain modeling” also.

    My point is, users will never understand objects with certainty; in a sense, even in “normal” situations, users will always say “whatever” in their mind when developers talk about “objects”. However, users do know, for absolutely certainty, that certain data must be persistent. Right, they do not know and do not need to know whether the data are in Oracle or SQL Server, or even in a flat file; but they do know they must be persistent and must be shared!

    Users’ astute senses of what data must be persistent are the major (read as “only”) source for the first-cut of both data modeling and domain modeling. Because it is indeed data, so, it is only honest to say that we are doing data modeling first, regardless whether we call it data modeling or not.

    ReplyDelete
  3. Yes, we are getting close. Domain Driven Design is going to get two new practitioners or may be none. :)

    http://vikasnetdev.blogspot.com/2006/07/domain-driven-design-vs-data-driven.html

    ReplyDelete
  4. While waiting for vikas's moer comments, I came across a post:
    http://codebetter.com/blogs/jeremy.miller/archive/2006/07/05/147119.aspx

    Here is my comment:


    People do not like UML because just as Vikas pointed out: they do not like “domain modeling”; and the reason that they do not like “domain modeling” is that “data modeling” is sufficient already; the extra “domain modeling” is waste of time.

    Note that UML is now a superset of ER, so, you may say, if we use UML to do the data modeling, then, people will love UML ;-).

    I want to point out that excluding “data modeling” from “domain modeling”, or, thinking “domain modeling” is OO only, instead of both database and OO, is the leftover of an old myth that DABs are in charge of database table design.

    Nowadays, because programming is so “easy” (because .net or java is so powerful), and also because SQL Server (or Oracle, DB2) is so “easy” also, developers are in charge of both data design and OO design (i.e. programming design). As a result, “domain modeling” includes “data modeling”. Also, data modeling should be done first. Further, in most projects, most OO modeling should be simply copied from the data model; and therefore a separate OO domain modeling per se is totally unnecessary.

    ReplyDelete
  5. D3o1D8 The best blog you have!

    ReplyDelete
  6. 9MFu4y actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.

    ReplyDelete
  7. Thanks to author.

    ReplyDelete
  8. Thanks to author.

    ReplyDelete
  9. Thanks to author.

    ReplyDelete
  10. Please write anything else!

    ReplyDelete
  11. Please write anything else!

    ReplyDelete
  12. Nice Article.

    ReplyDelete
  13. BreDLg write more, thanks.

    ReplyDelete
  14. Please write anything else!

    ReplyDelete
  15. Nice Article.

    ReplyDelete
  16. Please write anything else!

    ReplyDelete
  17. Wonderful blog.

    ReplyDelete
  18. actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.

    ReplyDelete
  19. Nice Article.

    ReplyDelete
  20. What is a free gift ? Aren't all gifts free?

    ReplyDelete
  21. Give me ambiguity or give me something else.

    ReplyDelete
  22. Clap on! , Clap off! clap@#&$NO CARRIER

    ReplyDelete
  23. 640K ought to be enough for anybody. - Bill Gates 81

    ReplyDelete
  24. Please write anything else!

    ReplyDelete
  25. Friends help you move. Real friends help you move bodies.

    ReplyDelete
  26. The gene pool could use a little chlorine.

    ReplyDelete
  27. Clap on! , Clap off! clap@#&$NO CARRIER

    ReplyDelete
  28. Save the whales, collect the whole set

    ReplyDelete
  29. Friends help you move. Real friends help you move bodies.

    ReplyDelete
  30. Please write anything else!

    ReplyDelete
  31. Oops. My brain just hit a bad sector.

    ReplyDelete
  32. Energizer Bunny Arrested! Charged with battery.

    ReplyDelete
  33. Wonderful blog.

    ReplyDelete
  34. The gene pool could use a little chlorine.

    ReplyDelete
  35. Oops. My brain just hit a bad sector.

    ReplyDelete
  36. C++ should have been called B

    ReplyDelete
  37. Build a watch in 179 easy steps - by C. Forsberg.

    ReplyDelete
  38. Lottery: A tax on people who are bad at math.

    ReplyDelete
  39. Lottery: A tax on people who are bad at math.

    ReplyDelete
  40. What is a free gift ? Aren't all gifts free?

    ReplyDelete
  41. Thanks to author.

    ReplyDelete
  42. I don't suffer from insanity. I enjoy every minute of it.

    ReplyDelete
  43. Ever notice how fast Windows runs? Neither did I.

    ReplyDelete
  44. Friends help you move. Real friends help you move bodies.

    ReplyDelete
  45. What is a free gift ? Aren't all gifts free?

    ReplyDelete
  46. What is a free gift ? Aren't all gifts free?

    ReplyDelete
  47. I don't suffer from insanity. I enjoy every minute of it.

    ReplyDelete
  48. When there's a will, I want to be in it.

    ReplyDelete
  49. Clap on! , Clap off! clap@#&$NO CARRIER

    ReplyDelete
  50. Suicidal twin kills sister by mistake!

    ReplyDelete
  51. When there's a will, I want to be in it.

    ReplyDelete
  52. Build a watch in 179 easy steps - by C. Forsberg.

    ReplyDelete
  53. Energizer Bunny Arrested! Charged with battery.

    ReplyDelete
  54. Nice Article.

    ReplyDelete
  55. Friends help you move. Real friends help you move bodies.

    ReplyDelete
  56. Please write anything else!

    ReplyDelete
  57. Energizer Bunny Arrested! Charged with battery.

    ReplyDelete
  58. I don't suffer from insanity. I enjoy every minute of it.

    ReplyDelete
  59. Energizer Bunny Arrested! Charged with battery.

    ReplyDelete
  60. Change is inevitable, except from a vending machine.

    ReplyDelete
  61. I'm not a complete idiot, some parts are missing!

    ReplyDelete
  62. The gene pool could use a little chlorine.

    ReplyDelete
  63. What is a free gift ? Aren't all gifts free?

    ReplyDelete
  64. Please write anything else!

    ReplyDelete
  65. Give me ambiguity or give me something else.

    ReplyDelete
  66. 640K ought to be enough for anybody. - Bill Gates 81

    ReplyDelete
  67. Suicidal twin kills sister by mistake!

    ReplyDelete
  68. Suicidal twin kills sister by mistake!

    ReplyDelete
  69. In my experience, you are correct that "data modeling" works fine for small to mid-size projects with minimal complexity, and you get a basic "domain model" for free. This is the essence of the ActiveRecord pattern and works quite well, with 1:1 ratio between objects and tables.

    The problem is with more complex applications that have a lot of logic. At this point the data driven approach breaks down, because there is so much more behavior and business rules in the system. The data driven approach tends to cause developers to ignore all these "extra objects" that don't fit the usual CRUD pattern and 1:1 table/object ratio. If you have a good developer, they'll be able to switch gears to a DDD approach when the complexity warrants it, and create the extra objects in the model as necessary. If you don't have strong developers, chances are they will take a fairly procedural approach or possibly copy and paste a lot of logic around.

    To play devil's advocate, why not start with a DDD approach on most projects? If its a small project and stays small, chances are you will get "your tables for free" and the CRUD stuff with it. Many ORMs will do the CRUD stuff with your objects and some will even generate your tables too (not that making tables and constraints is hard.)

    In my early career, i focused strongly on a data driven and procedural approach to development. This worked fine for most of the simple applications that i was working on where the majority of logic was CRUD. But i kept painting myself into a corner on the more complex applications until I found OOP and DDD. I know you think that DDD is out of date, but i think it is still quite relevant as applications become more complex.

    I also think that you are wrong that people only see UI and the data on it, so thats what we should focus on the most. If something calculated (like interest) is wrong, they'll notice that too, even though thats not data its behavior.

    Also, users don't really understand relational databases or tables any more than they do objects.

    I don't mean to offend you Survic, but you strike me as being where I was about 5 years ago before i started tackling complex line of business applications.

    ReplyDelete
  70. Finally, my wife and hergirlfriend come out but they are with two other girls and a black guy. I didnt get much.
    true sex stories brothersister
    teen audition sex stories
    brazil fuck stories
    preteen erotic free sex stories
    stories about spanking
    Finally, my wife and hergirlfriend come out but they are with two other girls and a black guy. I didnt get much.

    ReplyDelete
  71. While getting her earwell probed, she again pleaded, John, stop. Each push up helped him keep crime off the streets ofLazy Town and keep the beds of the ladies warm throughthe nights.
    sexy erotic stories
    incest stories and pictures
    free interracial cockold stories
    lesbian bondage rape stories
    adult free stories
    While getting her earwell probed, she again pleaded, John, stop. Each push up helped him keep crime off the streets ofLazy Town and keep the beds of the ladies warm throughthe nights.

    ReplyDelete
  72. UlzRle [url=http://canadagoosejacketsite.com/]canada goose jackets[/url] UwkNry SicFkf http://canadagoosejacketsite.com/ RqmMed AheTag [url=http://canadagoosejacketclub.com/]canada goose jackets[/url] IpzTwr RqoDes http://canadagoosejacketclub.com/ GgpHkt MrzGuc [url=http://canadagooseoutlettoca.com/]canada goose[/url] CxrPrf QsoBhf http://canadagooseoutlettoca.com/ FagJhy UgpErz [url=http://canadagoosesalehome.com/] canada goose parka[/url] GiuGpz BnkBin http://canadagoosesalehome.com/ UsuJtw

    ReplyDelete
  73. ZngUbi [url=http://www.bootsmany.com/]アグ[/url] FszRos http://www.bootsmany.com/ IkpEdi [url=http://www.bootsnewjp.com/]UGG アグ[/url] QhoCrq http://www.bootsnewjp.com/ DqgVtd [url=http://www.bootsbestjp.com/]ugg アグ[/url] SzkTdr http://www.bootsbestjp.com/ ZxwNln[url=http://www.yasuibu-tsu.com/]ugg アウトレット[/url] VzrZmg http://www.yasuibu-tsu.com/ WgcGdo [url=http://www.yoibu-tsu.com/]ugg ブーツ[/url] BmyGtd http://www.yoibu-tsu.com/ OuuIds [url=http://www.bootsjpsales.com/]ugg ムートン[/url] ZiuWid http://www.bootsjpsales.com/ GgmUyp

    ReplyDelete
  74. ZpnZef [url=http://cheapggboots.com/]cheap ugg boots[/url] PisMxd VzjSba http://cheapggboots.com/ RurTqw XofHuh [url=http://parka2013.com/]canada goose parka[/url] CkmAup FsnRtu http://parka2013.com/ WtpVjp CmvLtr [url=http://cagoosehome.com/]canada goose outlet[/url] OnsEbw YfaYgb http://cagoosehome.com/ ByeBqr CvbPbf [url=http://jackets-2012.com/] Canada Goose Parka[/url] CtnRxf NnjTxb http://jackets-2012.com/ PajBiq QiaZet [url=http://gooseoutlet2013.com/]Canada Goose Outlet[/url] AqtGlm BfgMvf http://gooseoutlet2013.com/ KmxMes FduLjb [url=http://jacketsca.com/]canada goose jacket[/url] LeqZhu KkuGer http://jacketsca.com/ ZdrXom

    ReplyDelete
  75. JoeSyt [url=http://ukbootshopon.com/]cheap ugg shoes[/url] PkfYeg http://ukbootshopon.com/

    ReplyDelete
  76. zkqm [url=http://salecanadagooseoutlet.ca]Canada Goose Jacket[/url] pqyh http://salecanadagooseoutlet.ca xupc [url=http://mycanadagoose-canada.com]Canada Goose Outlet[/url] mpgd http://mycanadagoose-canada.com aeev [url=http://salecanadagoose-outlets.com]Canada Goose Outlet[/url] pemy http://salecanadagoose-outlets.com ghqd [url=http://salecanaadagoosejackets.ca]Canada Goose Sale[/url] rpis http://salecanaadagoosejackets.ca axcu

    ReplyDelete
  77. SieBug [url=http://ghdshairscarestore.com/]ghd[/url] XvzYay http://ghdshairscarestore.com/ AkhRxp [url=http://ghdshairscareshop.com/]ghd straighteners[/url] SkdAnq http://ghdshairscareshop.com/ YtfDyc [url=http://ghdshaircarestore.com/]ghd hair straighteners[/url] XdrWld http://ghdshaircarestore.com/ ExvGzm [url=http://ghdshaircareshop.com/]ghd straightener[/url] MjgJdj http://ghdshaircareshop.com/ DziVxp [url=http://ghdhairscarestore.com/]cheap ghd australia[/url] VveZwf http://ghdhairscarestore.com/ XtgZfw [url=http://ghdhairscaresshop.com/]ghd factory outlet[/url] GqoFzr http://ghdhairscaresshop.com/ TkyKvw [url=http://ghdhaircarestore.com/]ghd outlet[/url] YwlDqn http://ghdhaircarestore.com/ MdcNwu [url=http://ghdhaircaresstore.com/]ghd australia[/url] IrzFcp http://ghdhaircaresstore.com/ VleJhe [url=http://ghdhaircareshop.com/]ghd straighteners australia[/url] RjrVwm http://ghdhaircareshop.com/

    ReplyDelete
  78. jyjb [url=http://okbeatsbydrecheap.com]Beats By Dre[/url] xurf http://okbeatsbydrecheap.com uxyl wdta [url=http://beatsbydresalesok.com]Cheap Beats By Dre[/url] dyuq http://beatsbydresalesok.com sthv dlzj [url=http://okbeatsbydreus.com]Beats By Dre Headphones[/url] gjqc http://okbeatsbydreus.com ykdp vfij [url=http://salebeatsbydreoutlet.com]Beats By Dre Outlet[/url] lsio http://salebeatsbydreoutlet.com taki

    ReplyDelete
  79. UkmPgc [url=http://www.chloesweet.com/]クロエ アウトレット[/url] RlxFwn NbzVvn [url=http://www.chloesweet.com/]クロエ 財布 アウトレット[/url] WnrNof FqpCvb [url=http://www.chloesweet.com/]chloe 財布[/url] IqdMnj FnhPcy http://www.chloesweet.com/ TznFdi YbwWjz [url=http://gucci-nice.com/]グッチ アウトレット[/url] EbdQpcQhwIty [url=http://gucci-nice.com/]グッチ 財布[/url] FqyAmu SzpGif [url=http://gucci-nice.com/]gucci バッグ[/url] XguQzo SnkJeu http://gucci-nice.com DomYku PwbBkm [url=http://www.mymonclerhome.com/]モンクレール アウトレット[/url] PzmGlx XspDrd [url=http://www.mymonclerhome.com/]モンクレール アウトレット 2012[/url] ZqgUdj AgeWfc [url=http://www.mymonclerhome.com/]モンクレール 店舗[/url] EheKia UraCio http://www.mymonclerhome.com/ HdnRwf QwtHqv [url=http://www.bootsjpbest.com/]ugg ムートンブーツ[/url] DndKel NjvIwz [url=http://www.bootsjpbest.com/]ugg ブーツ[/url] UlmHsx JdeJpz [url=http://www.bootsjpbest.com/]ugg ブーツ 激安[/url] KyaRdb BfaAre http://www.bootsjpbest.com/ HngWjg

    ReplyDelete
  80. [url=http://thecasinospellen367.com ]live casino [/url]2:9. 12:10. the country beyond the river, and His hand fell to his side again. nederland online casino

    ReplyDelete
  81. All of the in the most right way payday conformation services we reviewed are erect, straightforward institutions that nowadays a true utilization to those who outcry a infrequent extra dollars to exhort it be means of a inexorable patch. In this placement, you'll call up articles with payday loans communication and boodle tips, as opulently as finish reviews and a side sooner than side contrasting to plagiarize you win an briefed verdict on which assistance is principled nigh reason of your short-term suffering needs. We create that the most adroit options for payday loans online.

    Fit those that neediness difficulty money between paydays, understanding the differences in payday loan lenders can dictate how comfortably and speedily you catch the coins you need. It reach-me-down to be that you had to work to a diplomate fingers on and on the back burner serve repayment for an approval on your payday loan, after submitting copies of pass muster stubs and bank statements. Nowadays, there is a difference in payday advance lenders because there are some that proffer prompt and advantageous online options. When you take benefit of online options, it is possible to lay hold of split-second approvals and should prefer to the money you need in a upset of a scattering hours, or less.


    Best Online Payday Loans and Cash Advance:
    cash til payday loan
    [url=http://paydayloanmoneyfast.com/loan/guaranteed-payday-loans-no-credit-check-ec]Guaranteed payday loans no credit check[/url]
    http://paydayloanmoneyfast.com/loan/legit-payday-loans-a5 - Legit payday loans

    ReplyDelete
  82. http://www.cafb29b24.org/docs/buyativan/#for-sale buy xanax ativan - kicking ativan addiction

    ReplyDelete
  83. Louis Vuitton Bags 356717 Gucci Bags online 604803 Hermes Outlet 634697 http://guccihandbagsforcheap.cabanova.com/

    ReplyDelete
  84. cheap christian louboutin 836825 Burberry Handbags 731546 cheap christian louboutin 917998 http://guccioutletonline.cabanova.com/

    ReplyDelete
  85. Gucci Handbags online 114912 Burberry Outlet 292812 Burberry Bags 817559 http://cheapburberrybagsoutlet.cabanova.com/

    ReplyDelete
  86. Chanel Outlet 788235 Burberry Outlet 581369 Louis Vuitton Handbags 605358 http://cheaplouboutinshoes.cabanova.com/

    ReplyDelete
  87. Burberry Bags clearance 518957 Cheap Gucci Bags 694503 Louis Vuitton Bags store 281293 http://discountlouisvuittonbags.cabanova.com/

    ReplyDelete
  88. christian louboutin outlet store 260526 Burberry Bags clearance 444859 Gucci Outlet 472325 http://hermesbirkinsale.cabanova.com/

    ReplyDelete
  89. christian louboutin outlet 35615 Gucci Outlet 905897 Chanel Handbags on sale 987519 http://chaneloutletonline.cabanova.com/

    ReplyDelete
  90. cheap christian louboutin shoes 170375 hermes purses 599671 Hermes Birkin 58752 http://thehermesbirkin.webs.com/

    ReplyDelete
  91. Gucci Handbags for cheap 199311 hermes bags 641792 Louis Vuitton Handbags outlet 471398 http://outletslouisvuitton.blinkweb.com/

    ReplyDelete
  92. Gucci Bags online 491132 Gucci Handbags for cheap 255376 hermes birkin handbags 824852 http://chaneloutletonline.cabanova.com/

    ReplyDelete
  93. Hip porn blog
    http://blowjobs.sexblog.pw/?post_maya
    sex anal film gold digger video girl how to please a man sexually black girls pictures forum

    ReplyDelete