FAQ Database Discussion Community


Suppress F# Compiler Warning: Possible incorrect indentation: this token is offside of context

unit-testing,f#,compiler-warnings,readability,xunit
I have some xunit tests I would like to layout as follows for readability: [<Fact>] let ``Has Hash Code 2``() = target.GetHashCode().ShouldBe 2 [<Fact>] let ``ToString yields two``() = target.ToString().ShouldBe "two" [<Fact>] let ``Has underlysing type int``() = target.GetUnderlyingType().ShouldBe typeof<int> I'm getting a compiler warning on the let statements: "Possible...

Is this comparison behavior well-defined?

javascript,specifications,readability
var x = 'foo'; var y = 'bar'; var isItDefined = (x !== (x = y)); // true, once var isItAssigned = (x === 'bar'); // true This idiom is handy for checking for immutability mutations with Immutable.js, ie if (myMap !== (myMap = myMap.set('x', 2))) { changed.emit(); } IIRC...

Improve readability of enums in C++ [closed]

c++,oop,design,enums,readability
Problem: The problem of enums is that they IMO shrink the readability of code. Think of Motor.Turn (Full). What does Full mean? What were other options (Half? Empty? Green?...)? Idea: What I would like to implement is something like this: Motor.Turn (StepMode::Full) or in another situation: Color c = Color::Red;...

Readability vs Performance comparison

c#,.net,performance,readability
I was reviewing some of the code present in a project I'm working on and found things like these: string personName = currentPerson.Name; personModel.editPerson(idNr, personName); The above is a simple example but it may as well be like below: string idNr= currentPerson.IdNr; string personName = currentPerson.Name; string age = currentPerson.Age;...

What is the code convention for formatting try-with-resources? [closed]

java,java-7,indentation,readability,try-with-resources
I'd like to know what the code convention is for formatting try blocks with resources, in particular with more than one resource. Currently I put each resource on its own line, terminated by a semicolon, and use vim's indentation level (2 tab characters), like the following: try ( InputStream in1...

Convert/Parse many Objects using a member Method with less Code

c#,linq,readability
Is there any simple way to convert/parse many Objects of Class Foo to objects of class Bar, using a member method of class Bar like Bar.loadFromFooObject(Foo classFoo) ? So if I have those 2 Classes: class Foo { public string var1; public int var2; public List<string> var3; } class Bar...

Can I change the default response color in Linux Terminal?

linux,shell,colors,readability
It would be nice to be able to easily see the conversations I have with my computer in 'call and response' style, so my input lines are in one color, and what is returned shows in a different one.

Is it mandatory to enclose an entire ternary operator statement in parenthesis in this statement?

php,ternary-operator,parentheses,readability,code-readability
For example in the following statement, $class = ( is_array($tagClasses) ? 'class="'.implode(" ",$tagClasses).'"' : '' ); is the outermost parentheses only for readability or does it really have any other purpose? I think it is for readability and code-aesthetics only, unless you have other things happening in the same statement,...