Software Development Practices MCQs for the NSCT
Software development practices are the everyday habits that keep code working when a team changes it: version control with Git, clean and readable code, useful documentation, and code review. It is topic 16, the last of the 16 in the Programming (C++/Java/Python) area, which carries 10% of the NSCT according to HEC's Areas of Competencies. Candidates averaged 47.8% accuracy in this area in 2026, per the HEC NSCT report.
These questions reward practical experience. If you used Git for your FYP, you already know half the answers. The process side (SDLC models, agile, CI/CD pipelines) is covered in more depth under Software Engineering.
Git
Git is a distributed version control system: every clone holds the full history. Files move through three areas, the working directory, the staging area (index) and the repository. git add stages a snapshot, and git commit records whatever is staged.
| Command | What it does |
|---|---|
git status --short |
Shows ?? for untracked, A for added and M for modified files |
git switch -c feature |
Creates a branch and switches to it (git checkout -b is the older form) |
git merge feature |
Fast-forwards if possible, otherwise creates a merge commit |
git pull |
git fetch plus git merge (or a rebase, if configured) |
git revert <commit> |
Adds a new commit that undoes it; safe on shared branches |
git reset --soft/--mixed/--hard |
Moves the branch back; keeps changes staged, unstaged or discards them |
git stash |
Shelves uncommitted changes so the working tree is clean |
git cherry-pick <commit> |
Copies one commit onto the current branch with a new hash |
When both branches change the same line, a merge stops with conflict markers:
<<<<<<< HEAD
color = green
=======
color = blue
>>>>>>> feature
Exam angle: questions often ask what is in a commit after a file was edited again after git add. The answer is the staged version, not the latest edit. Also remember that .gitignore has no effect on files that are already tracked.
Clean code
Clean code is code that another person can read, change and test easily. The principles that come up most often are:
| Principle | Meaning |
|---|---|
| Meaningful names | days_since_borrowed, not d |
| DRY | Don't Repeat Yourself: one place for each piece of logic |
| KISS | Keep It Simple: prefer the plainest working design |
| YAGNI | You Aren't Gonna Need It: no speculative features |
| SRP | Single Responsibility: one reason for a class to change |
| No magic numbers | SECONDS_PER_DAY = 86400, not a bare 86400 |
Naming conventions differ by language. Python's PEP 8 uses snake_case for functions and variables. Java uses camelCase for methods and variables. Both use PascalCase for classes and UPPER_SNAKE_CASE for constants. A code smell such as a long method, duplicated code or a long boolean parameter list signals that the code needs refactoring: restructuring it without changing its behaviour.
Exam angle: a class with calculate(), print_pdf() and save_to_db() is the classic SRP violation.
Documentation
Documentation explains the code to its users and maintainers. It works at several levels: - Docstrings and Javadoc describe what a function does, its parameters and its return value. - Comments explain why the code does something non-obvious. - README files explain how to install, run and use a project.
def area(r):
"""Return the area of a circle of radius r."""
return 3.14159 * r * r
print(area.__doc__) # Return the area of a circle of radius r.
A comment that only restates the code adds noise. A comment that contradicts the code, such as # 10% discount above price * 0.85, is worse than none. Semantic versioning (MAJOR.MINOR.PATCH) also documents changes: a breaking change moves 2.4.1 to 3.0.0, a new compatible feature moves 1.9.3 to 1.10.0, and a bug fix moves 1.9.3 to 1.9.4.
Exam angle: expect a "what does a good comment explain?" question. The answer is the why, not the what.
Code review
In a code review, another developer reads a change, usually as a pull request, before it is merged. Its goals are to: - catch defects and security issues early, when they are cheapest to fix; - keep the code consistent with team standards; - spread knowledge of the codebase across the team.
Good review comments are specific and about the code, not the person. They also come with a reason, for example: "process(data, True, False) is hard to read; use keyword arguments." Reviews complement automated tests and continuous integration (CI), which builds and tests every change automatically. They do not replace them.
Exam angle: the purpose of a review is quality and shared knowledge, not counting lines or blaming the author.
Common traps
- Thinking
git commitincludes edits made aftergit add. It records the staged snapshot. - Confusing
git revert(a new undo commit) withgit reset(moving the branch back). - Expecting
.gitignoreto stop tracking a file that is already committed. Rungit rm --cachedfirst. - Rebasing a branch that teammates have already pulled.
- Believing a secret is gone once a later commit deletes it. It remains in history.
- Reading 1.10.0 as smaller than 1.9.3. Version parts are compared as separate numbers.
Worked examples
1. Understanding. What is the difference between forking and cloning a repository? Answer: a clone is a full local copy of a repository on your machine. A fork is a server-side copy made on a hosting platform such as GitHub, under your own account. You usually fork a project you cannot push to, clone your fork, and then open pull requests back to the original.
2. Application. In a repository with commits A and B, you run git reset --hard HEAD~1. How many commits does git log --oneline show, and what happens to B's changes?
Answer: one commit (A). --hard moves the branch back and also resets the staging area and working files, so B's changes disappear from the files. Until garbage collection, git reflog can still find B.
3. Analysis. In a pull request, a method named getStudents() returns the list of students and also deletes records older than five years. What should the reviewer flag?
Answer: a hidden side effect. The name promises a read-only query, so callers will not expect data to be deleted. Split it into getStudents() and purgeOldRecords(). This is command-query separation, and it also follows SRP.
Practise
The quiz below has 99 questions on software development practices, filterable by tier and difficulty.
Practise: 99 questions
FAQs
What is the difference between git merge and git rebase?
Merge joins two branches and keeps both histories, adding a merge commit when they have diverged. Rebase replays your commits on top of the other branch, giving a straight history but creating new commits with new hashes. Use rebase only on your own unpublished branches, and merge on shared ones.
What is the difference between git fetch and git pull?
git fetch downloads new commits and updates remote-tracking branches such as origin/main, but leaves your own branch and files untouched. git pull runs a fetch and then merges (or rebases) those commits into your current branch. Fetching first lets you inspect the changes before integrating them.
Do I need to memorise Git commands for the NSCT?
HEC lists software development practices as a topic but does not publish a command list. Know the core workflow well: init, add, commit, status, branch, switch, merge, pull, push, revert and reset. Understand what each one does to the working directory, the staging area and the history, rather than memorising flags.
Next step
You have reached the last Programming topic. Consolidate with the Programming revision notes, revisit the Programming MCQs hub, or test yourself in an NSCT mock test.