We help IT Professionals succeed at work.

General Class Questions

JRockFL
JRockFL asked
on
191 Views
Last Modified: 2010-04-15
Let's say I am creating a program to create invoices for clients
So far, I have these classes
contact (abstract)
company (inherits contact)
client (inherits contact)
invoice
invoice would have properties like invoice date, invoice number, invoice total etc.

My question is
Would the line items for the invoice need to be their own class? Why or what not?
The line items might be something like... be quantity, rate, description total
Comment
Watch Question

Top Expert 2007

Commented:
I would say no. They are just attributes (member variables) of that class. For example, quantity - it is simply a number no need to make a class out of that. Rate and description are the same.

I would expect rate to come from the client class. That way you can have differet rates for different clients, and set the rate in the invoice when you invoice that client.

Jim

Commented:
You might want to explain what your line items would be.
If an invoice has several line items, and each item may consist of more than one parameter(Eg: Name, type, date, cost...etc), then it would be wise to create a class called Item.

This would make things easier later on, when u start creating, adding and even removing line items.

Author

Commented:
Thanks for the replies. Yes, the rate could come from the client class.
Typically, I have several items on an invoice like...

Qty Desc Rate Total
2 Analysis of code changes 35 70
1 Code changes 35 35
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Jim,
Your thoughts now that I provided a little more details?
Top Expert 2007
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Thanks Jim, I could create a list of lineitem classes like you suggested.
I was thinking the entries would be stored in a database. Is that what you mean by your question, or something else?

Also, is there a "rule of thumb" of when to create classes?
Top Expert 2007
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.