Тёмный

Java Best Practices: Avoiding Boolean Parameters for Cleaner Code - Explained with Examples 

Otavio Santana
Подписаться 1,7 тыс.
Просмотров 488
50% 1

Опубликовано:

 

29 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 8   
@jonascbamt
@jonascbamt 5 месяцев назад
Your example gives us more cohesive classes/method, and eliminates the if, this means improving the performance and readability of the code and helping when doing unit testing, I am studying this in the solid principle and I'm really enjoying it. I knew your chanel via Elder's chanel. Thanks man!
@otaviojava
@otaviojava 5 месяцев назад
Hey Jonas, I am super happy that you enjoyed it. Yes, this decrease a lot of complexity inside your code.
@mikaelmedeiros2646
@mikaelmedeiros2646 9 месяцев назад
Are u using copilot to assist on code?
@otaviojava
@otaviojava 9 месяцев назад
Yes, I am
@mikaelmedeiros2646
@mikaelmedeiros2646 9 месяцев назад
I have a question! It makes sense I'm wrote a method "speak" with a String parameter that receive "portguese" or "english" so I can use switch case? And that method call another speakEnglish() or speakPortuguese()? Because in this case, I'm encapsulating the methods and clearing the option of the method speak.
@otaviojava
@otaviojava 9 месяцев назад
The context will define it; for example, in our case, I had two languages with a super simple sentence. If I have more, I could use an enum that is more valid than a String, once I can put an invalid value in String, such as "Banana". If the logic became more complex, I could use the Strategy pattern, thus, a Language interface with some implementations.
@mukulkopulwar
@mukulkopulwar 9 месяцев назад
Thanks for sharing 😊
@otaviojava
@otaviojava 9 месяцев назад
My pleasure 😊
Далее
Офицер, я всё объясню
01:00
Просмотров 4,1 млн
Java Logs: Logging Best Practices
8:15
Просмотров 397
🚀 Java 11 to 21: Upgrade Unveiled! 🔄
0:59
17 Passing Parameters to Functions
4:26
Просмотров 21