Тёмный

3 Ways to AVOID Hard Coded Strings | C#, DotNet 

About Clean Code
Подписаться 4,2 тыс.
Просмотров 1,3 тыс.
50% 1

Let's quickly discuss 3 different design approaches to avoid hard coded strings in our code bases.
OneOf library: github.com/mcintyre321/OneOf

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

 

28 май 2023

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 3   
@CRBarchager
@CRBarchager Год назад
I've used an Enum for things like a MailType where the values could be Daily, Weekly, Monthly and then compared the ToString() of that enum with the string value that was passed to the function. It might not be as effecient as other ways of doing it but it does make the code readable and easily to understand. I also removed a sh*t load of magic strings with the nameof(Classname.PropertyName). That wasn't as easy to read afterwards but made it much easier to refactor the class later on.
@StevenHartgers
@StevenHartgers Год назад
Definitely Enum or Int, much faster on the CPU. A bad example of everything(!) being a string is the "yandere simulator code meme", which is horrible to maintain. Luckily the CLR interns constant strings and compares the string address before comparing the value, thus speeds things up.
Далее
Dependency Inversion: What, Why & How? | By Example
12:17
That's NOT How Async And Await Works in .NET!
12:25
Просмотров 17 тыс.
ШАР СКВОЗЬ БУТЫЛКУ (СКЕРЕТ)
00:46
I SIMULATED THIS EURO 2024 GAME.. 🤯
00:13
Просмотров 1,7 млн
🎙️ПЕСНИ ВЖИВУЮ от КВАШЕНОЙ💖
3:23:13
How I Would Learn To Code (If I Could Start Over)
13:43
Don't throw exceptions in C#. Do this instead
18:13
Просмотров 251 тыс.
A Simpler Way to See Results
19:17
Просмотров 98 тыс.
All Rust string types explained
22:13
Просмотров 151 тыс.
Use Arc Instead of Vec
15:21
Просмотров 137 тыс.
Design Self-documenting Types to Avoid Bugs
13:23
Просмотров 2,7 тыс.
How to use Discriminated Unions Today in C#
17:09
Просмотров 59 тыс.
ШАР СКВОЗЬ БУТЫЛКУ (СКЕРЕТ)
00:46