CSSLP · Question #40
Which of the following coding practices are helpful in simplifying code? Each correct answer represents a complete solution. Choose all that apply.
The correct answer is A. Programmers should use multiple small and simple functions rather than a single complex function. B. Software should avoid ambiguities and hidden assumptions, recursions, and GoTo statements. C. Programmers should implement high-consequence functions in minimum required lines of code and. This question asks to identify coding practices that contribute to simplifying code, which inherently improves its readability, maintainability, and security.
Question
Which of the following coding practices are helpful in simplifying code? Each correct answer represents a complete solution. Choose all that apply.
Options
- AProgrammers should use multiple small and simple functions rather than a single complex function.
- BSoftware should avoid ambiguities and hidden assumptions, recursions, and GoTo statements.
- CProgrammers should implement high-consequence functions in minimum required lines of code and
- DProcesses should have multiple entry and exit points.
How the community answered
(51 responses)- A88% (45)
- D12% (6)
Why each option
This question asks to identify coding practices that contribute to simplifying code, which inherently improves its readability, maintainability, and security.
Using multiple small and simple functions instead of one large, complex function promotes modularity, making the code easier to understand, test, debug, and reuse.
Avoiding ambiguities, hidden assumptions, excessive use of recursion, and 'GoTo' statements leads to clearer, more predictable code flow, reducing complexity and making the code less prone to errors or security vulnerabilities.
Implementing high-consequence functions, which are critical to security or system integrity, in the minimum required lines of code reduces their complexity and attack surface, making them easier to review and verify for correctness.
Processes or functions should ideally adhere to structured programming principles, advocating for a single entry and single exit point to ensure predictable control flow and simplify debugging, rather than having multiple entry and exit points which increase complexity.
Concept tested: Secure coding best practices - code simplification
Source: https://owasp.org/www-project-secure-coding-guidelines/
Topics
Community Discussion
No community discussion yet for this question.