Debugging: Difference between revisions

From Computer Science Wiki
No edit summary
No edit summary
Line 2: Line 2:


This is a problem set. Some of these are easy, others are far more difficult. The purpose of these problems sets are to HELP YOU THINK THROUGH problems. The solution is at the bottom of this page, but please don't look at it until you have tried (and failed) at least three or four times.  
This is a problem set. Some of these are easy, others are far more difficult. The purpose of these problems sets are to HELP YOU THINK THROUGH problems. The solution is at the bottom of this page, but please don't look at it until you have tried (and failed) at least three or four times.  
== Terminology ==
In computers, debugging is the process of locating and fixing or bypassing bugs (errors) in computer program code or the engineering of a hardware device. To debug a program or hardware device is to start with a problem, isolate the source of the problem, and then fix it. A user of a program that does not know how to fix the problem may learn enough about the problem to be able to avoid it until it is permanently fixed. When someone says they've debugged a program or "worked the bugs out" of a program, they imply that they fixed it so that the bugs no longer exist.<ref>http://searchsoftwarequality.techtarget.com/definition/debugging</ref>
Debugging is the process of finding and resolving of defects that prevent correct operation of computer software or a system. Debugging tends to be harder when various subsystems are tightly coupled, as changes in one may cause bugs to emerge in another.<ref>https://en.wikipedia.org/wiki/Debugging#Typical_debugging_process</ref>




== What is this problem set trying to do ==
== What is this problem set trying to do ==
In computers, debugging is the process of locating and fixing or bypassing bugs (errors) in computer program code or the engineering of a hardware device. To debug a program or hardware device is to start with a problem, isolate the source of the problem, and then fix it. A user of a program that does not know how to fix the problem may learn enough about the problem to be able to avoid it until it is permanently fixed. When someone says they've debugged a program or "worked the bugs out" of a program, they imply that they fixed it so that the bugs no longer exist.<ref>http://searchsoftwarequality.techtarget.com/definition/debugging</ref>


'''You are going to create errors when you code!''' There is a process to follow when you are debugging. I expect EVERY student to follow these steps when you are debugging. The purpose of this problem set is to encourage you to understand and apply your understanding of the debugging process to your code (and the code of a classmate).  
'''You are going to create errors when you code!''' There is a process to follow when you are debugging. I expect EVERY student to follow these steps when you are debugging. The purpose of this problem set is to encourage you to understand and apply your understanding of the debugging process to your code (and the code of a classmate).  

Revision as of 08:06, 7 April 2016

This a problem set for you to work through [1]

This is a problem set. Some of these are easy, others are far more difficult. The purpose of these problems sets are to HELP YOU THINK THROUGH problems. The solution is at the bottom of this page, but please don't look at it until you have tried (and failed) at least three or four times.

Terminology[edit]

In computers, debugging is the process of locating and fixing or bypassing bugs (errors) in computer program code or the engineering of a hardware device. To debug a program or hardware device is to start with a problem, isolate the source of the problem, and then fix it. A user of a program that does not know how to fix the problem may learn enough about the problem to be able to avoid it until it is permanently fixed. When someone says they've debugged a program or "worked the bugs out" of a program, they imply that they fixed it so that the bugs no longer exist.[2]

Debugging is the process of finding and resolving of defects that prevent correct operation of computer software or a system. Debugging tends to be harder when various subsystems are tightly coupled, as changes in one may cause bugs to emerge in another.[3]


What is this problem set trying to do[edit]

You are going to create errors when you code! There is a process to follow when you are debugging. I expect EVERY student to follow these steps when you are debugging. The purpose of this problem set is to encourage you to understand and apply your understanding of the debugging process to your code (and the code of a classmate).

The Problem[edit]

You should write a program that asks a user to enter an email address. Your program should check if the email:

  1. has an @ sign
  2. has a period .
  3. has a common top level domain (org, com)

Some Code to Get You Started[edit]

email = raw_input("Enter your email ")

Take This Further[edit]

  1. you can test for a @ and a . Could you also test for common misspellings?
  2. if you can test for common misspellings, could you suggest the correct spelling?
  3. we can check for common .com, .org, addresses but what about other top level domain names click here for a fairly scary list of them

How you will be assessed[edit]

Every problem set is a formative assignment. Please click here to see how you will be graded

References[edit]

See also[edit]

a short paper on the debugging process

A possible solution[edit]

Click the expand link to see one possible solution, but NOT before you have tried and failed at least three times

top_level_domains = ['com', 'org', 'pl', 'kz', 'edu']


while True:
    email = raw_input("Enter you email ")
    if '@' not in email:
        print("Error: you need an @ sign in your email.")
        break
    elif '.' not in email:
        print("Error: you need a . sign in your email. Please try again")    
        break
    # I am grateful to my student Sneha for this line below. It is a succinct way of capturing the characters AFTER the period.
    elif email[email.index('.')+1:] not in top_level_domains:
        print("Error: you need a valid domain name at the end")    
    else:
        print("Success: the email address you entered has passed our basic validation tests.") 
        break