Standards - Code Generation in Visual Studio

Status
Not open for further replies.

ShuggyCoUk

Ars Legatus Legionis
10,387
Subscriptor++
It's not asynchronous (stack overflow) its just that its not meant to be catchable (see) but it was in the early days of .Net, and even kind of recoverable then.

If you're hosting the CLR you can, but you're obliged to take out the app domain still.

I do wish their standard hanker reserved enough space to give you the top of the stack at that point, would make spotting trivial recursion screw ups in properties easier.
 

svdsinner

Ars Legatus Legionis
15,152
Subscriptor
[url=http:/civis/viewtopic.php?p=24540369#p24540369:3fuiv9vn said:
ShuggyCoUk[/url]":3fuiv9vn]
Every time you bring up some reason you think is a valid one to encourage them to do something bad, 'better' via boilerplate in the source code, there appears to be an alternative that is actually better they could do instead. . . .

If they have a problem with committing bad stuff then *put in code reviews and help them*. If they won't do that then you are entering a world where, you are letting people run with scissors, and juggle with cats.
There are ALWAYS ways to do things better in code. But, unless you live in a magical environment with no deadlines and infinite resources, you don't strive to do things "perfectly" but rather "what is the best way to get the best code while still keeping expenses (time/money/staff) reasonably low.

[url=http:/civis/viewtopic.php?p=24540369#p24540369:3fuiv9vn said:
ShuggyCoUk[/url]":3fuiv9vn]As to Aunt sally, don't make sweeping statements of generality *to back up a specific position* as if it's somehow backing up your position. Someone's just going to shoot that statement down.
Your fallacy that I have ever been trying *to back up a specific position* is your Aunt Sally. I've been explicit that I was speaking in the big picture and asking that specific positions
NOT be the reason to derail this thread. You, however, keep concocting things that I have never said or meant as your continual strawman.
 

svdsinner

Ars Legatus Legionis
15,152
Subscriptor
[url=http:/civis/viewtopic.php?p=24545887#p24545887:3418g95t said:
Richard Berg[/url]":3418g95t]The post I quoted claimed that additional try/catch/rethrow aided debugging somehow. Um, all .Net exceptions raise a kernel transition and go thru SEH. Literally any Windows debugger can catch such events without needing to muck up the code.
Debuggers only catch things while debugging.
However, they aren't terribly useful for catching bugs that can't be recreated by the developer.

If bob from accounting is having a problem that your app crashes on his machine repeatedly, and the same actions cause no issue on dev/test machines, exception logs are a great way I to be able to track down odd problems. (E.G. Finding that a certain trivial animation that works on all other machines causes the odd video card in some VIPs laptop to lock up his machine.)

Also, certain timing issues can't be debugged by the debugger. (Because the pausing of the debugger resolves the timing issue you are trying to hunt down.)

Additionally, WPF has multiple known quirks with exceptions. Exceptions in event handlers only provide stack traces back to the beginning of the handler execution and offer no insight on what triggered the event. That is, UNLESS the specific operation that caused the handler to fire is inside a try/catch block. I'm not here to defend WPF's idiosyncrasies, I just live in a world where they have to be dealt with.
 

Pont

Ars Legatus Legionis
26,160
Subscriptor
[url=http:/civis/viewtopic.php?p=24550495#p24550495:2wueqdy3 said:
svdsinner[/url]":2wueqdy3]When exception logging is so easy, why would I want to mess with other systems (Dump files, etc.) to get data on exceptions in an app?
Because
* exception logging only works where you actually did it properly
* being able to debug minidumps is reusable knowledge across many problem domains
* mindumps can show you problems that happen outside your own code, such as inside IIS itself
 
[url=http:/civis/viewtopic.php?p=24550495#p24550495:3ubpby07 said:
svdsinner[/url]":3ubpby07]When exception logging is so easy, why would I want to mess with other systems (Dump files, etc.) to get data on exceptions in an app?
Because it directly addresses:
Debuggers only catch things while debugging.
However, they aren't terribly useful for catching bugs that can't be recreated by the developer.

If bob from accounting is having a problem that your app crashes on his machine repeatedly, and the same actions cause no issue on dev/test machines, exception logs are a great way I to be able to track down odd problems. (E.G. Finding that a certain trivial animation that works on all other machines causes the odd video card in some VIPs laptop to lock up his machine.)
and does so in a way that no amount of logging can match.
 
I have been meaning to sign up for a while but I thought I would wait for an interesting topic :).

Visual Assist offers 'Snippets' for the boilerplate code(), this is what we use. For any given situation you can have a snippet with suitable short-name (type the few keystrokes and the snippet will appear). You can use this for simple things like loops etc. but also for classes (so if you have a message class, event class etc., just have a snippet for each).

If you have the mechanism to enforce this at an organisation level, then that would be good. We didn't (that is to say, people could write these classes and not use the templates because maybe they wouldn't even be using Visual Studio), so I ended up creating a suite of macros to tidy things up after they have been submitted. The more optional stuff that you can avoid in these snippets, the better IMO. Doxy-tags etc.; people tend to just forget unless you make it a build error by default.

Standards etc., we also have a bunch of macros to check and report errors. Unfortunately VS2012 no longer has macro support so we are going to have to move those to an Add-In at some point since we have upgraded a few months ago. Nobody wants to sit through a coding review where people are talking about trivial issues like layout and formatting. Automate it and forget about it, and concentrate on reviewing the functionality (assuming that you have a formal review process in the first place!).

For the initial project setup it sounds like you would benefit from a simple project template(assuming that you don't use the default template from Visual Studio itself). Use shared Property Sheets to make sure all settings are consistent, use VA Snippets to knock up your quick application framework at the start of a new project and then Robert is your mother's brother.

We use MiniDumpWriteDump() too, seems like a no-brainer to me tbh. You can have it set up in an afternoon, add a wrapper into a small shared project that people just add to any new application, and nobody needs to worry about it ever again.
 
Status
Not open for further replies.