Courses / HEC NSCT – National Skill Competency Test: Complete Preparation for Computing Graduates
2.5 Code Tracing, Debugging and Good Practice
Area 2 – Programming (C++ / Java / Python) (10%) · 40 min read · 12 MCQs to check yourself
Output-prediction checklist
- Note the language – integer division and indexing rules differ.
- Build a trace table for loop variables.
- Watch for
break/continue,switchfall-through and++/--. - In Python, remember mutable default arguments and that lists are passed by reference.
Good programming practice
- Meaningful names, small functions, comments that explain why.
- DRY – Don't Repeat Yourself. KISS – Keep It Simple.
- Version control with Git (
commit,branch,merge,pull request). - Unit tests for each function; code review before merging.
- Compiled languages (C++) translate the whole program to machine code; Java compiles to bytecode run by the JVM; Python is interpreted (bytecode run by the Python virtual machine).
- Basic concurrency: a thread is a lightweight unit of execution; shared data needs synchronisation (
synchronizedin Java, locks in Python).
Tracing code by hand (Chris Mayfield)
This lesson ends with a quiz of 12 MCQs. Open the lesson on PrepOasis to take it and save your progress.
Previous: 2.4 Memory Management and Exception Handling · Next: Area 2 Review, Checklist and Area Test