Exceptions Are Your Friends

Photo by Nong Vang on Unsplash

When We Throw Exception

1 — Changing the Exception Type

2 — Unprocessable State

3 — Unexpected Situation

Throwing Exception vs Returning Operation Result

Disadvantages of Returning Operation Result

Disadvantages of Throwing Exception

  • When we work with an existing city (CityId = 1), our service structure that uses exception works with a slightly better performance. This is because it deals with less control blocks.
  • When we make a transaction with a city that does not exist (CityId = 0), it takes much more time to complete our transaction due to the cost of throwing an exception object.

--

--

--

var software = ConvertFrom(caffeine)

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

My CS College Degree in 5 Minutes

Why do you need a framework when doing test automation?

Under the Hood with Solidity Reference Types

🎊 𝐖𝐞𝐥𝐜𝐨𝐦𝐞 𝐭𝐨 𝐌𝐨𝐨𝐧𝐂𝐢𝐭𝐲 🎊

Calculating mathematical range in python for pandas describe

Python Libraries for Mesh, Point Cloud, and Data Visualization (Part 1)

Laravel Facade — I can do it too!

Week 18 Retrospective

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adem Catamak

Adem Catamak

var software = ConvertFrom(caffeine)

More from Medium

Flow-Control in C#

Clean Coding: Step One

Debugging into NuGet packages

Troubleshooting CORS Errors