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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:40:49+00:00 2026-05-20T16:40:49+00:00

I have a design problem that I can’t figure out. Here’s what I’ve got:

  • 0

I have a design problem that I can’t figure out. Here’s what I’ve got:

In general, I have two general types of objects Strikes and Options. These have been abstracted into two interfaces IStrike and IOption.

Let’s say that IOption has the following fields, in reality there are about 10 times as many, but we can use the following three to illustrate the problem.

interface IOption
{
   double Bid{get;set;}
   double Ask{get;set;}
   double ImpliedVol{get;set;}
}


interface IStrike
{
   IOption Call{get;set;}
   IOption Put{get;set;}
}

Now, that’s all well and good, but let’s say I’ve got the following method for performing some “math” on the IOption implied vol

public double SquareImpliedVol(IOption opt)
{
   return Math.Pow(opt.ImpliedVol,2);
}

Again, not a problem, but when I’m writing some mock objects for my tests, it’s not clear to me if I need to implement Bid and Ask. I don’t, but I wouldn’t know that unless I knew the guts inside SquareImpliedVol, which means I’m writing tests against the code, which is bad.

So to fix this, I could create another interface IOptionImpliedVol that just contains the ImpliedVol property, and then have IOption inherit from IOptionImpliedVol like so

interface IOption : IOptionImpliedVol
{
   double Bid{get;set;}
   double Ask{get;set;}
}

And then we can switch up SquareImpliedVol

public double SquareImpliedVol(IOptionImpliedVol opt)
{
   return Math.Pow(opt.ImpliedVol,2);
}

And we’re great. I can write mock objects and everything is sweet. Except….I want to write a method that is going to operate on a List, but the only properties I need out of IStrike are the Call.ImpliedVol and Put.ImpliedVol. I want to create something like

interface IStrikeImpliedVol
{
   IOptionImpliedVol Call;
   IOptionImpliedVol Put;
}

and then I could also have

interface IStrike : IStrikeImpliedVol
{
   IOption Call;
   IOption Put;
}

Except that isn’t legal. I feel like there has to be some kind of design pattern that I could to work this out, but I’m stuck in some kind of web of composition and inheritance.

  • 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-20T16:40:50+00:00Added an answer on May 20, 2026 at 4:40 pm

    I think you’re initial design with two interfaces was correct. You’re saying that you have to know when to set Bid/Ask and when not to set it in your tests and that bothers you.

    Let’s try to look at it from other point. You’re writing a test for some function (let’s say it is your SquareImpliedVol again). You know that correctly implemented this function should care only about ImpliedVol property, but not about Bid/Ask so you can leave those blank. If function will fail with unset Bid/Ask then your unit-test found an issue – be happy. Of course it differs if empty Bid/Ask is incorrect state of Option object, but that doesn’t seem to be an issue in your case.

    In other words I would say you’re writing a test against your knowledge on how particular method should work and there is nothing wrong in the fact that this knowledge correlates with code already written in that function.

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

Sidebar

Related Questions

I have simple LINQ problem that I can't figure out. I have a table
This is a design problem that I am trying to figure out. I will
Suppose I have a design like this: Object GUI has two objects: object aManager
I am stuck with a design problem that I hope you guys can help
I have a problem that can be simplified as follows: I have a particular
I have a class design problem that could simplified with this example: // foo.h
I got the following problem. I have a design similar to this jsfiddle: http://jsfiddle.net/k3EUx/
I'm building a database and have run into a problem that I can't seem
I have some sort of a design problem with my Django AJAX application. I
I am trying to design an mail system. I have stuttered on the problem

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.