Error Handling: Separating from Code for Easier Maintenance

  • Thread starter Thread starter 0rthodontist
  • Start date Start date
  • Tags Tags
    Error
Click For Summary

Discussion Overview

The discussion revolves around the challenges and methodologies of separating error handling from main code in programming. Participants explore theoretical and practical aspects of error handling, including its impact on code readability and maintainability, as well as various strategies for managing errors effectively.

Discussion Character

  • Debate/contested
  • Technical explanation
  • Conceptual clarification

Main Points Raised

  • Some participants argue that error handling can obfuscate code and detract from its readability, suggesting that it should be separated from the main logic.
  • Others contend that certain errors must be handled within the main algorithm to maintain code locality, and that separating error handling could complicate understanding the code's behavior.
  • A participant mentions that validation of arguments and contractual assertions can help clean up error handling by grouping checks at the beginning or end of code blocks.
  • There is a suggestion that using editor features to fold error handling code could improve readability, although some express dissatisfaction with current folding capabilities.
  • One participant shares a perspective that error handling should not be used as program control but rather for exceptional cases, advocating for a design where the main code is written first and errors are patched later.
  • Another participant challenges this view, arguing that understanding failure modes is crucial for good programming and that separating error handling could hinder comprehension of the code's overall function.
  • Some participants propose that a clear distinction between mainstream and special case code could enhance code organization and facilitate easier modifications.

Areas of Agreement / Disagreement

Participants express differing opinions on the separation of error handling from main code, with no consensus reached. Some advocate for separation to enhance readability, while others emphasize the importance of maintaining code locality and understanding failure modes.

Contextual Notes

The discussion highlights various assumptions about programming practices, including the effectiveness of different error handling strategies and the role of design foresight in coding. Limitations in current editor features for managing error handling are also noted.

  • #31
0rthodontist said:
Have you ever seen any programmer make use of this commenting style you are describing? If you're referring to the takes/alters syntax from another thread, I made it extremely clear that it would need to be automatically generated, and that in fact that was part of the point, so that it would provide documentation that a programmer might not have created on his own.

You're the one claiming that this coding style with "separated" error handling is superior to simply having the error-handling intermingled with the code it protects -- not me. I have never seen anyone besides you argue that this would be a good idea, so no, I have never seen anyone else do it.

- Warren
 
Technology news on Phys.org
  • #32
Chroot, were you actually talking about the takes/alters syntax in the other thread as I thought in my last post?
 

Similar threads

  • · Replies 40 ·
2
Replies
40
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
6
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
9K
  • · Replies 1 ·
Replies
1
Views
3K