Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

General Class Questions

Posted on 2007-09-29
8
Medium Priority
?
171 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
0
Comment
Question by:JRockFL
  • 3
  • 3
  • 2
8 Comments
 
LVL 22

Expert Comment

by:JimBrandley
ID: 19985995
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
0
 
LVL 7

Expert Comment

by:jax79sg
ID: 19986505
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.
0
 
LVL 8

Author Comment

by:JRockFL
ID: 19986712
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
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 7

Accepted Solution

by:
jax79sg earned 800 total points
ID: 19987246
So u might have noticed that there will be more than 1 instance of 'item', which consist of several parameters. So yes, use an Object to represent item.
0
 
LVL 8

Author Comment

by:JRockFL
ID: 19988695
Jim,
Your thoughts now that I provided a little more details?
0
 
LVL 22

Assisted Solution

by:JimBrandley
JimBrandley earned 1200 total points
ID: 19988704
Definately create a LineItem class. If you can have a number of them in any given invoice, you need a LineItemCollection (or List) class too.

I would guess that you do not want to recreate all your info from scratch every time you start the program. Have you thought of how and where you want to persist that data?

Jim
0
 
LVL 8

Author Comment

by:JRockFL
ID: 19989737
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?
0
 
LVL 22

Assisted Solution

by:JimBrandley
JimBrandley earned 1200 total points
ID: 19991377
Yes, I suspected you would want a DB behind it. I know of no rule-of-thumb, but there are some things to look for:
1. If you need a table in the DB, you likely need a class and a list or collection class to support it.
2. If you are doing something (non-business rules) that may need to be used in different places, create a class and put it in an assembly you might call your Framework; i.e. TCPListener/Client, EMail, Encryption, etc.
3. Keep your database access in a separete assembly. You might want to change providers someday.
4. Pass ANSI SQL from your business objects to your data layer.
5. Keep your business objects isolated from your UI layer. Then you can use the same business objects to support a fat-client app, as well as a web app. Note that you need to consider what is cached in memory, and the different behavior of the two.

Jim
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question