Please open Telegram to view this post
VIEW IN TELEGRAM
❤16👍1
Please open Telegram to view this post
VIEW IN TELEGRAM
❤13
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
1👍25❤18
This media is not supported in your browser
VIEW IN TELEGRAM
🔅 Fetch API in 4 Minutes (GET, POST, PUT, DELETE | JSON)
❤21👍2🔥2
Please open Telegram to view this post
VIEW IN TELEGRAM
❤13
Ex_Files_Learning_TypeScript.zip
481.2 KB
Please open Telegram to view this post
VIEW IN TELEGRAM
👍2
This is a snippet from JavaScript. This pattern of passing boolean params to methods is called a "Boolean trap", and let me explain why it's called so...
Imagine you are reading the method or function call. You have no idea what each param means unless you go and open the function definition. It's a big blow to readability 🤕
Better patterns would be to use a config object, where we clearly indicate what each field does. In other languages, you would use similar syntaxes, such as a builder pattern in Java.
☝️ Do note that it is still acceptable to use Boolean arguments in some places, such as
user.setAdmin(true)
Here we clearly know what the Boolean is doing, and so it is acceptable
Imagine you are reading the method or function call. You have no idea what each param means unless you go and open the function definition. It's a big blow to readability 🤕
Better patterns would be to use a config object, where we clearly indicate what each field does. In other languages, you would use similar syntaxes, such as a builder pattern in Java.
☝️ Do note that it is still acceptable to use Boolean arguments in some places, such as
user.setAdmin(true)
Here we clearly know what the Boolean is doing, and so it is acceptable
❤12👍3
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
❤14👍5