Question

Which would be considered more maintainable?

if (a == b) c = true; else c = false;

or

 c = (a == b);

I've tried looking in Code Complete, but can't find an answer.

I think the first is more readable (you can literally read it out loud), which I also think makes it more maintainable. The second one certainly makes more sense and reduces code, but I'm not sure it's as maintainable for C# developers (I'd expect to see this idiom more in, for example, Python).

No correct solution

Licensed under: CC-BY-SA with attribution
scroll top