Giter VIP home page Giter VIP logo

07-debugging-in-ruby's Introduction

Debugging in ruby

What is debugging?

From Techopedia:

'Debugging is the routine process of locating and removing computer program bugs, errors or abnormalities, which is methodically handled by software programmers via debugging tools. Debugging checks, detects and corrects errors (or "bugs") to allow proper program operation, according to set specifications...Normally, software contains errors and bugs, which are routinely removed. In the debugging process, complete software programs are regularly compiled and executed to identify and rectify issues. Large software programs, which contain millions of source code lines, are divided into small components. For efficiency, each component is debugged separately at first, followed by the program as a whole. In general, the way that debugging works depends on the global testing strategies that are chosen.'

In other words...

Debugging is the science of investigating and solving code problems through accessible debugging tools.

Why is debugging important?

We use debugging to determine why applications and programs are not behaving as expected.

Best processes for debugging:

  • Consider the goal of the code
  • What is the expected behavior?
  • What are all the components that make up this behavior?
  • What does the error/stack trace say?
  • What can we assume about the error?
  • Think about how to debug each assumption
  • Debug and repeat until an assumption is true

Testing vs debugging

Testing (rspec) and debugging are like the ying and yang of programming. They complete each other but are not the same thing. They compliment one another. Testing is used to identify what could go wrong if errors are made in the code base. Debugging is to find the error and solve it.

Common coding errors:

  • Syntax error
  • Runtime error
  • Semantic error
  • Logic error
  • Not following code conventions
  • NoMethodError
  • Using the wrong variable name in the wrong place
  • Undefined variables
  • undefined method 'some_method' for nil:NilClass

Challenges of debugging

  • Debugging will take more time than writing the code.
  • Challenges that can arise:
    • The cause of the bug is not so apparent, but the program is breaking.
    • Fix one part, break another.

Debugging tools:

  • Puts
  • Pry
  • Rake Console

07-debugging-in-ruby's People

Contributors

aisayo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.