ENG 213.1 · Computer Programming for Engineers
Our notes
1 min readWhy code security matters to engineers
Engineering programs control machines and produce design figures. A program that accepts bad input, is changed without record, or is lost, can cause unsafe designs, wrong reports or plant failures.
Validate input
- Check ranges and types: a negative diameter, zero thickness or a letter where a number is expected should give a clear message, not a crash or a silly answer.
if (d <= 0.0) then
print *, 'Diameter must be positive'
stop
end if
- Check iostat on reads and opens.
Protect against errors in calculations
Avoid division by zero and square roots of negatives; limit iterations; use double precision where accuracy matters; check results against simple limits.
Keep code and data safe
- Backups: at least one copy away from your laptop (flash drive or cloud storage).
- Version control (for example Git): every change is recorded with who made it and why; you can go back to a working version.
- Access control: passwords and permissions on shared computers; do not leave sensitive data (client designs, personal data) in public folders.
- Malware: only install compilers and libraries from official sources; scan flash drives.
- Hard-coded secrets: never put passwords or keys inside program files that others may see.
Integrity and ownership
- Licences: respect the licence of code you reuse; credit the author. Copying a classmate's assignment is academic misconduct.
- Documentation: a header comment with the author, date, purpose, units and method; comments explaining non-obvious steps.
Maintainable code
- Meaningful names and consistent indentation.
- IMPLICIT NONE always.
- Named constants instead of "magic numbers" (g = 9.81 declared once).
- Small procedures, each doing one job.
- A test case with a known answer kept with the program.
Safety-critical programs
Software that controls machines (PLCs, robots, lifts) must be tested, reviewed and have safe fail states: if a sensor reading is impossible, stop the machine safely rather than carry on.
Exams usually ask
- Explain what is meant by computer code security and how to achieve it.
- List good programming practices.
Common mistake
Thinking security only means passwords. For engineering code it also means correct input checks, a record of changes and safe behaviour when things go wrong.
Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.
Read
-
Secure coding
(opens en.wikipedia.org in a new tab)
Wikipedia, Secure coding, CC BY-SA 4.0 · licence
-
Coding conventions
(opens en.wikipedia.org in a new tab)
Wikipedia, Coding conventions, CC BY-SA 4.0 · licence
Watch
-
Best pick Fortran Programming Course - Installation
5 min · ≈ 23 MB · about ₦13
(opens youtube.com in a new tab)
-
Why You MUST Learn FORTRAN in 2025
8 min · ≈ 36 MB · about ₦20
(opens youtube.com in a new tab)
-
Fortran Program to Find Root of a Number | Lecture 4 | Fortran Programming Tutorial
6 min · ≈ 27 MB · about ₦15
(opens youtube.com in a new tab)
-
2. Programming with modern FORTRAN. Writing your first program
6 min · ≈ 27 MB · about ₦15
(opens youtube.com in a new tab)
We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.