Click here to Skip to main content
16,017,264 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: Code Readability Poll Pin
Not Active7-Oct-09 7:53
mentorNot Active7-Oct-09 7:53 
GeneralRe: Code Readability Poll Pin
PIEBALDconsult7-Oct-09 7:54
mvePIEBALDconsult7-Oct-09 7:54 
GeneralRe: Code Readability Poll Pin
LimitedAtonement7-Oct-09 7:32
LimitedAtonement7-Oct-09 7:32 
GeneralRe: Code Readability Poll Pin
Not Active7-Oct-09 8:01
mentorNot Active7-Oct-09 8:01 
GeneralRe: Code Readability Poll Pin
PIEBALDconsult7-Oct-09 8:07
mvePIEBALDconsult7-Oct-09 8:07 
GeneralRe: Code Readability Poll Pin
PIEBALDconsult7-Oct-09 7:40
mvePIEBALDconsult7-Oct-09 7:40 
AnswerRe: Code Readability Poll Pin
PIEBALDconsult7-Oct-09 7:26
mvePIEBALDconsult7-Oct-09 7:26 
If it ain't broke don't fix it.

An organization should have coding standards and everyone should follow them. If you have a standard and you find a non-complying file you may fix it (and alert a superior who should endeavor to enlighten the wayward developer). If you have no standard, then don't reformat the code just to "make it more readable".

Any edits you make to the code should otherwise fit the existing format.


LimitedAtonement wrote:
I do this kind of thing ALL the time


Then you're wasting time.


LimitedAtonement wrote:
ReferenceEquals, not `=='.


For what purpose? == is likely to be overridden to perform what the developer of the class thinks is best, which may simply be ReferenceEquals anyway.


LimitedAtonement wrote:
I'm crazy about conserving lines


For what purpose? Other than with compiler directives; you can write C/C++/C# with no line breaks at all. I don't see you doing that; obviously you recognize that whitespace enhances readability (I simply take it to a much higher level Cool | :cool: ). Back in high school when I was learning BASIC I endeavored to put the most statements on a line as I could -- the result is unreadable by humans. I've matured since then.


LimitedAtonement wrote:
some people swear by ALWAYS using braces


I wouldn't say that I swear by it; I recognize that they're not required in some cases. The primary reason is if I need to add an additional statement later, perhaps just during debugging, I don't need to constantly add and remove BRACEs as I work on the code. As an added bonus, by always using them, (I feel) my code has a more cohesive look and feel. Another concern is line length; I've worked in shops where the coding standard specified a maximum line length of eighty characters, BRACEs yield an obvious place to break a line.

<Aside>In my opinion, the BRACEs should be required and the parentheses should not be. Currently, when writing an if statement, you are required to type at least two and at most six delimiters. By requiring the BRACEs rather than the parentheses, the maximim is reduced to four while retaining the minimum of two. Any of you who want to "save keystrokes" should see the logic in this.</Aside>


As to multiple <codelang="text">returns in a method:

They are rarely needed and should only be used when the alternatives are much less readable. In my opinion, single-return methods show that the developer has a more organized concept of program flow and doesn't take shortcuts.

As for the posted code; why not:

Insets insets = obj as Insets;
return ( (insets != null) && (top == insets.top) && (left == insets.left) && (bottom == insets.bottom) && (right == insets.right));

AnswerRe: Code Readability Poll Pin
PIEBALDconsult7-Oct-09 8:41
mvePIEBALDconsult7-Oct-09 8:41 
AnswerRe: Code Readability Poll Pin
OriginalGriff7-Oct-09 10:35
mveOriginalGriff7-Oct-09 10:35 
GeneralRe: Code Readability Poll Pin
PIEBALDconsult7-Oct-09 13:22
mvePIEBALDconsult7-Oct-09 13:22 
QuestionPocket PC development tools Pin
libelledriver7-Oct-09 4:21
libelledriver7-Oct-09 4:21 
AnswerRe: Pocket PC development tools Pin
EliottA7-Oct-09 4:24
EliottA7-Oct-09 4:24 
GeneralRe: Pocket PC development tools Pin
libelledriver9-Oct-09 3:25
libelledriver9-Oct-09 3:25 
GeneralRe: Pocket PC development tools Pin
EliottA9-Oct-09 3:27
EliottA9-Oct-09 3:27 
Questionscoket communication through internet IP between two machine? Pin
Tridip Bhattacharjee7-Oct-09 4:20
professionalTridip Bhattacharjee7-Oct-09 4:20 
AnswerRe: scoket communication through internet IP between two machine? Pin
stancrm7-Oct-09 5:43
stancrm7-Oct-09 5:43 
Questioni need help Pin
Mohamed El-Wehishy7-Oct-09 4:17
Mohamed El-Wehishy7-Oct-09 4:17 
AnswerRe: i need help Pin
Blikkies7-Oct-09 4:28
professionalBlikkies7-Oct-09 4:28 
RantRe: i need help Pin
Greg Chelstowski7-Oct-09 4:41
Greg Chelstowski7-Oct-09 4:41 
GeneralRe: i need help Pin
Blikkies7-Oct-09 4:44
professionalBlikkies7-Oct-09 4:44 
GeneralRe: i need help Pin
Mohamed El-Wehishy7-Oct-09 4:53
Mohamed El-Wehishy7-Oct-09 4:53 
AnswerRe: i need help Pin
Blikkies7-Oct-09 4:52
professionalBlikkies7-Oct-09 4:52 
GeneralRe: i need help Pin
Mirko19807-Oct-09 5:46
Mirko19807-Oct-09 5:46 
GeneralRe: i need help Pin
Blikkies7-Oct-09 7:11
professionalBlikkies7-Oct-09 7:11 

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.