4
Writing, Debugging, and Testing Functions
This chapter is about writing functions to reuse code, debugging logic errors during development, logging exceptions during runtime, unit testing your code to remove bugs, and improving stability and reliability.
This chapter covers the following topics:
- Writing functions
- Debugging during development
- Hot reloading during development
- Logging during development and runtime
- Unit testing
- Throwing and catching exceptions in functions
Writing functions
A fundamental principle of programming is Don’t Repeat Yourself (DRY).
While programming, if you find yourself writing the same statements over and over again, then turn those statements into a function. Functions are like tiny programs that complete one ...
Get C# 12 and .NET 8 – Modern Cross-Platform Development Fundamentals - Eighth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.