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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:14:38+00:00 2026-06-08T06:14:38+00:00

I am trying to create a simple program in Ruby to track the price

  • 0

I am trying to create a simple program in Ruby to track the price movements of stocks, but I’m not entirely sure of how it should be designed.

Basically, I’m thinking of a class Stock, with all the attributes such as name, desc, etc. However, I’m not sure of how the price attribute would work. Because for each stock, I also want to track the history of prices and plot them on a graph. So, my question is, should I create another class, Prices and associate it with Stock? or is there a better way?

I’m a newbie at OOD and would love some explanation, helpful links or other advice. Thank you in advance.

  • 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-08T06:14:40+00:00Added an answer on June 8, 2026 at 6:14 am

    Some of this will depend on your choice of DB: OO, document, or relational. If you’re using the typical relational DB, then you would have a table for prices that represents the one-to-many relationship between prices and stock.

    It seems like you should have a separate class for price, because I’m assuming you’ll want to track price with time. I know this isn’t Ruby, but your Stock class could look something like this:

    public class Stock
    {
      public int Id { get; set; }
      public string Name { get; set; }
      public string Description { get; set; }
      public List<Price> PriceHistory { get; set; }
    }
    

    And then Price:

    public class Price
    {
      public int StockId { get; set; }
      public DateTime PriceDate { get; set; }
      public decimal Price { get; set; }
    }
    

    Note: You’ll need to ignore the fact that the IDs are public, and therefore able to be changed by outside classes. However, this code is presented this way for simplicity.

    Hope that helps.

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

Sidebar

Related Questions

I am trying to create a program that will do some simple calculations, but
Im trying to create a simple input box with form validation, but im not
I'm trying to create a very simple Hello, world program in RoR, but when
I'm trying to create a (very) simple Win32 GUI program, but for some reason
I am trying to create a simple program using Gstreamer to take the input
I have been trying to create a simple program with Python which uses OpenCV
I'm trying to get a simple winsock program working, so I create my socket
Im trying to create a simple pan and zoom app using silverlight 4, but
I'm trying to create a simple program that tells you your lucky number according
I am trying to create a simple translation program for iPhone and have drawn

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.