classes and objects

Posted on 2011-10-01
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,
Question by:rajeeva_nagaraj
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

dimaj earned 125 total points
ID: 36896861
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?
LVL 30

Assisted Solution

anarki_jimbel earned 250 total points
ID: 36900930
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.
LVL 30

Assisted Solution

anarki_jimbel earned 250 total points
ID: 36901005
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

Assisted Solution

jagrut_patel earned 125 total points
ID: 36902761
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>

Author Closing Comment

ID: 37093441
Thanks a lot

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

630 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