code-readability

How can I decouple this C# worker thread code from the main thread for shared data variables?

How could I modify the below code such that I could, for better readability in code: a) move the "workThreadMethod()" into it's own class b) not have any code in this worker thread class reference static variables from the main "Program" class c) the above are the main two requirements, however I'm hoping that as a side effect this wo...

Don't you sometimes hate the way the "m" character looks in your code?

We all write code using monospaced fonts and the "m" character often (depending on the character combination) looks awful in monospaced fonts. There are other characters that tend to look bad but "m" has the worst reputation in my book. I'm curious if anyone agrees with me on this. ...

Parsing big XML file with SAX parser, the class is becoming bloated and unreadable - How to fix this ?

This is purely a code readability related question, the performance of the class is not an issue. Here is how I am building this XMLHandler : For each element that is relevant to the application, I have a boolean in'ElementName' which I set to true or false depending on my location during the parsing : Problem, I now have 10+ boolean d...

Method call overhead

Hi I'd like to know what's the overhead of calling a method- in .Net -which returns inmediatly (because a condition which is the first code inside is not met). I'd argue that no matter how real-time your application is, that overhead is negligible and that in any case profiling should show the facts, being readability more important, ...

What's the normal way of organising a header file in Objective-C?

I do start off organising my .h files with the best intentions but somehow they get disgustingly messy. Below is an example (which isn't that bad, but i've seen much worse!). I've tried grouping sections with #pragma mark but it seems to look even messier. All the UILabels and UIButtons are required (as mentioned above) as they're sh...

Challenges of refactoring unit-tests to be maintainable and readable when dealing with List<T> objects

In the book The Art of Unit Testing it talks about wanting to create maintainable and readable unit tests. Around page 204 it mentions that one should try to avoid multiple asserts in one test and, perhaps compare objects with an overridden Equals method. This works great when we have only one object to compare the expected vs. actual re...

How do you encourage fellow programmers to care about code readability?

I've noticed some programmers do not seem to have much desire to write clean, organized, and readable code. What are some good ways to encourage consistent indentation, good naming of variables and functions, organized file structures, among other things? ...

Does "var" keyword hampers code readability?

I just started using Resharper. One of its features is that it suggests changes to the code based on, i suppose, good coding practices. One of the changes it suggested is to change the variable type to var during assignment. I kept on changing and now the code has var everywhere. Somehow I get the feeling that "var" keyword makes the c...

Better way to structure an "If" statment

Which of the following is a better way to structure nesting of If statments. if (x && y) doXY(); else if (x) doX(); else if (y) doY(); (OR) if(x) if(y) doXY(); else doX(); else if(Y) doY(); ...

php refactoring and better coding for php?

i have this process that is the heart of my app, that im creating, but for some reason i feel like its the worst way to do it(instinct) , and i wanted to see if thier is something wrong with this process, and am i approaching it in a bad way! p.s. the code works fine, just refactoring problem. the process is: users go to homepage, they...

Using { } to segment large blocks of code to improve code-readability - Good practice?

Hello, I'm considering the option of using anonymous { } code blocks to logically distinguish "code blocks" inside the same method call, something that (theoretically) should improve readability of the code. I'm wondering which of the following 2 code segments is better to your eyes? Also, are the 2 code segments compile to the same b...