Upgrade to Pro — share decks privately, control downloads, hide ads and more …

My domain is mine and I don't share it

My domain is mine and I don't share it

What's business logic exactly? What's a domain model? Which truths hide behind "patterns" like fat model - skinny controller? How does the use of a framework like Rails influence how we build a domain model?

This talk will approach the problems that we have to face when we put a tool in the core of our system and we will discuss whether the price we pay for the rails is too high.

This talk was given on Madrid.rb users group.

Javier Acero

May 30, 2013
Tweet

More Decks by Javier Acero

Other Decks in Programming

Transcript

  1. 1

  2. 3

  3. 2

  4. ARE THESE 3 LAYERS YOUR APP? ARE THEY EQUALLY IMPORTANT?

    DO THEY OBEY THE SAME RULES? DO THEY CHANGE AT THE SAME PACE?
  5. ARE THESE 3 LAYERS YOUR APP? ARE THEY EQUALLY IMPORTANT?

    DO THEY OBEY THE SAME RULES? DO THEY CHANGE AT THE SAME PACE?
  6. ARE THESE 3 LAYERS YOUR APP? ARE THEY EQUALLY IMPORTANT?

    DO WE BUILD THEM THE SAME WAY? DO THEY CHANGE AT THE SAME PACE?
  7. ARE THESE 3 LAYERS YOUR APP? ARE THEY EQUALLY IMPORTANT?

    DO WE BUILD THEM THE SAME WAY? DO THEY CHANGE AT THE SAME PACE?
  8. Business logic is a non-technical term used to describe the

    functional algorithms that handle information exchange between a database and a user interface - WIKIPEDIA
  9. Business logic is a non-technical term used to describe the

    functional algorithms that handle information exchange between a database and a user interface - WIKIPEDIA
  10. Business logic is the work the application needs to do

    for the domain it’s working with - Martin Fowler - Patterns of Enterprise Application Architecture
  11. simple easy to understand works great with simple datasources makes

    transaction boundaries visible 00 {ADVANTAGES
  12. DIS 00 {duplicated code procedural code duplicated code procedural code

    duplicated code procedural code duplicated code procedural code ADVANTAGES
  13. 00 {modeling limited by and tied to the data model

    mechanisms basic to oop like polymorphism are not available DISADVANTAGES
  14. A software model based specifically in the domain of the

    business you are working with. - Vaughn Vernon - Implementing Domain Driven Design
  15. It’s usually built as an object model, where objects have

    both data and behaviour with accurate business meaning. - Vaughn Vernon - Implementing Domain Driven Design
  16. The Object Oriented way of implementing business logic. - Martin

    Fowler - Patterns of Enterprise Application Architecture
  17. - Martin Fowler - Patterns of Enterprise Application Architecture Using

    a Domain Model as opposed to a Transaction Script is the essence of the paradigm shift to Object Oriented programming.
  18. the hardest to comprehend data sources get more complex overhead

    for simple business logic DISADVANTAGES 00 {
  19. SAME COMPLEXITY SAME L O C COUNT or even bigger!

    . . . http://www.slideshare.net/pcalcado/from-a-monolithic-ruby-on-rails-app-to-the-jvm
  20. Another argument against ActiveRecord is the fact that it couples

    the object design to the database design. This makes difficult to refactor either design as the project goes forward. - Martin Fowler - Patterns of Enterprise Application Architecture
  21. Active Record is a good choice for business logic that

    is not too complex, such as creates, reads updates and deletes - Martin Fowler - Patterns of Enterprise Application Architecture
  22. http://michaelfeathers.typepad.com/michael_feathers_blog/2013/01/the-framework-superclass-anti-pattern.html When you inherit code from a framework, it is

    mixed with your logic. Often you are obliged to run that inherited code with the code that you really want to test, along with all of its dependencies, start up time... - Michael Feathers - On his blog on January 2013
  23. http://michaelfeathers.typepad.com/michael_feathers_blog/2013/01/the-framework-superclass-anti-pattern.html If you've written logic important to your domain, there

    is nothing preventing you from being able to use that logic with other technology - nothing except coupling. - Michael Feathers - On his blog on January 2013
  24. http://www.threeriversinstitute.org/blog/?p=338 In a connected system, elements are highly available to

    each other. Adding the first feature to a connected system is cheap. All the resources you need are available. However, the cost of all those connections is that subsequent features are very likely to interact with previous features, driving up the cost of development over time.
  25. http://www.threeriversinstitute.org/blog/?p=338 In a modular design connections are deliberately kept to

    a minimum. The cost for the first feature is likely to be higher than in the connected system, because you need to find the necessary resources and bring them together, possibly re-modularizing in the process. Features are much less likely to interact in a modular system, though, leading to a steady stream of features at relatively constant cost.
  26. - Not about anemic domain models - Nothing to do

    with J2EE - Also on @DHH’s list (ironically) - The rails way’s antithesis (IMHO) - Not about data centric approaches - Not on @DHH’s list (but it should)
  27. Ruby Midwest 2011 Logo: http://cdn.confreaks.com/system/events/logos/49/rmw-logo-mid-original.png?1323836412 Uncle Bob picture: http://www.flickr.com/photos/koss/3250213001/ Home

    Alone Picture: http://www.multiplemayhemmamma.com/wp-content/uploads/2013/03/home-alone.jpg Terrified Adult Picture: http://sidoxia.files.wordpress.com/2011/02/scared.jpg Terrified Baby Picture: http://2.bp.blogspot.com/_0p-Jm7tsSa8/TNDUaU-HdHI/AAAAAAAAFfE/9ubR079H9UE/s1600/DSC_0425.JPG Spaghetti Picture: http://tonispilsburycom.wpengine.netdna-cdn.com/wp-content/uploads/2012/01/Mira10.jpg Dr. House Picture: http://4.bp.blogspot.com/-_EO0zOLq8YU/T8OUH5Zl5rI/AAAAAAAABLk/O_LYbtJuS1w/s1600/House+facepalm.jpg Martin Fowler Picture: http://www.flickr.com/photos/pragdave/173640462/ Vaughn Vernon Picture: https://si0.twimg.com/profile_images/1670662520/VaughnVernon_2011_2.JPG Fat & Skinny Silhouette: http://2.bp.blogspot.com/-C_B_KLHbBJ4/TiMWn5L5xUI/AAAAAAAAEDs/lqwnKydRPiQ/s1600/transition-fat_to_thin1.jpg Bear Facepalm Picture: http://blog.littlebigfund.org/wp-content/uploads/2013/04/facepalm-wallpaper.jpg Lion Facepalm Picture: http://wolfallen.w.o.pic.centerblog.net/nqgyh2l0.jpg
  28. Table Icon: http://fortawesome.github.io/Font-Awesome/icon/table/ Robot: http://icons.iconarchive.com/icons/martin-berube/character/256/Robot-icon.png Monster: http://icons.iconarchive.com/icons/martin-berube/character/256/Monster-icon.png Database Icon: http://iconmonstr.com/database-icon/

    Buried In Paper Picture: http://everythingchangesbook.com/wp-content/uploads/2009/03/paper-pile.jpg Cave Picture: http://imagenes.viajeros.com/fotos/l/ll/lleimrlh-1259512525.jpg Globe Icon: http://iconmonstr.com/globe-4-icon/ Refresh Icon: http://iconmonstr.com/refresh-2-icon/ J.B. Rainsberger Avatar: http://www.devtraining.ee/sites/default/files/trainers/rainsberger_0.jpg Michael Feathers Avatar: http://i985.photobucket.com/albums/ae335/edepodesta/MichaelFeathersNew.jpg Kent Beck Picture: http://www.flickr.com/photos/26420411@N02/3062930943/ Tool Icon: http://fortawesome.github.io/Font-Awesome/icon/wrench/