|
also.. consistency is a little bit of a vague fuzzy concept... mostly people will argue over pointless stuff like bracket and line return...
The argument for consistency is writing code is easy, reading code is harder.
Yet there is a better argument than consistency, it's write simple code. Minimize nested block, minimise recursivity, minimise everything!
Consistency is not really helping in this endless minimisation quests!
And this is the real quest to follow. NOT consistency!
ANd I much rather like creatively short code to consistently bloated one!
|
|
|
|
|
I mean, make the code as simple as it can be and no simpler.
These days I tend to code things that are by nature complicated. I'm into the compiler front end (parser) and middle stuff (type/scope resolution) these days. The code can't be that simple and still be functional.
So there's that. KISS is a good engineering principle, but it doesn't mean that all programs can be simple.
Consistency in style just means that month to month i can tell the same person wrote the code.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Automated message Review wrote: 'ANd' - wtf001: illegal use of capital 'N' following capital 'A' and preceding lowercase 'd'
|
|
|
|
|
#pragma disable warning wtf001
|
|
|
|
|
Well, think of every reading of any of your articles as a code review.
Out of the probably thousands of readers, I'll bet some of them have some level of OCD. (Hi Sander )
|
|
|
|
|
haha @ calling out sander.
he's young and has fire in his belly. When he gets old and jaded he'll care less about stuff like that, and more about contemplating his own mortality like the rest of us.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
While I do kind of agree with lloyd on this I must also admit that I have trouble reading what I consider to be badly formatted code.
But there is little point in complaining.
If it's my own project I reformat and rename variables. But if it's owned by someone else I'll have to adjust. That's just common courtesy.
Oh, btw, Sander has humour. He can take it.
|
|
|
|
|
sigh, I hate this discussion, meetings, forums, wasting time on style:
I say your style sucks, and you [would I'm sure] say mine sucks. so.... that makes us equal? right or not?
next item on the agenda is....
|
|
|
|
|
honey the codewitch wrote: On my own I tend to gravitate towards a combination of styles ABSOLUTE CHAOS HAIL SANTA I like. FTFY (keeping in season spirits)
|
|
|
|
|
I could have sworn I turned you into a newt.
Maybe i was daydreaming.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
honey the codewitch wrote: using postfix-inc in array indexer like _array[index++],
Well, array[++index] does something different than array[index++] , so what's the issue with postfix when you want the index to increment after accessing the value at that index?
int[] foo = { 1, 2, 3, 4, 5 };
int i = 0;
int j = 0;
Console.WriteLine(foo[++i]);
Console.WriteLine(foo[j++]);
2
1
|
|
|
|
|
THat's rather my point, innit?
Readability and maintainability are contrary to pulling stunts like that
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
At least you don't have to fight against MISRA rules and automatic enforcers.
GCS d--(d+) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
My three rules.
- The code must be readable to a junior dev
- The code must be correct (ie safe, efficient and actually do its job)
- The code must be consistent
I'll put up with some really, really bad coding practices if they at least follow the 3 rules. I find it intensely painful switching between modules, files or even methods to find totally different styles and assumptions. It slows down reviews and is like a pot-holed road: you get thrown around and things break.
cheers
Chris Maunder
|
|
|
|
|
On point 1 you and I are going to disagree.
I can't even read LALR(1) generation code. I can't even read the algorithm it's based off of. That's how messy the problem is.
No junior developer will be able to dissect LALR(1) table generation code. Someone with a masters in CS might recognize what it is, and be able to point out the various steps of the algorithm in the routine, but it's the algorithm itself that is the problem, not the code that implements it.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Something tells me that Windows isn't open source not just to protect MS's IP...
|
|
|
|
|
var meth = binder.BindToMethod(BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Static, binder.GetMethodGroup(
code.Namespaces[1].Types[0],
"Bar",
BindingFlags.NonPublic | BindingFlags.Static),
ref args, null, System.Globalization.CultureInfo.CurrentCulture,null);
Console.WriteLine(CodeDomUtility.ToString(meth));
I implemented reflection binding over CodeDOM objects as though they were real types.
I even support the #)(%*@)#% BindingFlags enumeration
Above is just calling the stupid thing. You should see what the code to make it work looks like.
What it does:
say in your codedom you have
class Foo
{
public int Bar(string foo)
{
Console.WriteLine(foo);
return foo.GetHashCode();
}
public string Bar(int foo)
{
Console.WriteLine(foo);
return foo.ToString();
}
}
Based on a group of methods with the same name, and a set of arguments or types you give it, match the signature to what you passed in, and return the appropriate method that best matches the signature, including doing widening conversions on primitive types, and skipping type checking on null arguments.
This is H-A-R-D
But I did it. Woo. Does it for indexed properties as well.
Gosh I never want to have to implement a binder again.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
honey the codewitch wrote: var meth = binder
so, you're cooking, erm, coding meth ?
I'd rather be phishing!
|
|
|
|
|
That's not even the worst of them. I've used die as short for delegate-invoke-expression recently. I've used f-c at least once that i can recall, p-s probably dozens more.
edited for forum rules
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
I'm still impressed that someone at Microsoft managed to slip both PIDL and SHITEMID past their corporate overlords.
Common Explorer Concepts (Windows) | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
haha and I'm such a microsoftie i didn't even think anything of PIDL until you just said something.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
I woke up and had an email saying a book I co-authored was FINALLY published after a year delay! (don't worry, we revised it so it's not a year behind)
So that's pretty awesome.
Because it was supposed to be released a year ago I already did a book presentation in January
This afternoon I went for the AZ-301 exam, Azure Architect Design.
I passed, and with my AZ-300 exam that I passed two weeks ago I can now officially call myself an Azure Solutions Architect
Then I got a call from my dad, who got a call from someone he used to work with who thought about me, who got a call from a customer...
Long story short, I'm calling a company tomorrow (who is a former customer from a previous employer) who may or may not need my services, possibly leaving me with a new customer.
Of course it's very premature to say anything about it, but it's nice to know my name is out there and people think about me
So did nothing go wrong today?
Unfortunately, I got wet in the rain and I spent most of my day wearing wet pants, being cold and having a ridiculous hair cut
Ah well, I'm dry and warm now so all's well that ends well
|
|
|
|
|
May I suggest a new name for you here on CodeProject:
Mr.Sunshine
|
|
|
|
|
I thought "sunshine" is a kind of insult on this forum?
|
|
|
|
|
Not if you are Dutch, words have different meaning for us Dutch (if any at all)
|
|
|
|