Magic Numbers sind Zahlen (oder auch Strings), die irgendwo im Code „einfach so“ stehen und deren Bedeutung man nur errät. Du siehst dann `60`, `3`, `1024` oder `"admin"` und musst aus dem Kontext heraus rekonstruieren, *warum genau dieser Wert* dort steht. Zahlen im Code sind nicht per se schl

https://magicmarcy.de/wenn-zahlen-luegen-magic-numbers-sauber-ersetzen

#MagicNumbers #Konstanten #Enums #Java #Programming #MagicStrings #Bedeutung #Dokumentation #Fachlichkeit

Wenn Zahlen lügen: Magic Numbers sauber ersetzen | magicmarcy.de

Magic Numbers sind Zahlen (oder auch Strings), die irgendwo im Code „einfach so“ stehen und deren Bedeutung man nur errät. Du siehst dann `60`, `3`, `1024` oder `"admin"` und musst aus dem Kontext heraus rekonstruieren, *warum genau dieser Wert* dort steht. Zahlen im Code sind nicht per se schlecht. Schlecht wird es, wenn die Zahl eine fachliche oder technische Bedeutung trägt, diese Bedeutung aber nicht sichtbar ist.

magicmarcy.de

Modern Enums Battle: Python 3.10 vs PHP 8.1!

Both languages just added enums! Python's Enum class vs PHP's native enums - which implementation wins? This is HUGE!

#python #php #pythonvsphp #enums #python3.10 #php8.1 #modernfeatures #codecomparison #programmingcomparison #pythontricks #phptricks #programmingdebate #codingtips #typesafety #enummethods

https://www.youtube.com/watch?v=Fn5YHr3lDq0

Modern Enums Battle: Python 3.10 vs PHP 8.1! #modernfeatures

YouTube

For the gophers out there... Just a reminder: a bunch of consts + iota isn't an enum. Slugs aren’t enums. Interfaces, structs, and switch statements aren’t enums either.

Enums are enums.

Scala went through the same BS for what felt like a gazillion years.Just add a proper enum to the language. Go really needs a proper sum type. Don’t wait until Go v3 like we did in Scala.

"Simplicity" here is creating extraordinary levels of complexity.

#Enums #Golang #scala #LanguageDesign

Constants or Enums in PHP?

🔹 Constants = silent bugs
🔹 Enums = strong typing, cleaner code

Your future self will thank you.
🔗Full article: https://medium.com/@sfmok/10-benefits-of-using-enums-instead-of-constants-in-php-7fc87465edf3

#PHp #Enums #CleanCode #WebDev #PHPZen

10 Benefits of Using Enums Instead of Constants in PHP

Let me start off by saying this: if you’ve been coding in PHP for a while, you know the pain of juggling constants all over your codebase. Constants are great, but they can sometimes leave you…

Medium

Dear #lazyweb, what is the best way you know to represent #tagged #enums in #Python? It needs to be at least somewhat type-checkable, although it's possible I might settle for something like enumerating each value's associated data type/tuple once again for mypy to see.

So far I've been using a hierarchy of frozen dataclasses and then a single-dispatch handler; however, now I have a possible use case with the need for validation, and the hierarchy of dataclasses is not discoverable, thus not, well, enumerable :)

📚🤖 Ah, nothing says "cutting-edge innovation" quite like a 7-year-old article on #state #machines in Rust! Dive into this riveting tale of #enums and structures, where #computer scientists bravely pave the way to a "hopeful future" by rehashing #CS101 topics. Seriously, Samuel, enums again? 🙄🔄
https://hoverbear.org/blog/rust-state-machine-pattern/ #cuttingedgeinnovation #Rust #programming #science #HackerNews #ngated
Pretty State Machine Patterns in Rust

A computer scientist working in open source towards a more hopeful future.

I really, really like the django_enum package.

Imagine Django's TextChoices/IntegerChoices classes, but with the ability to encapsulate any additional information for each choice in one place.

I don't use it everywhere, but it's super useful in a number of use-cases.

Here are a few places where I've found django_enum makes things easier. See alt text for more detail about how I use of each of these.

Check it out: https://django-enum.readthedocs.io/en/stable/

And follow: @bckohan

#Django #Python #WebDev #Enums

Django Enum 2.2.2 documentation

A surprising enum size optimization in the Rust compiler · post by James Fennell

Personal website of James Fennell

🚀 Wow, a whole article explaining that #enums in #Rust can be optimized! Who would’ve thought that a #compiler might actually, you know, do its job? 🙄 Next week: discovering that water is wet and that the sky is blue. 🌧️
https://jpfennell.com/posts/enum-type-size/ #Optimization #Insights #Programming #Humor #HackerNews #ngated
A surprising enum size optimization in the Rust compiler · post by James Fennell

Personal website of James Fennell

Fascinating that #TypeScript 's people are talking about getting rid of #enums (union types can handle most of the situations - someone recently wrote they consider TS enums a mistake), yet now we have #Javascript talking about putting them in JS using the TS syntax:

https://github.com/rbuckton/proposal-enum

GitHub - rbuckton/proposal-enum: Proposal for ECMAScript enums

Proposal for ECMAScript enums. Contribute to rbuckton/proposal-enum development by creating an account on GitHub.

GitHub