Spaghetti gate

25
You Will Haz Crazy Code! Super-Charged Debugging for the New Developer

description

You've officially leveled-up in the world of software development with Visual Studio, and you now find yourself working on projects that are infinitely larger and far more complex than anything you've worked on before. Time to beef up your debugging skills not only to debug, but sometimes just to learn the flow of a given process! Plain old break-points have always gotten you by, but now you quickly run into trickier situations that come close to making your head explode. Come and learn some new debugging tricks & tips to bring your debugging skills to new heights.

Transcript of Spaghetti gate

Page 1: Spaghetti gate

You Will Haz Crazy Code!Super-Charged Debugging for the New Developer

Page 2: Spaghetti gate

why are we here?

● Developers spend a *lot* of time debugging code.

● You're a developer interested in pushing your debugging skills beyond simple breakpoints.

● As the projects you work on grow in size and complexity, you will likely want some additional tools at the ready for when breakpoints prove totally, completely and in all other ways wholly inadequate.

Page 3: Spaghetti gate

who's the geek up front?

● Software/web developer at Bridgepoint Education, rocking primarily with ASP.NET MVC 4, SQL Server 2008, C#, Java, Javascript, Unity.

[email protected]● www.jonbachelor.com● @DigiPug● speakerrate.com/digipug● slideshare.net/digipug● (this will all be at the end too!)

Page 4: Spaghetti gate

he's doing it wrong

Page 5: Spaghetti gate

totally doing it right... but might be drunk

Page 6: Spaghetti gate

the good news

There are enough debugging tools, tips, tricks and techniques to make this into a semester-length course, rather than a 1 hour talk.

Page 7: Spaghetti gate

the bad news

There are enough debugging tools, tips, tricks and techniques to make this into a semester-length course, rather than a 1 hour talk.

Page 8: Spaghetti gate

meet the tip of the iceberg

● Breakpoints● Tracepoints● Homemade debug

snippets● Conditional

breakpoints● Breakpoint filters● Fiddler● AOP with

PostSharp

● MOQ● 'FileWatcher'● Intellitrace● LINQPad● Snoop● Debug converters● sqlcmd● VS exception

settings● so... much... more...

Page 9: Spaghetti gate

the mighty breakpoint

Page 10: Spaghetti gate

f9, f10, ctrl-f10, f11, shift-f11

Use function keys to speed up your debugging efforts:● f9: Sets a breakpoint at your cursor● f10: Step over (not INTO code)● ctrl-f10: Run to cursor● f11: Step in● shift-f11: Step out● f5: giddy up!

Page 11: Spaghetti gate

hit it!

Page 12: Spaghetti gate

when hit... make me a tracepoint!

Page 13: Spaghetti gate

demosuper-charging your breakpoints:

tracepointshit count

conditional breakpointslabeled breakpoints

Page 14: Spaghetti gate

tracepoints == cool;

● Allows you to get a ton of information about your execution flow, arguments and/or variables, etc, very quickly.

● Prevents trouble you may otherwise run into with timing issues caused by using breakpoints (like when debugging threading problems).

Page 15: Spaghetti gate

murphy's tipthe "fun" issues always seem to happen in production...

where tracepoints are not an option.

NOW WHAT???

Page 16: Spaghetti gate

logging == super-cool;

● Tracepoints are really just a means to set up really quick logging statements.

● Take the time to implement good logging... If your logs don't capture a problem, they're useless. If your logs capture so much information that your app slows to a crawl, they're worse than useless.

● Two popular tools to make logging easier:○ PostSharp AOP○ Log4Net

Page 17: Spaghetti gate

remote debuggingan extraordinarily powerful tool that so few take the

time to learn how to set up!

Page 18: Spaghetti gate

it's easier than it sounds

● Remote debugging is particularly useful for troubleshooting an issue occurring on your development webserver which you cannot replicate on your local machine

● Fairly easy to setup if both you and your webserver are on the same domain

● Run the "remote debugging monitor" on the server

● Your DLLs and PDB files must match exactly● Attach to process: w3wp.exe● Enjoy rockstar status!

Page 19: Spaghetti gate

what about the data??sometimes a crazy-funky problem you're facing is

being triggered by a bad state of your database

Page 20: Spaghetti gate

an ounce of prevention...

● At some point, your database will presumably be in a known good state. Make a backup at that time.

● Restore to that backup if things go wrong.● Make backups of known bad states to

troubleshoot issues... Or play pranks on team members.

Page 21: Spaghetti gate

ssms not installed... ruh-roh!

● sqlcmd to the rescue!● Command line utility to run quick queries to

check on potential data issues.● Also super useful for creating batch scripts to

run collections of SQL scripts.

Page 22: Spaghetti gate

databases can be complex!

● Use database diagrams in SSMS to get your mind wrapped around a database, or even just a portion of a database.

Page 23: Spaghetti gate

warning: small font ahead!

What follows is a list of resources to help you dig into a bunch of the tools covered or

mentioned today...

I would suggest grabbing this deck from slideshare.net/digipug, but do what ya gotta

do...

Page 24: Spaghetti gate

i'm hooked... i want more!Visual Studio Debugging from MSDN (general info from Microsoft):

http://bit.ly/18LdVBk

PostSharp AOP (logging and TONS more):

http://www.postsharp.net/purchase

Snoop (WPF debug assistant):

http://snoopwpf.codeplex.com/

Fiddler (web debug assistant):

http://fiddler2.com/

WPF debug converter & more (techniques):

http://bit.ly/16deQqe

Favorite Documents Extension (keeping track of classes related to a particular issue or feature):

http://bit.ly/12VMRav

Agent Ransack (kick-butt search tool):

http://www.mythicsoft.com/agentransack

Remote Debugging (you'll be a star when you set this up!):

http://bit.ly/1ceBqlb

Using Labels in TFS:

http://bit.ly/17NkCOG

sqlcmd:

http://bit.ly/15ptd9U