Click here to Skip to main content
15,911,306 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello friends,
I have defined class as below

public class UserDAO
{ 
     public clsUser Validate(string username,string pwd)
	{
        }
         
     public int saveUserDetails(clsUser objUser)
        { 
        }

     public DataSet GetUserDetails()
        {
        }
}


May i know, do I require inheritance in above scenario??
Just trying to know how actually inheritance is implemented

Thanks in advance
Posted
Comments
CPallini 1-Apr-11 8:52am    
That's not a scenario, that's a sketch of code.
Albin Abel 1-Apr-11 8:57am    
Yes agreed
dhage.prashant01 1-Apr-11 9:02am    
Ok, is this class doing more than one functionality?

You don't have to use inheritance in the above scenario, inheritance is used to kind of have a starting point.

For example if you inherit a class from a TextBox object, your class is exactly the same as the TextBox class
C#
public class MyCustomTextbox : System.Windows.Forms.Textbox
{
}


You can use inheritance to add or manipulate functionality to an existing type. In this example you can add or modify functionality to the TextBox control, for example Validation or something.

Have fun,

Eduard
 
Share this answer
 
Comments
Albin Abel 1-Apr-11 8:58am    
informative. My 5
 
Share this answer
 
Comments
dhage.prashant01 1-Apr-11 8:56am    
I know inheritance in books, but i want know how is it implemented in projects.
Albin Abel 1-Apr-11 9:00am    
if you feel some of the business logic can be use by many children, then move that to a parent. Or if you feel many children can use your logic then let the children inherit you. There is no hard rule.
[no name] 1-Apr-11 9:09am    
It usually starts by implementing what is described in the books
Albin Abel 1-Apr-11 8:58am    
Informative links
It's not strictly possible to answer that.

The question you have asked is similar to "Do I need petrol to drive to the shops?"
The answer depends on too many unspecified things:
1) Do you have a car or motorcycle?
2) Does it have enough fuel to get to the shops?
3) Does it run on diesel?
4) Is there a petrol station nearby?
5) Are you or the shops on an island with no bridge?

Do you need to inherit from anything? There is nothing in your class as shown which needs to inherit, but with just a tiny fragment nothing can be reliably said.
 
Share this answer
 
Comments
Albin Abel 1-Apr-11 8:56am    
Good answer. Without knowing the dependability of other objects to this object nothing can say. My 5
Sergey Alexandrovich Kryukov 1-Apr-11 12:46pm    
Well, this is a serious one. No kidding, my 5.
--SA

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