Ngoại lệ Cực kỳ Tốn kém… Hãy Làm Điều Này Thay Thế

Tác giả: Milan Jovanović
Ngày xuất bản: 2024-07-12T00:00:00
Length: 17:15

Want to master Clean Architecture? Go here: https://bit.ly/3PupkOJ

Want to unlock Modular Monoliths? Go here: https://bit.ly/3SXlzSt

Join a community of 1000+ .NET developers: https://www.patreon.com/milanjovanovic

How should you handle errors in your code? This has been a topic of many discussions, and I want to share my opinion. One school of thought suggests using exceptions for flow control. This is not a good approach because it makes the code harder to reason about. The caller must know the implementation details and which exceptions to handle. Exceptions are for exceptional situations. Exceptions are also costly and degrade performance. If you don't believe me, we'll prove it in this video.

GitHub thread: https://github.com/dotnet/aspnetcore/issues/46280#issuecomment-1527898867

Functional Error Handling in .NET With the Result Pattern

https://www.milanjovanovic.tech/blog/functional-error-handling-in-dotnet-with-the-result-pattern

Check out my courses:

https://www.milanjovanovic.tech/courses

Read my Blog here:

https://www.milanjovanovic.tech/blog

Join my weekly .NET newsletter:

https://www.milanjovanovic.tech

Chapters

0:00 Are exceptions expensive?

3:14 Exceptions for flow control

7:38 Performance testing exceptions

10:23 Handling errors with Result pattern

14:11 Performance testing Result pattern

15:30 Result pattern drawbacks

Dịch Vào Lúc: 2025-03-13T17:20:19Z

Yêu cầu dịch (Một bản dịch khoảng 5 phút)

Phiên bản 3 (ổn định)

Tối ưu hóa cho một người nói. Phù hợp cho video chia sẻ kiến thức hoặc giảng dạy.

Video Đề Xuất