Click here to Skip to main content
15,909,835 members
Home / Discussions / C#
   

C#

 
GeneralFinal result.. Pin
Member 9615-Jan-05 6:05
Member 9615-Jan-05 6:05 
GeneralRe: Image Property Pin
14-Jan-05 11:33
suss14-Jan-05 11:33 
GeneralSend Javascript command to IE Pin
Chris Chavez14-Jan-05 10:10
sussChris Chavez14-Jan-05 10:10 
GeneralRe: Send Javascript command to IE Pin
Heath Stewart14-Jan-05 13:14
protectorHeath Stewart14-Jan-05 13:14 
GeneralRe: Send Javascript command to IE Pin
Chris Chavez18-Jan-05 3:27
sussChris Chavez18-Jan-05 3:27 
GeneralRe: Send Javascript command to IE Pin
Heath Stewart18-Jan-05 6:05
protectorHeath Stewart18-Jan-05 6:05 
GeneralRe: Send Javascript command to IE Pin
Chris Chavez19-Jan-05 5:09
sussChris Chavez19-Jan-05 5:09 
GeneralEthical Coding Style Pin
Wayne Phipps14-Jan-05 8:22
Wayne Phipps14-Jan-05 8:22 
I regularly have questions about what/which way is best, most efficient or ethical.

I want to develop applications that look, feel and work well from both a user and coding perspective.

If as an example I wanted to check if a value had changed, I would consider using something like:
<br />
<br />
int _CurrentValue;<br />
		<br />
int CurrentValue<br />
{<br />
     set{_CurrentValue = value;}<br />
     get{return _CurrentValue;}<br />
}<br />
		<br />
bool ValueChanged(int NewValue)<br />
{<br />
     if (CurrentValue != NewValue)<br />
     {<br />
          return true;<br />
     } else {<br />
          return false;<br />
     }<br />
}<br />

I was taught (many years ago) that a method should have one entry and one exit point wherever possible so to abide to that standard, the above could be written as:
<br />
bool ValueChanged(int NewValue)<br />
{<br />
     bool result;<br />
     if (CurrentValue != NewValue)<br />
     {<br />
          result = true;<br />
     } else {<br />
          result = false;<br />
     }<br />
     return result;<br />
}<br />

I was also taught however that you shouldn't use a variable where one was not needed and as the previous code demonstrated, only the programming style was different the result would be the same.

I was just hoping for comments as which method is best/more efficient.


Regards

Wayne Phipps
____________

Time is the greatest teacher... unfortunately, it kills all of its students
LearnVisualStudio.Net

GeneralRe: Ethical Coding Style Pin
Christian Graus14-Jan-05 8:28
protectorChristian Graus14-Jan-05 8:28 
GeneralRe: Ethical Coding Style Pin
Wayne Phipps14-Jan-05 8:41
Wayne Phipps14-Jan-05 8:41 
GeneralRe: Ethical Coding Style Pin
Christian Graus14-Jan-05 9:07
protectorChristian Graus14-Jan-05 9:07 
GeneralRe: Ethical Coding Style Pin
Wayne Phipps14-Jan-05 23:12
Wayne Phipps14-Jan-05 23:12 
GeneralRe: Ethical Coding Style Pin
Christian Graus15-Jan-05 9:45
protectorChristian Graus15-Jan-05 9:45 
GeneralAngle between 2 vectors Pin
flipper8614-Jan-05 7:30
flipper8614-Jan-05 7:30 
GeneralRe: Angle between 2 vectors Pin
Dave Kreskowiak14-Jan-05 7:49
mveDave Kreskowiak14-Jan-05 7:49 
QuestionHow do you determine MSAccess version? Pin
Hostia14-Jan-05 5:12
Hostia14-Jan-05 5:12 
AnswerRe: How do you determine MSAccess version? Pin
Rob Graham14-Jan-05 11:50
Rob Graham14-Jan-05 11:50 
GeneralProblems reading through XML file with XPathNavigator and XPathNodeIterator Pin
huckfinn14-Jan-05 4:57
huckfinn14-Jan-05 4:57 
GeneralRe: Problems reading through XML file with XPathNavigator and XPathNodeIterator Pin
leppie14-Jan-05 5:55
leppie14-Jan-05 5:55 
GeneralCOM in C# (regarding MSMQ) Pin
Esmo200014-Jan-05 4:44
Esmo200014-Jan-05 4:44 
GeneralExtracting Data From Text Files Pin
lizim14-Jan-05 3:52
lizim14-Jan-05 3:52 
GeneralRe: Extracting Data From Text Files Pin
Nick Parker14-Jan-05 4:09
protectorNick Parker14-Jan-05 4:09 
GeneralRe: Extracting Data From Text Files Pin
lizim14-Jan-05 4:17
lizim14-Jan-05 4:17 
GeneralRe: Extracting Data From Text Files Pin
Wayne Phipps14-Jan-05 22:59
Wayne Phipps14-Jan-05 22:59 
Generalmetafiles - physical dimensions in mm Pin
jadamcrain14-Jan-05 3:47
jadamcrain14-Jan-05 3:47 

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.