readability

Implicit return values in Ruby

I am somewhat new to Ruby and although I find it to be a very intuitive language I am having some difficulty understanding how implicit return values behave. I am working on a small program to grep Tomcat logs and generate pipe-delimited CSV files from the pertinent data. Here is a simplified example that I'm using to generate the line...

Flesch-Kincaid Readability: Improve PHP function

Hello! I wrote this PHP code to implement the Flesch-Kincaid Readability Score as a function: function readability($text) { $total_sentences = 1; // one full stop = two sentences => start with 1 $punctuation_marks = array('.', '?', '!', ':'); foreach ($punctuation_marks as $punctuation_mark) { $total_sentences += su...

What is the best color combination for readability, easy of use, and reduced eye strain?

I am trying to pick out the optimal set of colors for a new website project. I want to do a traditional black on white look and feel for the main content. However my partner on the project wants to do a color combination that more looks like the traditional Windows Forms look and feel. Is there any research available on the best c...

Beautifying C# Syntax

In my C#/ASP.NET project I have an object which has certain categories of behavior. Each behavior category is physically dependent on a root object but to make the code read better i want to clearly differentiate the categories. I think it would be interesting to see how my implementation compares to what others might write to solve the ...

Access fields or properties from within the declaring class

Public Class FooBar { private int _foo; public int Foo { get { return _foo; } set { _foo = value; } } public void DoStuff() { _foo++; // Do this? Foo++; // Or this? } } Is there a more accepted practice to either access fields or properties (if one exists) in a class? I've alwa...

Loupe Magnification with White Text & Clear Background on Iphone

You guys helped so much with my last question, I figured I'd give you a shot at another. I have written an app with a theme that uses a dark blue glassy background and white / gray text and labels. The textfields in my app have clearcolor backgrounds and white texts and everything shows up very well. My only concern is that when you hold...

conditional formatting or formatting with VBA

In MS Access, is there a reason to prefer conditional formatting over setting formatting options with VBA? Is one more effecient or generally considered easier to read? ...

Web Interfaces: What is a good way to display many static fields?

My web applications have pages that display many static fields. I know that poor layout invariably leads to information overload and poor readability. My Question: Are there any best-practices or heuristics for laying out a screen that contains many static fields? Ordinarily, I would reference Bill Scott and Theresa Neil's excell...

Clearest way to code structarray map functor in C++

This is a poll for opinions on the most readable way to do something -- whether to use a C++ pointer-to-member, a byte offset, or a templatized functor to define "select member X from structure foo". I've got a type that contains a large vector of structures, and I'm writing a utility function that basically operates as a reduce over s...

Why STL implementation is so unreadable? How C++ could have been improved here?

For instance why does most members in STL implementation have M or _ or __ prefix? Why there is so much boilerplate code ? What features C++ is lacking that would allow make vector (for instance) implementation clear and more concise? ...

What makes a language readable or not readable?

I heard people say they can understand their python code a year later but not their XYZ code. Why? I dont know what is good about python syntax or what is bad about another. I like C# but i have a feeling VB.NET code is easier to read. I am doing language design so what do you find makes code/syntax/language readable or not readable? ...

Most readable way to assign a double quote to a string in C#

Does anyone else think that escaping characters in very short strings make them not very readable? I noticed I was using s = "\"" in my code to assign a double quote a string, but having thought about it, I came up with the following alternative: s = '"'.ToString(). Is my alternative any good? Would you prefer see the first version in ...

What is the most readable use of String.Format for long strings with many parameters?

For instance: String login = String.Format("computer={0}&ver={1}.{2}.{3}&from={4}&realcomputername={5}&type={6}&Channels={7}&Hotkeys={8}&ID={9}\r\n", serviceConfig.Computer, serviceConfig.Version.Major, serviceConfig.Version.Minor, serviceConfig.Version.Build, userName, ...

Which code is more readable?

Suppose I have two methods bool Foo() and bool Bar(). Which of the following is more readable? if(Foo()) { SomeProperty = Bar(); } else { SomeProperty = false; } or SomeProperty = Foo() && Bar(); On the one hand, I consider the short-circuiting && to be a useful feature and the second code sample is much shorter. On the o...

Boolean method naming readability

Simple question, from a readability standpoint, which method name do you prefer for a boolean method: public boolean isUserExist(...) or: public boolean doesUserExist(...) or: public boolean userExists(...) ...

Actionscript 'Object' labeled as a real datastructure for readability

So in actionscript 3, instances of the Object class can be used an as associative array: var doNotHaveSexWith:Object = new Object(); doNotHaveSexWith['mum'] = new Person(...); doNotHaveSexWith['dad'] = new Person(...); doNotHaveSexWith['dave'] = new Person(...); Say I have some class, and one of it's members is a read only 'Object' wh...

Design of an Alternative (Fluent?) Interface for Regular Expressions

I've just seen a huge regex for Java that made me think a little about maintainability of regular expressions in general. I believe that most people - except some badass perl mongers - would agree that regular expressions are hardly maintainable. I was thinking about how this situation could be fixed. So far, the most promising idea I h...

What's the cleanest way to write a multiline string in JavaScript?

It doesn't really have to add newlines, just something readable. Anything better than this? str = "line 1" + "line 2" + "line 3"; ...

In what order should I place properties, events, functions, function overrides, etc. in C# classes?

When creating a new C# class I am not certain of what the best logical order for declaring properties, event delegates, functions, function overrides, etc. are and what considerations should be taken into account when deciding on that order. Typically when creating the code behind class of a WebUserControl I end up placing things in th...

Extension 'Class': Good use of extension methods and increase code readability... or bad smell?

So I've been dealing with several APIs recently provided by different software vendors for their products. Sometimes things are lacking, sometimes I just want to make the code more readable, and I'm trying to avoid a ton of static methods where they don't belong to "get what I need" from the APIs. Thus, I've found myself writing quite a ...