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 7168807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:51:23+00:00 2026-05-28T14:51:23+00:00

The application that I help support has no real business objects to speak of,

  • 0

The application that I help support has no real business objects to speak of, despite it being a sizable, ostensibly n-tiered project. What our team refers to as “business objects” are really nothing more than auto-generated wrappers around our database rows, and all the actual business logic is mixed in with the web UI code. For new functionality, I’d really like to see our team start working with/coding objects that truly represent the business entities’ data and behavior, and keep business logic out of the UI as much as possible. There’s some conflict, however, about how the relationships should be modeled.

To vastly oversimplify the domain for purposes here, say you have Persons and Tasks. Each Task has a Person assigned to it.

public class Person
{
    public int ID { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; } 
}

How should Task be modeled?

public class Task
{
    public int ID { get; set; }
    public string Title { get; set; }
    public int AssignedPersonID { get; set; } 
}

OR

public class Task
{
    public int ID { get; set; }
    public string Title { get; set; }
    public Person AssignedPerson { get; set; } 
}

Those that spend more time coding the web UI want the earlier, in which Person is referenced by his ID. They argue that when, say, a different Person is assigned to a Task, it’s better to just change task.AssignedPersonID (the new ID being easily available from their dropdown list on the UI) and write to the database. To me this is no different from the approach we’re doing now; it still reflects a database row more than the actual business model. They argue that it’s more code and slower to have to take that PersonID, instantiate the corresponding Person instance, and then set task.AssignedPerson, when the end result — that the AssignedPersonID column in the Task table is updated — is exactly the same.

From a object-oriented perspective, what is the preferred approach here?

  • 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-28T14:51:24+00:00Added an answer on May 28, 2026 at 2:51 pm

    I’d prefer having an actual reference to the object instead of just the ID.

    If you have just the ID, and you would frequently be using that to look up the Person to do stuff with it, you’re in bad shape because those frequent lookups will take time. If on the other hand, you have the Person object, and need the ID instead, it’s as simple as calling Person.ID.

    There are some possible reasons for going with the ID route, and Wes hits on several of them that I wasn’t even thinking about (performance issues, in particular), and also the fact that it lines up with your database structure better, and (depending on how your code is currently structured) it may require fewer code changes to do this, but I don’t think either of those are that compelling of reasons to go with it.

    So while it depends on the specifics, I think most OO programmers would prefer having the actual object reference.

    By the way, the title uses the word “Parent” and “Child” which (you probably already know) have specific meanings in the context of inheritance in object-oriented programming. This doesn’t look like a parent-child relationship to me, but rather, a “this-uses-that” kind of relationship. Your question is perfectly valid, but the title/header might be a little misleading, and you might get better answers with slightly different terminology.

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

Sidebar

Related Questions

I am trying to help a small business that has an application that could
An application that I support has recently begun experiencing extended periods of time required
I'm thinking about writing a small application that will help me mass rename files.
cowboy coder needs some help from SO-veterans: I have a given application that uses
I'm trying to create a Help/About screen for my application, but I've discovered that,
An application that has been working well for months has stopped picking up the
I'm trying to test an application that has on the Manifest: <uses-feature android:name=android.hardware.telephony android:required=false
I'm sure someone can explain this. we have an application that has been in
I have an application that has been working with session variables no problem. I
I have a web application that I'm working on that has always been in

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.