student Interview Question
StudentsCountry: United States
Interview Type: Written Test
This is more of an opinion base question.
When I program in any language (especially on non-object-oriented languages), I program my code piece by piece and make sure each parts works individually.
So first thing first:
1) Find out where the error(s) are occurring. If you have good coding practice, more of the time you should be dealing with not so many errors.
1a) When you have a function (classes too for other languages), make sure it works for all cases. It is very important.
1b) If any of your function (including your main) is >100 lines, you should ask yourself if you should simplify (break it down further?) it (well for smaller stuff probably go for smaller numbers)
2) fix everyone of your functions (especially the ones used by the features that is having error). (+ if you do it well, you don't have to go double/triple checking them)
3) check your main process.
That's what I usually do:
1) double check all the bugs and make sure what are the expect results. (if possible, ask people who wrote the code because they know the most how the system is expected to work)
2) trace code to the exactly point where bug happens to find the "reason" why it happens
3) make a plan of how should I fixed the bug and what kind of influence will happn in the system (think before doing it)
4) carefully fix the bug
5) test if the bug is fixed and also if other features are still ok
It's an open question. There are a lot of unknowns:
- Does it contain several functions each handling a functionality? I.e. is it modular?
- Does it load external libraries - version incompatibilities?
- Is it always failing in the same way? Is it easy to repro?
- Do you have access to documentation/requirements? Do they cover the failing scenario(s)?
- Can execute the various parts in isolation (perhaps writing some code) in order to unit test and isolate the issues?
There are two ways to debug as per me :
1. Live debugging (using tools like lauterbach, JTAG etc)
2. Simulators etc.
Using simulators, we can step into, step out and look at watch window , we are expecting the value.
Else we can use printf's and look at it.
But before looking at it, we have to surely look into the variables which we have used, the semicolons, if we have missed any pre-processors etc etc.
If you have lauterbach/ JTAG is becomes easy.
What are beakpoints and the so called Framework used for?
- hprem991 May 23, 2013IMO this is one word answer. Use Break point to debug the code flow and Fix it.