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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:16:01+00:00 2026-06-06T18:16:01+00:00

In certain types of code (e.g. simulation/ games/ optimization), many physical quantities/properties are stored,

  • 0

In certain types of code (e.g. simulation/ games/ optimization), many physical quantities/properties are stored, manipulated, and exposed for objects (position, velocity, distance, area, volume, time, time-differences). In these types of code, all these quantities are typically represented by floating point numbers, i.e. doubles in c#.

This allows you to add times to distances, area’s to volumes, times to times, and positions to positions.

But you never want to do this. You will only want to add time-differences to times, distances to other distances or positions, and multiply areas with distances. Still, errors are easily made, especially when working on code by someone else.

There are many options to mitigate this danger. You could define custom classes representing various physical quantities, and subsequently forbidding certain types of interactions programmatically. Or you adhere to strict naming conventions (e.g. delay_timedifference). Which of those two options is best under what (if any) circumstances? How to implement the first option? How to do the naming for the second option?

  • 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-06-06T18:16:02+00:00Added an answer on June 6, 2026 at 6:16 pm

    Often, the second option is used, but more for convenience. Naming becomes a matter of making it obvious what you’re dealing with, ie: naming properties Area and Volume, but even then, there is a unit issue.

    You can handle the first case by making an entire set of custom classes (or immutable struct types) to handle each of the different combinations, which can work well, but can make the code quite a bit more cumbersome to work with. The DateTime struct in the framework is a good example – at its core, it’s basically just a long integer value, but it’s wrapped into a struct to prevent its usage as anything but a moment in time.

    Note that other languages have options for this – for example, F# allows Units to be handled at a language level, but this isn’t supported in any way in C#.

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

Sidebar

Related Questions

When I write tests for certain types of objects, such as UI elements like
I would like to conditionally compile certain parts of code based on Compiler Type
For certain types of sql queries, an auxiliary table of numbers can be very
I'm unable to reference certain types in a separate assembly. The strange thing is
I'd like to setup one instance of MySQL to flat-out reject certain types of
I'm working on an embedded systems which provides an interface with certain types. The
I am trying to apply global application styles to certain control types, however adding
Does anyone know of a good way to automatically run certain file types through
What is the correct jQuery syntax to only select certain file types? e.g. $(#fragment-1
I have a bunch of overloaded functions that operate on certain data types such

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.