Link to home
Start Free TrialLog in
Avatar of JRockFL
JRockFLFlag for United States of America

asked on

General Class Questions

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
Avatar of JimBrandley
JimBrandley
Flag of United States of America image

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
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.
Avatar of JRockFL

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Jax Tan
Jax Tan
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JRockFL

ASKER

Jim,
Your thoughts now that I provided a little more details?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JRockFL

ASKER

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?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial