Describe the steps from writing code to execution in programming
Answers
Answer:
The wrong way:
- Write the entire program, every last class, method, etc., etc.
- Attempt to compile it.
- Discover that compiling the huge pile of code you just wrote is going to involve fixing dozens or possibly hundreds of syntax errors.
- Get it to the point it will at least compile.
- Run the executable. Something awful happens here. Could be a segfault, or just hanging. If you’re really lucky, it runs to completion, but doesn’t work correctly.
- Debug, debug, debug.
- Submit your homework.
- Discover three more bugs.
The right way:
- Pick a small piece of the overall functionality.
- If you want to strictly adhere to Test Driven Development (TDD), write a unit test that will exercise the code you are about to write. In this case, you’ll run the test and watch it fail because you haven’t written the code it’s testing yet. If you aren’t strict about TDD, you can swap this step with step 3.
- Write the code for this small piece of the functionality.
- Compile the code and the unit test.
- Run your unit test.
- If you’re like me, your unit tests fail at least some of the time on the first attempt, so fix the bug.
- Possibly write a new unit test or two in the process of debugging.
- Your code works. Repeat steps 1 through 7 until done.
The right way feels like it should take longer because you’re writing more code for the unit tests. The first time you do it, it probably will take longer. You’ll be learning the unit test framework you’re using. You’ll be learning testing strategies as well.
When you finish, your code is much more likely to be working correctly. You have tests for that. And once you get used to doing it, it speeds up the process. The simple reason is that each time through you are only working on bugs you’ve introduced with a small amount of new or changed code, and you have a suite of existing unit tests to ensure that you didn’t break what you’ve already written and debugged without knowing.
One of the hidden benefits of TDD is that making your code testable also makes it easier to understand. Code that is more modular is easier to test, and you’ll definitely be motivated to make your testing easier. The tests will represent your understanding of the requirements as well. You’ll almost certainly discover requirements that weren’t specified.
Explanation:
please mark my answer as brainliest