• Post Reply Bookmark Topic Watch Topic
  • New Topic

Should I make all the classes?  RSS feed

 
Maki Jav
Ranch Hand
Posts: 470
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am faced with this dilemma. There are 43 types of expenses of a hotel eg
Milk and butter
green grocery
cloth
and so on...

The accounts guys say that they may categorise more. Do I need to make a single class which have the attributes (field) or should I define class for each exepnse type?

What is your experience of such a situation?

Thanx in advance,

Maki Jav
 
Maximilian Xavier Stocker
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you mean to create a class with 43 atrributes then I don't like either of your plans.

It's hard to say exactly what your model should be because I am not sure what you are looking to accomplish exactly, however, the idea is to create a model the encompasses the information and is flexible enough not to rely on their only being x types.

Here is an idea.

 
Scott Selikoff
author
Bartender
Posts: 4093
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you should never make instance-specific classes unless you have an extremely good business reason to do so. Expenses should able to be cast into a single expense class with some exceptions that you may want 2-3 types of groupings that can likely be handled by sub-inheritence.

For example, you might have an Automobile class and an SUV sub-class. But, you wouldnt want a class for every possible SUV. Maintaining such a beast would be very difficult (unless you were using good code generation).
 
Maki Jav
Ranch Hand
Posts: 470
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am thankful for the code from Maixmilian. Yes, you are right scott...
I can give you an example of two expenses:
(These are their categorisations)

1) Plant and Nursery Purchase
(fields) date, vendor name, item, Qty, Amount, Paid Amount (meaning the amount they
have paid to the vendor at the time picking up or getting that item. So the amount yet
to pay is the difference of amount and paid amount ), Balance Amount (but I don't need that
at saving time, right? I can use query for that a display time.)

2) Chicken Purchase
(fields) date, vendor name, item, rate per kg,weight, Amount, Paid Amount , Balance Amount

and yes Maixmilian they have staff related expenses and these are:

Staff Expense (subtract from salary, according to their requirement)
(fields) date,name, Amount, house rent

Staff Food ( ie the amount they spend on meals for their staff )
(fields) date, Amount

Service Charges ( ie the amount they give daily to their staff for work )
(fields) date, Amount

Staff Salary Sheet
Their staff is either on 15 days wages or on monthly wages. I will have to design it by myself.


Except these staff expenses and utility bills, all expenses have similar fields with some variance.

I also want advice on Lahore Expense which has both qty and weight as its fields(attributes)

Thanx,

Maki Jav
[ February 05, 2006: Message edited by: Maki Jav ]
 
Maki Jav
Ranch Hand
Posts: 470
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again,


I have gone through the all the expense accounts. The attributes a single class will need to handle all type of expenses are:

date, vendor name, item, rate per(kg/liter/meter/bottle),qty or weight or liters or meters or bottles, amount, paid amount, date paid (added by me, for each payment)


This is analysis of various accounts (33 accounts and not 43. The accounts guy was not so correct!)

The common attributes are date, vendor name, amount, paid amount, date paid

Eleven have quantity

Seven has rate per kg and weight

Five has amount only no measure of any kind. (in case of Electric & gas bills and Staff food even vendor name is not required)

Five have both qty and weight

One has both qty and liter
One has rate per bottle and bottles
One has rate per liter and liters
One has rate per meter and meters

One entirely different account is Staff salary sheet.

This comes to 33 type of expenses.


I want to follow Object Oriented Paradigm correctly here. As I am going to hand code the
application so I want to save myself any trouble that rise may later due to wrong design or procedural mindset.


Thanx,

Maki Jav
 
pascal betz
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello

i am not sure i got you right ? do you plan on making 33 expense classes now ?

i count 6 groups of expenses. you do not need a single expense class for all the different expenses.

how about you create a hierarchy of expense classes (base class contains all the attributes you determined to be common) and let them have an additional type/name attribute (as in Maximillians example) for the exact expense type ?


p
 
Maki Jav
Ranch Hand
Posts: 470
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I just noticed that there are six types!

I need more on this and I may return to ask for more help from you guys...

Thanx,

Maki Jav
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!