Solved

classes and objects

Posted on 2011-10-01
5
195 Views
Last Modified: 2012-05-12
Hi Everyone,

I am trying to bring in object oriented concept in one of my project, but i am not very clear about how to start with and to decide what kind of class to design and the elements.
i'll try to explain a sample project if anyone can help me in designing a class structure for that, later with that idea i can build a class structure for my ERP project.
My sample application is something like this
1. customer master (Name, address, city, state, country, phone, email, contact person)
2. supplier master (Name, address, city, state, country, phone, email, contact person)
3. product master (productcode, productname, brand, category, color)
4. purchase (pono, supplierid, productcode, qty, rate, amount, dateofpurchase)
4. sales (invoiceno, customercode, productcode, qty, rate, amount, dateofsale)
5. stock(productcode, date, qtyinstock)

all the above screens will have adding a new record, editing a existing record and deletion of records. Can anyone tell me how can i go for the class structure for the above sample project with all properties and elements.

Thanks in advance,
Rajeeva
0
Comment
Question by:rajeeva_nagaraj
5 Comments
 
LVL 7

Accepted Solution

by:
dimaj earned 125 total points
Comment Utility
From what I see, Customer Master and Supplier Master could be the same object (as they have identical fields). All other classes should be separate.
Then, you should have some sort of a Collection of class type (i.e. Customer, Supplier, etc)
When you add a new record, just add an item to the corresponding collection

Does this make sense?
0
 
LVL 29

Assisted Solution

by:anarki_jimbel
anarki_jimbel earned 250 total points
Comment Utility
Hmmm, OK, I'd say this structure is quite simplified :)

Anyway. A lot depends on specific requirements. Probably, dimaj is right and you may have one class for Customer  and Supplier. You may add a flag telling is it one or another.

I prefer when DB ids are used for relation between tabled. Therefore I'd replace productcode
 purchase (pono, supplierid, productid, qty, rate, amount, dateofpurchase). In the class you will have a reference to a product object, of course.

You will also need some main class, e.g. Store, which has collections of products, handles collections of customer and supplies, etc.
0
 
LVL 29

Assisted Solution

by:anarki_jimbel
anarki_jimbel earned 250 total points
Comment Utility
Also, if we talk about a project structure.

If you are going to store your objects in a database you will need a database layer. In other words you will need a class (or classes) that are responsible for reading /writing from/to database.

In other words, you will have :
presentation layer
business layer
DB layer
0
 
LVL 8

Assisted Solution

by:jagrut_patel
jagrut_patel earned 125 total points
Comment Utility
abstract class Contact
{
  //Properties for Name, address, city, state, country, phone, email, contact person
}

class Customer: Contact
{
}

class Supplier: Contact
{
}

class Product
{
   //Properties for productcode, productname, brand, category, color
}

class ProductTransacted
{
   //Property of type Product
   //Properties for qty, rate, amount
}

class Purchase
{
   //Properties for pono, dateofpurchase
   //Property of type supplier
   //Property of type List<ProductTransacted>  
}

class Sales
{
   //Properties for invoiceno, dateofsale
   //Property of type Customer
   //Property of type List<ProductTransacted>
}

class ProductStock
{
   //Properties for date, qtyinstock
   //Property of type Product
}

class Stock
{
   //Property of type List<ProductStock>
}
0
 

Author Closing Comment

by:rajeeva_nagaraj
Comment Utility
Thanks a lot
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now