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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:00:43+00:00 2026-05-25T16:00:43+00:00

I’m writing an expense tracking program. At the moment I have three class Lineitem

  • 0

I’m writing an expense tracking program. At the moment I have three class

Lineitem stores the attributes for individual transactions and has methods format a transaction for output (payee, amount date), etc. Each lineitem is one transaction.

Account is a collection of lineitems and has methods to add a lineitem, list its lineitems, determine the value of all of its lineitems, etc.

Journal is a collection of accounts and has methods to add a new account, list its accounts, format a list of accounts, etc.

1) Does this seem a sensible way of organizing classes?

2) I’m adding a method to only look at transactions between a run-time specified start_date and end_date. The best way might be to store start_date and end_date somewhere, then modify Account to change some methods to receive start_date and end_date parameters and then examine lineitem dates when totaling or listing its linetimes. Are there other approaches I should be considering?

EDIT: method in accounts to implement the date check. self.lineitems is a list of lineitems. start_date and end_date are set and runtime and may not be set or may be set more than once.

def get_lineitems(self, start_date, end_date):
        if start_date and end_date:
            for lineitem in self.lineitems:
                if start_date <= lineitem.date <= end_date:
                    yield lineitem
        else:
            for lineitem in self.lineitems:
                yield lineitem
  • 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-25T16:00:44+00:00Added an answer on May 25, 2026 at 4:00 pm

    1) Does this seem a sensible way of organizing classes?

    Yes, it seems so. Remember that LineItem “ispartof” Account, and Account itself is part of Journal. There are no inheritance relationships around, you just have a collection of Accounts in Journal, and a collection of LineItem‘s in Account.

    The only issue I see is about naming. You say that the class is a LineItem, and later that a LineItem is a Transaction. Maybe you should give it a moment of thought. Why didn’t you name it Transaction? Would you need yo clarify it if the class was named Transaction?

    Anyway, the needs of your application will change with time (will grow with time). Probably, you need to worry more about how will you adapt it to the future needs, instead of now, in which the requirements are clear. Your second question has to do with this.

    2) I’m adding a method to only look at transactions between a
    run-time specified start_date and end_date. The best way might be to
    store start_date and end_date somewhere, then modify Account to change
    some methods to receive start_date and end_date parameters and then
    examine lineitem dates when totaling or listing its linetimes. Are
    there other approaches I should be considering?

    Pay attention to the fact that you have used the word Transaction again. You must store the date attribute in the LineItem‘s objects. I think that’s a sensible approach. If you don’t want to change the lookUp methods constantly, in order to track of all the possible attributes you can search for, consider creating an Options class in which you can store the search parameters, storing all the attributes you can need now and in the future.

    Hope this helps.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

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.