|
0) If I'm editing an existing file, I follow the formatting already in that file. If I'm creating a new file - in the absence of established corporate coding standards - I use my own style.
1) I never reformat a file to my style because source control would mark every line as being changed when I checked it back in.
2) I always put accessors on private elements.
3) I always use this. , or in the case of static classes, I use ClassName. to denote local class members.
4) I use lowercase chars to start field/method variable names, and camel-case them if necessary.
5) I start class, property, and method names with uppercase chars, and camel-case them if necessary.
6) I put curly braces on their own lines.
7) I'm a fanatic for code alignment.
8) I use LINQ when it makes sense to do so, mostly because it cleans up the code so well without loosing fidelity.
9) I "keep tabs". After I demonstrated why to the rest of the team, they agree it's the best way to go. We have one guy that was doing 5 spaces instead of four when he hit the tab key. This helped him immensely because VS uses five spaces for him, and four for the rest of us.
10) I comment pretty much everything, at least the "why" of it.
Fortunately, I'm currently in a position where I can dictate styling for my team. Even more fortunate, they already used pretty much the same styling techniques.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
I am in a position where I could dictate, but I certainly do not want to if I can avoid it - I try to nudge people in the right direction when possible.
For the rest: yes, you use pretty average code standards like we all do. With some variations like most have. I had to change a thing or two to match the tools, but then - if it was important I could have changed the tool settings - but it was not important.
|
|
|
|
|
Super Lloyd wrote: apart from method, field and property casing, which I will be the first to admit is purely cosmetic Not completely, it helps you make assumptions about your code so you don't have to think about every little detail.
Not constantly having to check whether something is a method or variable or whatever, because it's consistently cased, lowers the cognitive load while reading code.
Most code is already hard enough to read without you having to worry whether something is a field, variable or property.
For example, you could make assumptions about the following code:
public ReturnTheValue(int a) => a + b + C; a is a variable passed to the method, b is probably a private field and C is probably a public property.
You'd be surprised if b was the property and C was the field, it'd be a WTF, and as we all know there's only one good metric for code quality... WTFs per minute.
So just a little more than cosmetics, I'd argue
|
|
|
|
|
Ok, ok, it's a bit more than just cosmetic. Lucky me, that's the only code style I find worth enforcing!
|
|
|
|
|
But... MVVM means you need a UI framework :P
Funny how we don't complain about that with desktop apps
|
|
|
|
|
I rather think of WPF as a UI library. Not a Framework.
While Framework force you to work their way to do (arguably new) stuff, UI library empower you to do stuff however you like!
|
|
|
|
|
Frameworks for desktop applications are just as bad.
|
|
|
|
|
I find that consistent code styling (whatever style you use) also helps with code comparisons / merges.
|
|
|
|
|
Consistency helps a bit when reading code, but it comes with two drawbacks in my view: Endless discussion and code review focusing on formatting while no-one notice the structure of the code is complete crap.
We did find a solution to this in our team. A bit too heavy impact to apply in old projects but for anything new we do it from the start: Analyzers.
We use Stylecop and NETAnalyzers (or whatever fxcop was renamed to.... or do we still have FXCop and it was Stylecop renamed? Who knows? Who cares?) and a few others.
We suppress some things (no file headers, no requirement to document public methods in anything but public APIs). There is no strict rule for what we suppress, but any suppression also goes through code review, and typically "this adds a lot of work and no benefit" will be accepted while "it looks better this way" is unlikely to get through - at least as a global suppression.
In the start there is the usual complains about prefixing with "this." and placing using statements inside the namespace declaration. Luckily there is a solution: Simply say "sure, we can change it if you don't like it, just try doing it 3-6 months then we will discuss what we want to change. Most will live with this "mandate" form a senior. After all, in 3-6 months they will have the discussion and they can get this stupidity changed.... Then after 3-6 months, they realized it just doesn't matter and don't want to change anything.
Set the release build to treat warnings like errors - and force a build on merge to "develop" or whatever branch you use and formatting is "just taken care of" by tools as it should be.
|
|
|
|
|
lmoelleb wrote: Endless discussion and code review focusing on formatting while no-one notice the structure of the code is complete crap.
We don't talk about formatting in our code reviews, unless the format of the target code does not follow the formatting in the rest of the file.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
So if I understand you correct: You check (and if needed talk about) formatting in the code reviews.
Of course, once developers get used to following whatever you have it is not often it has to be brought up - we work that way in the old code as well.
It's just so much easier in the new code. It's trivial work, exactly the thing computers where invented to do.
|
|
|
|
|
No we don't make it part of the code review itself. If the formatting is way off, we mention it at the end of the review, but it's not a "topic of discussion".
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Fair enough, we just use different wordings. Something that is checked and potentially mentioned (even briefly) I see as part of the review, but you do not. In the end I think we in practice do the same thing.
|
|
|
|
|
Windows 10, updated, decided that it would not let me map drives to my ancient NAS box any more. Do not pass go, do not collect $200. Just go. NAS box does SMB1 only and no update for firmware. Actually, there is a way to enable it via Powershell but I think I bought the NAS box in 2012 and it doesn't own me anything. I will take the data off the drives (mirror RAID) and move them over, they are only a couple of years old.
So, although I hated to spring for a new NAS box and start over, that seemed to be the better choice. Duckduckgo'd some NAS stuff and hit on JSOP's oldish article, here on CP, about using freenas. Have a decent Dell Precision Workstation I just removed from surveillance duty and Viola!
Installed Truenas (replaced freenas) and am still configuring/learning. Many options similar to Synology (probably same OS). Like Synology, I can limit attaching hosts by IP address and set some backups as WORM (after 5 minute delay). Still much to configure but basics are working well. Performance is excellent when using Veeam to back up virtual machines from ESXi. Now about those drives... Thanks for the idea JSOP (real).
>64
If you can keep your head while those about you are losing theirs, perhaps you don't understand the situation.
|
|
|
|
|
I had the same problem, but found a workround: set your router to give a fixed IP address to your NAS and disconect the current shares. Then remake them using IP addresses instead of server names.
All shares on my SMB1 NASes work fine (though occasionally I have to restart Windows if it doesn't connect, but that's because the NAS has spun down the drives and hibernated it's software overnight rather than being Windows fault. It just takes too long to wake up and Windows times out waiting. A restart fixes it immediately.
C:\Users\PaulG>net use
New connections will be remembered.
Status Local Remote Network
-------------------------------------------------------------------------------
OK A: \\192.168.0.11\ZDCIM Microsoft Windows Network
OK B: \\192.168.0.11\Griff Microsoft Windows Network
OK M: \\192.168.0.11\Music Microsoft Windows Network
OK P: \\192.168.0.11\Pictures Microsoft Windows Network
OK S: \\192.168.0.11\Software Microsoft Windows Network
OK V: \\192.168.0.11\Video Microsoft Windows Network
OK X: \\192.168.0.11\Publications
Microsoft Windows Network
The command completed successfully.
C:\Users\PaulG>
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
All IP addresses are fixed and all shares by IP. Had to enable SMB1 to reconnect shares to that NAS. Replacing it anyway. Too slow now that things are more bloated.
Thank you.
>64
If you can keep your head while those about you are losing theirs, perhaps you don't understand the situation.
|
|
|
|
|
I understand your issue and wish you the best. How many machines on your network? I have a Raid+ box attached by USB to one of my 2 computers, and a Proraid attached to the other. They are not Networked.
They are both configured for raid 5. The Raid+ has 4 4TB SSD drives, and the Proraid has 4 hard disks.
They are both plenty fast enough for me. I actually use the Raid+ as an external drive and not just for backup.
You are correct, CP is great for many things. I just wish thye could add a Spell checker function to this message box. And before anyone remarks why don't I write one , I don't know how. I bought the one I use.
Slower than ever....
|
|
|
|
|
Thank you, my issue is being resolved by my "new" TrueNAS system. I merely intended to pass along my appreciation for this site.
I have 4 hardware systems and about a 6 of 12 virtual machines running at any given time. I use both ESXi and VMware Workstation. I "model" a client's network of 4 servers and a second network of surveillance cameras.
I run 3 LAN's here, each with its own public facing router/firewall. All IP's, public and private are static. Having resolved some 3 Ransomeware situations, I am slightly paranoid. No, that is wrong, I am not paranoid, they are out to get me (you too)!
>64
If you can keep your head while those about you are losing theirs, perhaps you don't understand the situation.
|
|
|
|
|
You are a significantly better man than me! I agree that they are out to get us.
Maybe we should form an alliance to track them down and go "get them"
Zaphod
|
|
|
|
|
At my age, "go get them" means bagels at the deli are BOGO.
>64
If you can keep your head while those about you are losing theirs, perhaps you don't understand the situation.
|
|
|
|
|
Plant puns: I didn't peony myself laughing.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
You rose to the occasion with that pun, this thread will be poplar I think.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Meh, I've already become Impatien with it.
|
|
|
|
|
Maybe, I thought we would have to weed through a lot of responses. I can't kelp but think there will be more, I'll wait dill the end of the day and see.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
I can't help but think the lack of responses is parsley because people think I'm a newbie instead of a re-carnation.
Mwa ha ha ha!
|
|
|
|
|