Building Rock-Solid Software Nikolay Kostov Telerik Software Academy academy.telerik.com Senior Software Developer and Technical Trainer

Slides:



Advertisements
Similar presentations
Windows Basic and Dynamic Disk Borislav Varadinov Telerik Software Academy academy.telerik.com System Administrator Marian Marinov CEO of 1H Ltd.
Advertisements

Make swiftly iOS development Telerik Academy Telerik Academy Plus.
Amazon S 3, App Engine Blobstore, Google Cloud Storage, Azure Blobs Svetlin Nakov Telerik Software Academy academy.telerik.com.
RPN and Shunting-yard algorithm Ivaylo Kenov Telerik Software Academy academy.telerik.com Technical Assistant
Shortest paths in edge-weighted digraph Krasin Georgiev Technical University of Sofia g.krasin at gmail com Assistant Professor.
Telerik Software Academy Telerik School Academy.
Asynchronous Programming with C# and WinRT
Unleash the Power of JavaScript Tooling Telerik Software Academy End-to-end JavaScript Applications.
Touch and Gestures with Xamarin Forms
Telerik School Academy ASP.NET MVC.
Character sequences, C-strings and the C++ String class, Working with Strings Learning & Development Team Telerik Software Academy.
Hybrid or Native?! Doncho Minkov Telerik Software Academy Senior Technical Trainer
Done already for your convenience! Telerik School Academy Unity 2D Game Development.
Processing Sequences of Elements Telerik School Academy C# Fundamentals – Part 1.
C# Fundamentals – Part I
Telerik Software Academy Telerik School Academy Creating E/R Diagrams with SQL Server.
The Business Plan and the Business Model Margarita Antonova Volunteer Telerik Academy academy.telerik.com Business System Analyst Telerik Corporation.
Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training About the Course.
What are ADTs, STL Intro, vector, list, queue, stack Learning & Development Team Telerik Software Academy.
Making JavaScript code by template! Learning & Development Team Telerik Software Academy.
Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training Who, What, Why?
Svetlin Nakov Telerik Software Academy Manager Technical Training
Marketing Mix, SWOT Analysis and Stages of Developing an Idea Margarita Antonova Volunteer Telerik Academy academy.telerik.com Business System.
Access to known folders, using pickers, writing to and reading from files, caching files for future access George Georgiev Telerik Software Academy academy.telerik.com.
Learning & Development Telerik Software Academy.
Reading and Writing Text Files Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Telerik Software Academy ASP.NET Web Forms.
Classical OOP in JavaScript Classes and stuff Telerik Software Academy
Optimization problems, Greedy Algorithms, Optimal Substructure and Greedy choice Learning & Development Team Telerik Software.
Using Selenium for Mobile Web Testing Powered by KendoUI Telerik QA Academy Atanas Georgiev Senior QA Engineer KendoUI Team.
New features: classes, generators, iterators, etc. Telerik Academy Plus JavaScript.Next.
Creating E/R Diagrams with SQL Server Management Studio and MySQL Workbench Svetlin Nakov Telerik Software Academy Manager Technical.
Throwing and Catching Exceptions Tran Anh Tuan Edit from Telerik Software Academy
Debugging Building Rock-Solid Software Software University Technical Trainers SoftUni Team.
Loops, Conditional Statements, Functions Tran Anh Tuan Edit from Telerik Academy
Private/Public fields, Module, Revealing Module Learning & Development Team Telerik Software Academy.
Building Data-Driven ASP.NET Web Forms Apps Telerik Software Academy ASP.NET Web Forms.
Course Introduction Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
Nikolay Kostov Telerik Software Academy Senior Software Developer and Trainer
Telerik Software Academy End-to-end JavaScript Applications.
General and reusable solutions to common problems in software design Vasil Dininski Telerik Software Academy academy.telerik.com Intern at Telerik Academy.
Planning and Tracking Software Quality Yordan Dimitrov Telerik Corporation Team Leader, Team Pulse, Team Leader, Team Pulse, Telerik Corporation,
What you need to know Ivaylo Kenov Telerik Corporation Telerik Academy Student.
Data binding concepts, Bindings in WinJS George Georgiev Telerik Software Academy academy.telerik.com Technical Trainer itgeorge.net.
Pavel Kolev Telerik Software Academy Senior.Net Developer and Trainer
Objects, Properties, Primitive and Reference Types Learning & Development Team Telerik Software Academy.
When and How to Refactor? Refactoring Patterns Alexander Vakrilov Telerik Corporation Senior Developer and Team Leader.
Free Training and Job for Software Engineers Svetlin Nakov, PhD Manager Technical Training Telerik Corp. Telerik Software Academy.
Free Training and Job for Software Engineers Svetlin Nakov, PhD Manager Technical Training Telerik Corp. Telerik Software Academy.
Access to known folders, using pickers, writing to and reading from files, caching files for future access George Georgiev Telerik Software Academy academy.telerik.com.
Doing the Canvas the "easy way"! Learning & Development Telerik Software Academy.
Creating and Running Your First C# Program Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
Course Overview Doncho Minkov Telerik Software Academy Technical Trainer
Correctly Formatting the Source Code Nikolay Kostov Telerik Software Academy academy.telerik.com Senior Software Developer and Technical Trainer
Data Types, Primitive Types in C++, Variables – Declaration, Initialization, Scope Telerik Software Academy academy.telerik.com Learning and Development.
The past, the present, the future Learning & Development Team Telerik Software Academy.
Learn to Design Error Steady Code Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Connecting, Queries, Best Practices Tran Anh Tuan Edit from Telerik Software Academy
Processing Sequences of Elements Telerik Software Academy C# Fundamentals – Part 2.
Telerik JavaScript Framework Telerik Software Academy Hybrid Mobile Applications.
Telerik Software Academy Databases.
Things start to get serious Telerik Software Academy JavaScript OOP.
Learning & Development Mobile apps for iPhone & iPad.
Processing Matrices and Multidimensional Tables Telerik Software Academy C# Fundamentals – Part 2.
Nikolay Kostov Telerik Software Academy academy.telerik.com Team Lead, Senior Developer and Trainer
Functions and Function Expressions Closures, Function Scope, Nested Functions Telerik Software Academy
Implementing Control Logic in C# Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical trainer
Mocking tools for easier unit testing Telerik Software Academy High Quality Code.
What why and how? Telerik School Academy Unity 2D Game Development.
Windows Security Model Borislav Varadinov Telerik Software Academy academy.telerik.com System Administrator
Presentation transcript:

Building Rock-Solid Software Nikolay Kostov Telerik Software Academy academy.telerik.com Senior Software Developer and Technical Trainer

 Introduction to Debugging  Visual Studio Debugger  Breakpoints  Data Inspection  Finding a Defect 2

 The process of locating and fixing or bypassing bugs (errors) in computer program code  To debug a program:  start with a problem  isolate the source of the problem  fix it  Debugging tools (called debuggers) help identify coding errors at various development stages

 Testing  A means of initial detection of errors  Debugging  A means of diagnosing and correcting the root causes of errors that have already been detected 5

 $60 Billion per year in economic losses due to software defects  Perfect code is an illusion  There are factors that are out of our control  Legacy code  You should be able to debug code that is written years ago  Deeper understanding of system as a whole 6

 Debugging can viewed as one big decision tree  Individual nodes represent theories  Leaf nodes represent possible root causes  Traversal of tree boils down to process state inspection  Minimizing time to resolution is key  Careful traversal of the decision tree  Pattern recognition  Visualization and easy of use helps minimize time to resolution 7

8 OutOfMemoryException Native Heaps? Virtual?.NET Heaps?.NET Types? Native? Native Heaps? Long references?

 Visual Studio IDE gives us a lot of tools to debug your application  Adding breakpoints  Visualize the program flow  Control the flow of execution  Data tips  Watch variables  Debugging multithreaded programs  and many more…

 Starting a process under the Visual Studio debugger  Attaching to an already running process  Without a solution loaded you can still debug  Useful when solution isn't readily available  Debug menu -> Attach to Process 11

 Debug menu, Start Debugging item  F5 is a shortcut  Easier access to the source code and symbols since its loaded in the solution  Certain differences exist in comparison to debugging an already running process  Hosting for ASP.NET application  VS uses a replacement of the real IIS 12

 Debug Windows are the means to introspect on the state of a process  Opens a new window with the selected information in it  Window categories  Data inspection  Threading  Accessible from menu  Debug -> Windows

 Convenient shortcut to common debugging tasks  Step into  Step over  Continue  Break  Breakpoints  Customizable to fit your needs  Add and/or remove buttons 14

 By default, an app will run uninterrupted (and stop on exception or breakpoint)  Debugging is all about looking at the state of the process  Controlling execution allows:  Pausing execution  Resuming execution  Stepping through the application in smaller chunks  In the case of IntelliTrace (recording steps), allows backward and forward stepping 15

 IntelliTrace operates in the background, records what you are doing during debugging  You can easily get a past state of your application from intelliTrace  You can navigate your code with any part and see what’s happened  To navigate, just click any of the events that you want to explore 16

 Visual Studio offers quite a few knobs and tweaks in the debugging experience  Options and settings is available via Debug -> Options and Settings  Examples of Options and Settings  Enable just my code (ignore other code)  Enable.NET framework source stepping  Source server support  Symbols (line numbers, variable names)  Much more… 17

 Ability to stop execution based on certain criteria is key when debugging  When a function is hit  When data changes  When a specific thread hits a function  much more  Visual Studio debugger has a huge feature set when it comes to breakpoints

 Stops execution at a specific instruction (line of code)  Can be set using Debug->Toggle breakpoint  F9 shortcut  Clicking on the left most side of the source code window  By default, the breakpoint will hit every time execution reaches the line of the code  Additional capabilities: condition, hit count, value changed, when hit, filters 20

 Managed in the breakpoint window  Adding breakpoints  Removing or disabling breakpoints  Labeling or grouping breakpoints  Export/import breakpoints 21

 Allows you to excerpt even more control of when a breakpoint hits  Examples of customization  Machine name  Process ID  Process name  Thread ID  Thread name  Multiple can be combined using &, ||, ! 22

 Debugging is all about data inspection  What are the local variables?  What is in memory?  What is the code flow?  In general - What is the state of the process right now and how did it get there?  As such, the ease of data inspection is key to quick resolution of problems

 Visual Studio offers great data inspection features  Watch windows  Autos and Locals  Memory and Registers  Data Tips  Immediate window 25

 Allows you to inspect various states of your application  Several different kinds of “predefined” watch windows  Autos  Locals  “Custom” watch windows also possible  Contains only variables that you choose to add  Right click on the variable and select “Add to Watch” 26

 Locals watch window contains the local variables for the specific stack frame  Debug -> Windows -> Locals  Displays: name of the variable, value and type  Allows drill down into objects by clicking on the + sign in the tree control  Autos lets the debugger decide which variables to show in the window  Loosely based on the current and previous statement 27

 Memory window can be used to inspect process wide memory  Address field can be a raw pointer or an expression  Drag and drop a variable from the source window  Number of columns displayed can be configured  Data format can be configured  Registers window can be used to inspect processor registers 28

 Provides information about variables  Variables must be within scope of current execution  Place mouse pointer over any variable  Variables can be expanded by using the + sign  Pinning the data tip causes it to always stay open  Comments can be added to data tips  Data tips support drag and drop  Importing and exporting data tips 29

 Useful when debugging due to the expansive expressions that can be executed  To output the value of a variable  To output the value of a variable  To set values, use =  To set values, use =  To call a method, use. (arguments)  Similar to regular code  Supports Intellisense 30

 Fundamental unit of code execution  Commonly, more than one thread .NET, always more than one thread  Each thread has a memory area associated with it known as a stack used to  Store local variables  Store frame specific information  Memory area employs last in first out semantics 32

 Contains an overview of thread activity in the process  Includes basic information in a per thread basis  Thread ID’s  Category  Name  Location  Priority 33

 A threads stack is commonly referred to as a callstack  Visual Studio shows the elements of a callstack  Local variables  Method frames 34

1.Stabilize the error 2.Locate the source of the error a)Gather the data b)Analyze the data and form hypothesis c)Determine how to prove or disprove the hypothesis d)Prove or disprove the hypothesis by 2c 3.Fix the defect 4.Test the fix 5.Look for similar errors 36

 Use all available data  Refine the test cases  Check unit tests  Use available tools  Reproduce the error several different ways  Generate more data to generate more hypotheses  Use the results of negative tests  Brainstorm for possible hypotheses 37

 Narrow the suspicious region of the code  Be suspicious of classes and routines that have had defects before  Check code that’s changed recently  Expand the suspicious region of the code  Integrate incrementally  Check for common defects  Talk to someone else about the problem  Take a break from the problem 38

 Understand the problem before you fix it  Understand the program, not just the problem  Confirm the defect diagnosis  Relax  Save the original source code  Fix the problem not the symptom  Make one change at a time  Add a unit test that expose the defect  Look for similar defects 39 Source:

 Your ego tells you that your code is good and doesn't have a defect even when you've seen that it has one.  How "Psychological Set" Contributes to Debugging Blindness 40

форум програмиране, форум уеб дизайн курсове и уроци по програмиране, уеб дизайн – безплатно програмиране за деца – безплатни курсове и уроци безплатен SEO курс - оптимизация за търсачки уроци по уеб дизайн, HTML, CSS, JavaScript, Photoshop уроци по програмиране и уеб дизайн за ученици ASP.NET MVC курс – HTML, SQL, C#,.NET, ASP.NET MVC безплатен курс "Разработка на софтуер в cloud среда" BG Coder - онлайн състезателна система - online judge курсове и уроци по програмиране, книги – безплатно от Наков безплатен курс "Качествен програмен код" алго академия – състезателно програмиране, състезания ASP.NET курс - уеб програмиране, бази данни, C#,.NET, ASP.NET курсове и уроци по програмиране – Телерик академия курс мобилни приложения с iPhone, Android, WP7, PhoneGap free C# book, безплатна книга C#, книга Java, книга C# Николай Костов - блог за програмиране

 C# Telerik Academy  csharpfundamentals.telerik.com csharpfundamentals.telerik.com  Telerik Software Academy  academy.telerik.com academy.telerik.com  Telerik Facebook  facebook.com/TelerikAcademy facebook.com/TelerikAcademy  Telerik Software Academy Forums  forums.academy.telerik.com forums.academy.telerik.com