Click here to Skip to main content
15,888,610 members
Home / Discussions / C#
   

C#

 
AnswerRe: connectivity problem with SQL Server Pin
Marek Grzenkowicz1-Sep-06 23:17
Marek Grzenkowicz1-Sep-06 23:17 
AnswerRe: connectivity problem with SQL Server Pin
Nader Elshehabi1-Sep-06 23:53
Nader Elshehabi1-Sep-06 23:53 
AnswerRe: connectivity problem with SQL Server Pin
beatles16922-Sep-06 23:21
beatles16922-Sep-06 23:21 
GeneralRe: connectivity problem with SQL Server Pin
komal243-Sep-06 21:07
komal243-Sep-06 21:07 
GeneralRe: connectivity problem with SQL Server Pin
beatles16923-Sep-06 22:20
beatles16923-Sep-06 22:20 
GeneralRe: connectivity problem with SQL Server Pin
Saira Tanwir3-Sep-06 22:35
Saira Tanwir3-Sep-06 22:35 
Questionoverloading and overriding Pin
lakshmi_sri1-Sep-06 19:03
lakshmi_sri1-Sep-06 19:03 
AnswerRe: overloading and overriding Pin
Phillip M. Hoff1-Sep-06 20:16
Phillip M. Hoff1-Sep-06 20:16 
When overloading methods, one thing to keep in mind is consistency of the API.

For example, suppose we have a method DoSomething() that ultimately requires an integer parameter and, optionally, string and boolean parameters. One way we could do this is the following:

void DoSomething(int required1);
void DoSomething(string option1, int required1);
void DoSomething(bool option2, string option1, int required1);

While this technically works, it's not a consistent API. How often are users going to have to consult their documentation to remember the order in which parameters are expected? Even worse, imagine that your optional parameters are of the same type. How easy would it be then to accidentally swap arguments passed to the method? Yes, Intellisense helps, but it's not a substitute for a simple API and, besides, not everyone uses Visual Studio.

Consistency further applies to the default values of those optional parameters. In general, "missing" parameters should have the same default value in each overloaded method.

When overriding methods, an important thing to keep in mind is maintaining the semantics of the base class method. That is, when a base class marks a method as virtual it expects that method to behave within certain constraints, despite the fact that the derived class can theoretically do whatever it likes within that method. For example, in a file stream hierarchy it might be that the ReadByte() method throw an exception if called before the Open() method. For a Windows Forms control it might be that the overridden OnClicked() method in the derived class must call the base class method (in order for the Clicked event to be fired).

For the developer of the API, maintaining semantics means documenting, in detail, the expectations of derived classes with respect to overriding methods. For the user of the API, it means ensuring derived classes meet those expectations.

-Phil
GeneralRe: overloading and overriding Pin
Guffa1-Sep-06 21:15
Guffa1-Sep-06 21:15 
QuestionI need help please Pin
TheCardinal1-Sep-06 18:30
TheCardinal1-Sep-06 18:30 
AnswerRe: I need help please Pin
Coding C#1-Sep-06 21:31
Coding C#1-Sep-06 21:31 
GeneralRe: I need help please Pin
Daniel Grunwald2-Sep-06 1:33
Daniel Grunwald2-Sep-06 1:33 
AnswerRe: I need help please Pin
Stefan Troschuetz1-Sep-06 21:40
Stefan Troschuetz1-Sep-06 21:40 
AnswerRe: I need help please Pin
kkadir1-Sep-06 22:54
kkadir1-Sep-06 22:54 
GeneralRe: I need help please Pin
TheCardinal3-Sep-06 0:30
TheCardinal3-Sep-06 0:30 
QuestionDescriptionAttribute question Pin
e-laj1-Sep-06 18:20
e-laj1-Sep-06 18:20 
QuestionC# 2.0 Process.Start Pin
kselman1-Sep-06 17:09
kselman1-Sep-06 17:09 
AnswerRe: C# 2.0 Process.Start Pin
Not Active1-Sep-06 18:19
mentorNot Active1-Sep-06 18:19 
GeneralRe: C# 2.0 Process.Start Pin
kselman1-Sep-06 19:13
kselman1-Sep-06 19:13 
QuestionC# Application Monitor? Pin
wbjohnson1-Sep-06 12:47
wbjohnson1-Sep-06 12:47 
AnswerRe: C# Application Monitor? Pin
Jun Du1-Sep-06 16:08
Jun Du1-Sep-06 16:08 
Questionplz help! Pin
maryamf1-Sep-06 12:28
maryamf1-Sep-06 12:28 
AnswerRe: plz help! Pin
Nader Elshehabi1-Sep-06 12:39
Nader Elshehabi1-Sep-06 12:39 
AnswerRe: plz help! Pin
Muammar©2-Sep-06 1:43
Muammar©2-Sep-06 1:43 
QuestionChanging .NET version in VC# 2005? Pin
Lord Kixdemp1-Sep-06 11:49
Lord Kixdemp1-Sep-06 11:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.