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

  • Home
  • SEARCH
  • 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 229257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:45:02+00:00 2026-05-11T19:45:02+00:00

I have many math types like Point3, and I am running into the dilemma

  • 0

I have many math types like Point3, and I am running into the dilemma of implementing operators, instance and static methods for arithmetic.

So say the type is Point3. Where a, b, c is a Point3, I sure wanna be able to say:

c = a + b;

But should I also implement:

c = Point3.Add (a, b);

And this:

c = a.Add (b);

To me #3 is useless and less readable than #1. And #2 seems like pointless unless you have an interface for Add, Subtract, Multiply, Divide, etc.

What do you recommend? Is there any problem or drawback with just having the operators (+, -, *, /)? Would this impede the generics arithmetic (I know it doesn’t support it directly, but maybe having static methods would be useful in a workaround)?

Would a guidelines for this matter whether it’s a class or a struct?

EDIT: Also for #3, I forgot to mention that this is for an immutable type, so returns a new Point3, instead of changing a.

  • 1 1 Answer
  • 3 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-11T19:45:03+00:00Added an answer on May 11, 2026 at 7:45 pm

    In general, I think Microsoft seems to have kind of done A+B in most of their classes similar to this.

    For samples, see the entire System.Windows.Media.Media3D namespace, as well as the XNA math classes. Both have point/vector/quaternion/matrices/etc, and use Class.Operator(a,b), and occasionally do c = a + b;

    Personally, I would do the first where it makes sense and is clear, and always do the second option. I usually implement the first using the second option (the operator is implemented using the static method).

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

Sidebar

Related Questions

I have seen many places using Math.floor() and Math.random() like below $('a.random-color').hover(function() { //mouseover
I have many MySQL statements that are running under MySQL 4, but not MySQL
For my project, I have many objects split into 10 classes. Each of the
I'm creating a software for math problems. As you know, there are many types
There have been many threads started over the confusion in the way that Math.Round
I have many different NSArray 's stored in .dat files, in the Documents folder
I have many PowerPoint presentations that I need to be able to add to
I have many many files in a folder, and I want to process them
I have many directories with files in them. I want to create a comma
We have many projects with several files inside each. Files can be checked 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.