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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:11:52+00:00 2026-05-13T07:11:52+00:00

I am helping my friend develop a Unit Converter. He asked me if I

  • 0

I am helping my friend develop a Unit Converter. He asked me if I could help split up the work. So I am making a .dll called Unit. Unit is supposed to handle the conversions. I was brainstorm on how to do this and I came up with an idea to put give each section an enum (like enum Angle[Degrees, Radians, Gradians], enum Area[Square meters, square miles, …], enum Energy[Newtons, Pascals, Joules, …], …). Then a main abstract class Unit with all the Convert methods
NOTE:

I am NOT asking you to code the .dll, I just want your opinion on HOW to make the .dll.

  • 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-13T07:11:52+00:00Added an answer on May 13, 2026 at 7:11 am

    Something to watch for when you have a many-to-many relationship like this (every value wants to be able to be converted to every other kind of value in its class) is that you’ll end up writing a ton of methods if you use the brute force method of writing a conversion function for each possibility.

    This is OK if you need it to work as fast as possible and want to make sure your error is controlled, but you suffer for code maintainability.

    Something I’ve done in the past for converting between many units was to establish a ‘base’ unit that everything could convert to and write functions to convert to/from that. This lets you define an interface something like:

    interface IUnitConverter<T, U> {
     T ToBaseUnit();
     void FromBaseUnit(T BaseValue);
     U MyValue {get;}
    }
    

    And specialize that for certain types of conversion:

    class RadiansConverter : IUnitConverter<DegreesConverter, float> {
     float radians = 0;
    
     DegreesConverter ToBaseUnit() {...}
     void FromBaseUnit(DegreesConverter BaseValue) {...}
     float MyValue {get {return radians;}}
    }
    

    Edit: Usage:

    // assume we have a constructor that sets the private value
    float degrees = new RadiansConverter(Math.PI).ToBaseUnit().MyValue;
    float radians = new RadiansConverter().FromBaseUnit(degrees).MyValue;
    

    This can be somewhat heavyweight and you have to watch for propagation of error hitting you for two conversions instead of one. It has come in handy when I needed to do complex GIS conversions that needed state stored as well, but it might not be what you’re looking for exactly.

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

Sidebar

Ask A Question

Stats

  • Questions 252k
  • Answers 252k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Have you tried rebuilding permissions? http://yourdomain.com/?q=admin/content/node-settings/rebuild Or running update.php? Either… May 13, 2026 at 9:41 am
  • Editorial Team
    Editorial Team added an answer As explained by Rob Mensching: The KeyPath for a Component… May 13, 2026 at 9:41 am
  • Editorial Team
    Editorial Team added an answer I would suggest you use multiple view controllers when trying… May 13, 2026 at 9:41 am

Related Questions

I'm helping my sister convert a website that somebody did for her in flash
I am helping s.o. out over mail to start with c#, and I would
I'm not familiar with ASP, but am helping someone out with their website as
I am trying to write a PHP program to automatically created backups of MySQL
How do I get per thread based memory consumption of a process in Linux?

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.