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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:33:47+00:00 2026-05-16T21:33:47+00:00

Where do you draw the line when moving functions which operate on data into

  • 0

Where do you draw the line when moving functions which operate on data into the class which contains that data? For example, imagine you have a simple class which stores a description of the weather, with variables for temperature, humidity, wind speed and direction, and the time at which the measurement was taken. Now imagine you have an object of this class and you want to transmit it to someone else – another process, another machine, whatever. Do you put the code to transmit the object into the object itself – for example, by adding a Send(destination-type) method to the simple data class? Or do you keep this kind of feature in separate classes that can send and receive anything over the medium – whether it’s networking, file i/o, interprocess comms, or anything similar?

My gut instinct is to keep my data classes simple and wrap them up when I want to transmit them – in classes which serialise them and present the sender and receiver classes with a simple interface they understand. The alternative seems to be to put everything including the kitchen sink into the simple data classes – every function which might ever operate on that data, however indirectly. In short, network error handling code doesn’t seem to me to belong in a simple data class.

This seems obvious to me, but I keep seeing developers put Send() methods on their classes. They even tell message classes to Send() themselves, which seems highly counterintuitive to me; if I write a letter on a piece of paper, I don’t tell the paper to send itself. I wrap the letter in an envelope and hand it to the postman, because he has a van and a map. What do people think?

  • 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-16T21:33:48+00:00Added an answer on May 16, 2026 at 9:33 pm

    There’s logic to do with the payload item itself: what’s the wind speed now?

    There’s logic to do with interpreting that data: can we dock this ship now?

    There’s logic to do with deciding to send the payload somewhere: oh here’s a new weather value, someobody over there cares.

    Then the actual network stuff.

    The payload probably needs to be able to serialize and deserialise itself. I don’t see that any of the rest is the payload’s concern. There must be a better place for Send(). Not least because you might choose to send several payload objects at once, and they can’t all send each other.

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

Sidebar

Related Questions

i want to draw line, i have two textfiled in which i enter some
I Have a bresenham algorithm which I wrote it in class Line I Can
i want to draw a line on a bmp image which is pass into
I have integrate draw line in my application i have not used OpenGL or
I want to Draw multiple line Graph with each line have different color and
I want to draw a line in Crystal report. I can do that from
I have a simple Javascript program that displays a small rectangle in a canvas.
There is a simple MSDN example about WriteableBitmap. It shows how to draw a
I have problem to draw line on scaled and transformed image on canvas, well
So I am writing a program which is moving circle through a line, I

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.