Compact code, using C# shorthand and coding habits
I've been reprimanded for writing code that's too complex...well, not exactly reprimanded, but told to please make my code less complicated.
One of the things i do often is use shorthand..for those that doesn't know what shorthand is, its when your use "logical" operators like "? :" and "??" in your code.
ex.
bool result = (object.type == businessObjectType.Status)
? true
: false;
instead of:
bool result;
if (object.Type == businessObjectType.Status)
{
result = true;
}
else
{
result = false;
}
The same goes for not always using { } when i don't see the need.ex.
if (object.FieldValue > 10)
if (otherObject.FieldValue == object.FieldValue)
// do something
To me, shorthand code is extremely easy to use. I even use it nested at times when returning an object or value if there's multiple checks to do and the logic can return multiple objects or values.
My bad habits are obviously not in check with good coding practises, but i've been using this type of code for a LOONG time..the coding style is hard to changed but since it's requested i suppose i'll have to try.
What do people think about it?