Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6199551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:12:34+00:00 2026-05-24T04:12:34+00:00

I have been reading the book SQL Antipatterns: Avoiding the Pitfalls of Database Programming

  • 0

I have been reading the book “SQL Antipatterns: Avoiding the Pitfalls of Database Programming” especially around the magic beans anti pattern. In it shows a diagram decoupling activerecords by using a domain model and has example in PHP, but not Rails, it refers to this as HAS-A aggregation between domain models and views/controllers and HAS-A composition between domain models and activerecords (I presume this is UML speak).

In Rails it seems to be common place to make thin controllers fat models by using model methods, these methods may manipulate other associated models so that only one model can be used in any given controller. However, I wonder if there is a practice which includes total decoupling in Rails?

That is, to create a tableless model or other class to be used as a domain model acting as a layer between controllers and activerecord objects (which in turn are mapped to tables) so that controllers have better isolation and don’t need to know anything about the underlying database and its structure. It also gives the option to move away from CRUD methods which don’t explain the application requirements which they apply, another criticism in the book.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:12:35+00:00Added an answer on May 24, 2026 at 4:12 am

    My comments come from utilizing DDD together with ASP.NET MVC. The recommended approach to binding controllers to domain entities is through view models, which are DTOs purposed specifically toward binding to a specific view. The view model provides a much needed buffer between the binding mechanisms and the domain model. Often times a given view may be a composition of multiple domain entities or even reporting objects and therefore does not correspond directly with any given domain entity. Having the attributes required for a view declared in a view model makes those data requirements explicit and does not lead one into trying to adjust the domain model to fulfill the needs of a view.

    The downside of course is the potential emergence of a dual-class hierarchy, where you may have a view model which corresponds to many of your domain entities. In practice however, I find that maintaining the dual class hierarchy is much easier than worrying about the ramifications of changing a domain entity. Take a look at The Fallacy of ReUse.

    In an SOA system, the objects which view models ‘wrap’ may not be domain entities but instead DTOs representing those domain entities. This does not violate the structure of the view models, since they are themselves DTOs and don’t have behavioral aspects, only data. Take a look at this article which discusses the nature of data at application boundaries.

    To answer your question, I believe that creating a layer of view models would be advantageous for a Rails application, given all the caveats above. The view models would be populated with data from either an active record object or any other object containing data to be presented, and then when the user inputs data, the view model would update the active record object or domain model entity. Though I would avoid calling this view model layer a domain model.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've recently been reading Louis Davidson's book on Sql Server Database Design and found
I have been hearing and reading about Agile for years. I own a book
I have been doing a little reading on Flow Based Programming over the last
Some while ago, I've been reading through the book SQL and Relational Theory by
I'm quite new to php and have been reading Larry Ullman book to develop
I have been reading some recipes in the Perl Hacks book. Recipe #24 Query
Recently I have been reading The Art Of Unit Testing book by Roy Osherove
I have been reading a book and encountered a statement, that generics allow the
I have been reading Joseph Albahari's brilliant book on C# 4.0 and I came
I recently purchased the book Seven Languages in Seven Weeks and have been reading

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.