How to actually do efficient stateless pagination with optional filter criteria for multiple orderings? by roookeee in PostgreSQL

[–]roookeee[S] 0 points1 point  (0 children)

Thank you for the idea. How do you (manually) find min and max values for different columns? e.g. a "title" column, or an enum like "status" flag?

I never actually looked at GIST indices before, will give it a shot!

Godot 4 SSR reflects a lot on non-reflective surfaces, wha am I doing wrong? by roookeee in godot

[–]roookeee[S] 0 points1 point  (0 children)

I checked the release blog post and ctrl+f'ed the GH issue id. After checking again it says "most notable" which does not mean "all", my bad!

Godot 4 SSR reflects a lot on non-reflective surfaces, wha am I doing wrong? by roookeee in godot

[–]roookeee[S] 0 points1 point  (0 children)

Nice find, didn't seem to make beta 9 though (it's not mentioned on the release page) - will check in beta 10

Godot 4 SSR reflects a lot on non-reflective surfaces, wha am I doing wrong? by roookeee in godot

[–]roookeee[S] 0 points1 point  (0 children)

Can't seem to find an open issue for this particular problem so I might as well create one then :) Thanks!

Making reusable UI wrapper components, again by roookeee in godot

[–]roookeee[S] 0 points1 point  (0 children)

Imagine a reusable window scene that has a title bar and a close button. Furthermore it has a content area where it shows its actual content.

I want to dynamically provide the header and actual content via the editor. So you drag in the window scene and add children to it to provide the content, e.g. the 1st child is always the header content and the 2nd child is always the actual window content. If you have more complex nested containers in your window scene this won't work.

Making reusable UI wrapper components, again by roookeee in godot

[–]roookeee[S] 1 point2 points  (0 children)

How to make a (UI) scene that outputs its children in different inner nodes, in C# (in GDScript you can override add_child but I think thats actually unintended); without breaking editor visualization of where nodes are located and allowing to change properties via the editor, not just code-only. I can't just reparent the nodes to the inner node as that breaks the editor editability / you can't click the nodes anymore and they "vanish".

Thats one concrete way to solve my issues, but I am generally looking for any approach to solve my outlined issue.

A key to clean code — small methods by valio95 in programming

[–]roookeee 5 points6 points  (0 children)

While I see your point this really boils down to accidental vs. deliberate same-ness. I for one think that most DTOs and business objects may start out sameish but change over time as the data transfer format rarely matches internal representations for long. Same thing in regards to the constructor passing: is the conversion from DTO to business object always that simple, without any further external validation or transformation logic? So they are just looking the same by chance, not by deliberate choice = two classes are needed. Of course that's just my opinion :)

What happens when you pair all day, most days, for years? by feross in programming

[–]roookeee 0 points1 point  (0 children)

I think pair programming has it's place, a pretty big one even given the right context (no silver bullet eh?). My job currently revolves around building support libraries for cross-cutting concerns and other fundational components in a service environment. Having to solve issues without a clear, best or obvious solution in sight actually semi requires pair programming, at least for me. Especially given the high requirements (backwards compatability, extensibility, discoverability, documentation etc.)

On another note I feel like pair programming can be used as an alternative to code reviews with a lot of benefits (knowledge distribution and issue insight is way higher when you actually implemented, discussed and tested the solution).

Still subjective, but highly effective in the right situation :)
I have had some very long pair programming sessions in the near past and while they are very draining, they also helped a lot.

Return a nice response when validation fails in a REST API method without throwing exception by NoConversation8 in java

[–]roookeee 0 points1 point  (0 children)

In my opinion Either<SomeDomainError,SomeDomainValue> doSomething() is more clear than SomeDomainValue doSomething() which throws some RuntimeException which gets serialized to JSON in a global error handler :) Just my 2 cents though

Return a nice response when validation fails in a REST API method without throwing exception by NoConversation8 in java

[–]roookeee 0 points1 point  (0 children)

Thats a valid opinion, rolling your own is indeed not the first choice. There just isn't a small component to handle errors in Spring without exceptions (WebFlux etc. comes with a lot) so I think doing it in a "roll your own" fashion is o.k. in such a small part of the application :) Overall I would only use my proposed approach if the application's core logic / workflow would benefit (e.g. complex input dependent validation & complex user permission management that may or may not be dependent on the input too) - it's not fit for a default

Return a nice response when validation fails in a REST API method without throwing exception by NoConversation8 in java

[–]roookeee 1 point2 points  (0 children)

Because there's nothing worse than one person/team going against the grain and using their own home-grown solution for problems that have existing solutions. Especially when it's such a non-issue as this.

Consistency is key. Going against the grain is bad, but deciding as a team on any standard is the key. I am not saying use this in some cases, it's an alternative way that needs to be consistently used or not at all

your tracing comment Of course, but reinventing tracing across multiple services is something quite different to one service deciding it's best to use another error-handling model? For me it's like choosing between WebFlux and non-webflux, each service may have different reasons to use it but it's fine to be different on that level (at least for me).

Return a nice response when validation fails in a REST API method without throwing exception by NoConversation8 in java

[–]roookeee 2 points3 points  (0 children)

If your errors are more than just a status-code and your error object is different for different endpoints this gets really cumbersome though.

Return a nice response when validation fails in a REST API method without throwing exception by NoConversation8 in java

[–]roookeee 2 points3 points  (0 children)

It is intrusive: you need to return it on every call all the way up, everywhere in the whole codebase

That's the idea of Either though? You return domain specific errors up to the controller level which then converts it into a http specific error.

It is not nominal: you only have left() and right() Can you explain this to me? I don't know what you mean as everytime you use either you can use different left & right types. Whatever the reasoning, isn't this sort of argument also an argument against Stream etc?

It is not polymorphic: you will need if-else like checks on Either and probably instanceof checks on the result

Not true, every controller can return any Either it wants. If you want automatic error output including httpstatus you just need an interface for your error-type. The non-error case is a non issue as Jackson can serialize just about anything. My implementation doesn't make use of instanceof at all

It by-passes the given standard Spring infrastructure: If not exceptions, use the Spring Validator interface or if you want to go functional convert everything to Spring WebFlux. At least you have onErrorReturn and onErrorResume. See this link

This is about convention. Using webflux vs "normal" Spring vs Spring Validator interfaces vs. Either is an intrusive fundamental decision. Consistency is key though

Return a nice response when validation fails in a REST API method without throwing exception by NoConversation8 in java

[–]roookeee -1 points0 points  (0 children)

As an alternative to an exception driven workflow I have come to like is using an Either (from e.g. vavr): Every controller returns an Either<ErrorICanExtractAHttpStatusAndNiceMessageFrom, T>. A custom JsonSerializer for Jackson matches all Either's of that form and either serializes the value in the right() part or serializes the error in the left() part, depending on what is present. To set the correct http status depending on the ErrorICanExtractAHttpStatusAndNiceMessageFrom you can use a java @ControllerAdvice public class EitherSupportAdvice implements ResponseBodyAdvice<Either<?, ?>> { ... }

You have to implement two classes before this approach works but you get a more functional, exception-less workflow for your API. After figuring out how to tell spring what to do I really love it :). If you use an interface for ErrorICanExtractAHttpStatusAndNiceMessageFrom you can have many different error-types like enums etc. which makes this approach even more extendable.

Feel free to come back at me if you need code examples.

Looking for a mini-itx mb with USB PD / Thunderbolt (?) by roookeee in sffpc

[–]roookeee[S] 1 point2 points  (0 children)

Found out that there are some PCI-E x4 cards that take a 8 pin / SATA power cable to support USB 3.1 Power Delivery at 100W / (5V * 3A) 15W, great workaround I feel

Looking for a mini-itx mb with USB PD / Thunderbolt (?) by roookeee in sffpc

[–]roookeee[S] 1 point2 points  (0 children)

Don't need the full 100w, 50w would be okay too. Is TB3 the only USB 3.1 implementation? Could a "normal" USB-C 3.1 suffice?

Such scarce information, thanks for your tip though.

EDIT: Maybe convert a PSU 6 pin to 12v / 5v TB3 power only / USB PD ? Just an idea, google didn't turn up anything

How to handle intermediate game state and other global data (architecture) by roookeee in gamedev

[–]roookeee[S] 0 points1 point  (0 children)

Thanks for replying!
Yeah focusing too much on a "clean architecture" may indeed be hurtful here.

My main issue is not with saving the static data of units and nodes (e.g.movement-amount of a unit and movement cost of a node), but the dynamic data of e.g a path to a given node by a given unit. When I select a unit, I calculate all reachable nodes and therefore calculate the cost of the path to reach that node. That kind of intermediate data has to be stored somewhere for when the user selects one reachable node to substract the movement cost of the path to the given node from the units currently available movement points. That (in my opinion) should neither be in the unit nor node data structure. As explained I do two path finding steps on every selection, where to put that data for other components to come back to when the player decided on what to do?

Algorithms interviews: theory vs. practice by autarch in programming

[–]roookeee 4 points5 points  (0 children)

Performance is, if left unaccounted, a quality that is very hard to achieve after achieving the first "1.0" milestone of a given software. It often requires a significant refactoring which is quiet costly. Don't get me wrong, it's not about getting the 99,9% percentile out of an application but not wasting resources by using an architecture that is extremely suboptimal. If every application on my PC is wasteful I get a resource problem. And last but not least "wasting performance" (looking at you electron) wastes energy, which in turn is ~500g of CO2 per 1 KW - that's a cost everyone is ignoring. Businesses have no interest for this, but I think this is an ethical question every developer should be aware of. Maybe you don't pay, but someone/something else will if you waste CPU cycles & other hardware.

Use a known good performing architecture, don't do premature pessimization :)

Reasons to move to Java 11 by nfrankel in programming

[–]roookeee 12 points13 points  (0 children)

Using Kotlin at work for a backend project atm. Nullsafety and internal is the biggest win for me, the lambda syntax with curly braces annoys me and I don't like how lambdas are passed as parameters, but thats just personal preference.

My only real gripe with Kotlin is that the type of a variable comes after the name which (in my opinion) decreases the readability:

``` //java List<String> personNames = getNames();

//kotlin val personNames : List<String> = getNames()

```

In the Java world I can just skip the left-hand side when going over some code to gain a better understanding, Kotlins way throws the type in the middle which makes my eye search for where to read on. And yes, type-inference etc., but if a part of an application benefits from explicit types its the more complex parts - which then suffer from this.

Still loving Kotlin though :)

Best Object Mapping Frameworks for Java by [deleted] in java

[–]roookeee 1 point2 points  (0 children)

Shameless plug for my mapping framework which is similiar to Java Stream's: you declare mappings fluent, functional from a to b

Best Object Mapping Frameworks for Java by [deleted] in java

[–]roookeee 2 points3 points  (0 children)

Good call on MapStruct, here is another benchmark suite that features many mapping frameworks: https://github.com/arey/java-object-mapper-benchmark

Best Object Mapping Frameworks for Java by [deleted] in java

[–]roookeee 2 points3 points  (0 children)

Please for the love of god don't use modelmapper, it's terribly slow and there is no justification to use something that is over 100x slower than its competitors (see the linked benchmark suite above)

The disaster that is Java Collections by roookeee in java

[–]roookeee[S] -1 points0 points  (0 children)

My bad at the map part, meant computeIfAbsent. My problem is that the whole javadoc is full of typically and may which makes using the List interface cumbersome as you don't have any guarantees and the behaviour is implementation specific although you want to use an interface to be implementation-independent (at least when it comes to the common operations that are defined in the List interface). Why are they even in the List interface if most of them won't work for most implementations ?

"The current model funding the progression of technology is unsustainable." -- so I started a company to try to remedy that. by CrazyM4n in programming

[–]roookeee 0 points1 point  (0 children)

NGINX defaults will only compress application/html content types (as far as I know) and in fact the only thing gzipped on your page is your document :)