#OrderStatus
Postando aqui para não passar vergonha no Linkedinho, mas onde que o segundo código é mais legível que o primeiro? #bolhadev
February 3, 2025 at 2:27 PM
⚠️ #Rustlang Tip: Use the #[must_use] attribute to ensure important return values aren't ignored.

Result is already marked as must_use but other types can be too!
It's good to add #[must_use] when ignoring the return value of a function is almost always a bug.
December 4, 2024 at 5:16 PM
No segundo caso? Bem, estou assumindo que ele está lista de exaustivamente as chaves de OrderStatus...
February 3, 2025 at 4:05 PM
Da war der Zug aber schon abgefahren, Win95 am Start und damit die Dominanz vorhanden. Naja, ich warte ja noch auf meinen "Neuen" ;)
July 21, 2026 at 11:43 AM
Você poderia ter uma outra assinatura para a função com string exceto aquelas em OrderStatus que retornaria nulo. Aí eu vejo vantagem
February 3, 2025 at 3:39 PM
O jeito de expandir o mapa OrderStatus -> OrderMessage também é mais direto ao ponto no segundo caso. Enquanto que no primeiro vc precisaria adicionar um `else-if` com um `return` a mais, no mapeamento é só o mapeamento. Vc tb tem menos chance de fazer bobeira inserindo código executável no segundo
February 3, 2025 at 2:47 PM
O tipo de getOrderMessage tá aberto pra entrada e saída, então na minha visão perdeu valor no tipo.
`status` é qualquer coisa indexável , não necessariamente um OrderStatus.
A nível de tipos eu acho que perdeu informação
February 3, 2025 at 3:39 PM
A nível de backward compatibility faz bastante sentido ter essa opção string -> "unknown", mas a nível de tipos e de lidar com o conhecido faz sentido OrderStatus -> string (talvez OrderMessage, mas não sei o valor da enumeração de resposta)
February 3, 2025 at 3:43 PM
a tenet of avoiding scam emails that's always being shouted at people is "don't click suspicious links from websites and go to the website directly if it looks weird", but then the rewards center for order fulfilment from my insurance company will literally be shit like MY ORDER STATUS DOT COM
July 22, 2025 at 6:17 PM
Examining the "Boolean-Switch" in Java \_(ツ)_/
While reading through some ai-generated code today, I was caught off guard when I saw a switch statement inside of a boolean. What on earth has ai done now, I wondered. Here is the suspect: public boolean canChangeTo(OrderStatus newStatus) { switch (this) { case PLACED: return newStatus == PROCESSING || newStatus == CANCELLED; case PROCESSING: return newStatus == SHIPPED || newStatus == CANCELLED; case SHIPPED: return newStatus == DELIVERED; default: return false; } } Shortly after marveling at "ooo, this is a thing?" I started to question it. Why does this feel _different_? Basically in every other case besides enum, this is bad. Enum, to my knowledge, is the only case where this is acceptable. Why? Because in a flow where there can be one and only one direction, like order processing, this checks out. Each one will hit in the order it is intended to hit. Each case will be found true at the right time in the process, and will update the status accordingly. We can define our fixed, or set values (enums, short for enumeration) to use later in our switch. That might look like: public enum OrderStatus { PLACED("Placed"), PROCESSING("Processing"), SHIPPED("Shipped"), DELIVERED("Delivered"), CANCELLED("Cancelled"); } We use enums when we have a distinct list of choices that do not change. This could also work for days of the week or the current states of your most recent job applications. Because we are using enum, we avoid typos. Also, using your choices as enum values makes them classes in Java - a whole 'nother level of excitement. But back to my boolean-switch... Upon doing further digger I discovered that what claude had spat out (no hate on claude, I love claude!) was actually not optimized. There is a better way to write the boolean-switch. Since Java 14, we can use arrows to slim down our writing. public boolean canChangeTo(OrderStatus newStatus) { return switch (this) { case PLACED -> newStatus == PROCESSING || newStatus == CANCELLED; case PROCESSING -> newStatus == SHIPPED || newStatus == CANCELLED; case SHIPPED -> newStatus == DELIVERED; default -> false; }; } ...slimmer and concise! My brain likes this better. A peculiar boolean-switch has made me realize that using enums is incredibly more powerful and efficient than writing a string in an if-else statement. By using the _this_ keyword on the switch statement itself, it evaluates the enum value and not the boolean value. If you want to "switch" on the boolean, then just use an if else statement, because there is only two values anyways... I used to lean into if-else statements, but the switch is starting to grow on me.
dev.to
September 15, 2026 at 11:38 PM
2/ Five bad fields in one request. One inside a nested record, one on the second item of a list. One response, every field named and located, and nobody wrote the error handling. How, from the top:
buff.ly/zEIkXAU
#Java
September 9, 2026 at 6:05 PM
Higher-Kinded-J 0.4.10 is out 🧵
Whatever shape your data takes (a thirty-field DTO, a generic page of results, a Set three records down) 0.4.10 maps it, focuses it and traverses it with code your build compiles.
One parse, every bad field, one 422:
github.com/higher-kinde...
#Java #JVM
August 30, 2026 at 6:02 PM
In a recent example, I needed to track order status updates and an enum allows me to compare them numerically.

So with
```
OrderStatus {
Ordered = 0,
Paid = 100,
Confirmed = 200,
...etc
}
```

if status is 200, then 0 and 100 are also true, so I can check `if (thisStatus <= orderStatus)`
February 12, 2025 at 10:05 PM
May 2, 2026 at 11:31 AM
April 28, 2026 at 5:57 PM
April 28, 2026 at 5:24 PM
April 5, 2026 at 7:34 AM
April 5, 2026 at 7:31 AM
April 5, 2026 at 5:14 AM
April 5, 2026 at 3:14 AM
April 4, 2026 at 11:22 PM
April 4, 2026 at 5:14 PM
April 3, 2026 at 11:54 AM
March 24, 2026 at 12:03 PM
March 24, 2026 at 10:59 AM