What should be the rules to write excellent code?

Click For Summary

Discussion Overview

The discussion revolves around the principles and rules for writing excellent code, applicable across various programming languages. Participants share their insights on best practices, methodologies, and concepts that contribute to high-quality code, including design principles, testing strategies, and documentation practices.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • Some participants mention rules such as avoiding pollution of the global namespace, adhering to SOLID principles, and following KISS (Keep It Simple, Stupid).
  • Test-driven development is proposed as a method to ensure components can be tested independently.
  • Functional programming is discussed as a way to simplify debugging and testing by eliminating side effects.
  • Participants emphasize the importance of detailed variable naming and documentation to enhance code readability and maintainability.
  • Some contributors suggest that the principles discussed are independent of programming languages, advocating for a focus on minimum, functional, and structured programming.
  • There is mention of design patterns and software requirements as essential concepts to understand in programming.
  • One participant argues against the use of 'goto' statements, while another defends their potential utility in certain advanced scenarios.
  • Several participants reference Steve McConnell's book "Code Complete" as a valuable resource for understanding coding best practices.

Areas of Agreement / Disagreement

Participants express a variety of viewpoints on coding principles, with some areas of agreement on the importance of documentation and testing. However, there is disagreement regarding the use of 'goto' statements, with differing opinions on their appropriateness in programming.

Contextual Notes

Some participants highlight the need for context-specific considerations when applying coding principles, noting that the KISS principle may evolve with experience. Additionally, there are references to specific programming practices that may depend on the language or project guidelines.

Who May Find This Useful

This discussion may be useful for software developers, programmers, and students interested in improving their coding practices and understanding various programming principles.

  • #31
Document, document, document.
Read through the requirement
Identify testable statements
Use a design methodology relevant to the task/project
Use a recognised standard for documentation and design toolset
Identify methods/objects at the design stage
Use a programming language relevant to the task.
Wherever possible reuse known working classes if OOD/OOP
or working modules if procedural design.
Ensure the smallest components are easily testable, build up a library of components that could be reused later
Test each class/procedure from the bottom up, increasing complexity as you go, ensuring that the system requirements continue to be met
Test
Test
Test
The aim of the exercise is to obtain a software system that is fit for purpose and does what is required.
 
  • Like
Likes   Reactions: Svein

Similar threads

  • · Replies 40 ·
2
Replies
40
Views
1K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 32 ·
2
Replies
32
Views
4K
  • · Replies 49 ·
2
Replies
49
Views
4K
Replies
47
Views
5K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 6 ·
Replies
6
Views
2K
Replies
10
Views
2K