Click here to Skip to main content
15,891,372 members
Home / Discussions / C#
   

C#

 
AnswerRe: What's special with message box? Pin
PIEBALDconsult7-Oct-09 7:27
mvePIEBALDconsult7-Oct-09 7:27 
GeneralRe: What's special with message box? [modified] Pin
teknolog1237-Oct-09 7:37
teknolog1237-Oct-09 7:37 
GeneralRe: What's special with message box? Pin
LimitedAtonement7-Oct-09 7:42
LimitedAtonement7-Oct-09 7:42 
GeneralRe: What's special with message box? Pin
teknolog1237-Oct-09 8:09
teknolog1237-Oct-09 8:09 
GeneralRe: What's special with message box? Pin
PIEBALDconsult7-Oct-09 7:42
mvePIEBALDconsult7-Oct-09 7:42 
QuestionAnother method safer than StreamWriter and how can I save the file on another server (asp.net c sharp) Pin
aspkiddy7-Oct-09 6:32
aspkiddy7-Oct-09 6:32 
QuestionCode Readability Poll Pin
LimitedAtonement7-Oct-09 5:57
LimitedAtonement7-Oct-09 5:57 
AnswerRe: Code Readability Poll Pin
Kevin Marois7-Oct-09 6:34
professionalKevin Marois7-Oct-09 6:34 
Aaron,

I teach C# at a local JC, and one thing I always stress is readability. White space and well defined blocks of
code are good because it allows your mind to process each item individually line by line, whereas this

Insets insets = obj as Insets;
if (ReferenceEquals(insets, null)) return false;
return ((top == insets.top) && (left == insets.left) && (bottom == insets.bottom) && (right == insets.right));

forces me to stop and pick apart these lines to digest all that is happening.

I find this to me much clearer
if (obj is Insets)
{    
	Insets insets = obj as Insets;    
	return ((top == insets.top) && (left == insets.left) && (bottom == insets.bottom) && (right == insets.right));
}
return false;


Also, one other thing we teach is having only one return in a method. It prevents "spaghetti code" where you
have to really hunt to see where the method is actually ending. So condider this:

bool bReturn = false;
if (obj is Insets)
{    
	Insets insets = obj as Insets;    
	bReturn = ((top == insets.top) && (left == insets.left) && (bottom == insets.bottom) && (right == insets.right));
}
return bReturn;


So now if I wanted to put more code in the method that I know will always run, all I have to do is find
the return & put the code above it.

Just my humble opinion.

Everything makes sense in someone's mind

GeneralRe: Code Readability Poll Pin
N a v a n e e t h7-Oct-09 7:38
N a v a n e e t h7-Oct-09 7:38 
GeneralRe: Code Readability Poll Pin
PIEBALDconsult7-Oct-09 8:22
mvePIEBALDconsult7-Oct-09 8:22 
GeneralRe: Code Readability Poll Pin
Gideon Engelberth7-Oct-09 9:14
Gideon Engelberth7-Oct-09 9:14 
GeneralRe: Code Readability Poll Pin
PIEBALDconsult7-Oct-09 13:49
mvePIEBALDconsult7-Oct-09 13:49 
AnswerRe: Code Readability Poll Pin
Luc Pattyn7-Oct-09 6:40
sitebuilderLuc Pattyn7-Oct-09 6:40 
GeneralRe: Code Readability Poll Pin
Ennis Ray Lynch, Jr.7-Oct-09 8:59
Ennis Ray Lynch, Jr.7-Oct-09 8:59 
GeneralRe: Code Readability Poll Pin
Luc Pattyn7-Oct-09 9:14
sitebuilderLuc Pattyn7-Oct-09 9:14 
GeneralRe: Code Readability Poll Pin
PIEBALDconsult7-Oct-09 12:58
mvePIEBALDconsult7-Oct-09 12:58 
AnswerRe: Code Readability Poll Pin
N a v a n e e t h7-Oct-09 6:42
N a v a n e e t h7-Oct-09 6:42 
GeneralRe: Code Readability Poll Pin
PIEBALDconsult7-Oct-09 7:32
mvePIEBALDconsult7-Oct-09 7:32 
GeneralRe: Code Readability Poll Pin
N a v a n e e t h7-Oct-09 7:42
N a v a n e e t h7-Oct-09 7:42 
GeneralRe: Code Readability Poll Pin
DaveyM697-Oct-09 9:08
professionalDaveyM697-Oct-09 9:08 
GeneralRe: Code Readability Poll Pin
LimitedAtonement7-Oct-09 10:02
LimitedAtonement7-Oct-09 10:02 
GeneralRe: Code Readability Poll [modified] Pin
DaveyM697-Oct-09 11:12
professionalDaveyM697-Oct-09 11:12 
AnswerRe: Code Readability Poll Pin
Not Active7-Oct-09 6:44
mentorNot Active7-Oct-09 6:44 
GeneralRe: Code Readability Poll Pin
Kevin Marois7-Oct-09 6:53
professionalKevin Marois7-Oct-09 6:53 
GeneralRe: Code Readability Poll Pin
N a v a n e e t h7-Oct-09 7:24
N a v a n e e t h7-Oct-09 7:24 

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.