Click here to Skip to main content
16,004,540 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
i am developing a project in c# (mvc4).I am undergoing a learning process, the following is my scenario.

1. There are a list of Companies
2. Each Company has some common features like type of products,turnover of the company,no of staffs

Which is the best ideas to use in C#.Shall i use Interface for declaring
products()
turnover()
NoOfStaffs()

or a class with all these methods.Please give me a structure to follow.
Posted
Comments
Sergey Alexandrovich Kryukov 5-Sep-13 0:25am    
The question is way too vague. Even the title of the question does not look like a logically correct clause. What do you mean by that?
The choice between interfaces, abstract base classes or the combination on the both depends on many factors. You need to describe the data model in sufficient detail, as well as your concerns.
—SA

1 solution

If you have other objects interacting with your company object, and you don't need to care how those objects implement things, you'd go for interface.

Why not use simple properties?
class Company
{
turnover
{
get;set;
}

staffCount
{
get;set;
}
List<product> productList;
}
//And other properties go here that you link with member variables.

Class Product
{
int productID;
string productName;
.
.

}</product>


btw, your intention is to learn just OOPs or OOPs on MVC (Asp.net)?
If you would like to learn OOPS, stick with Console Applications that spares you from other framework (MVC) wiring and debugging.
 
Share this answer
 
Comments
id-athul 5-Sep-13 1:03am    
Thanks for your support. I am learning MVC with oops,I know the working of MVC.I wish i could implement oops on it.Please link some advance oops tutorials which has realtime projects,I have gone through the basic tutorials.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900