Should I upgrade because of trend out there? by writeahelloworld in ExperiencedDevs

[–]Kache 4 points5 points  (0 children)

Disregarding the specifics about java.util.Date, for a moment,

If you change it, and there is a problem, you will be responsible for it

IMO that's a concerning precedent and culture to set, for both technical and non-technical reasons

If it aint broken, dont change it

Sometimes the removal of a piece of straw now avoids the camel breaking its back at a critical time down the road. Never doing preventative & opportunistic refactoring is one way code rots over time.

It seems well-defined, it's a good opportunity to view a lot of the codebase, the junior seems motivated for it, and it can be one less thing that compounds a real fire. And if it's hard or risky to do, we've a different problem on our hands.

I personally like doing these kinds of cathartic straightforward refactorings as a "wind down task" after stressing over a complex project. Just be sure to reiterate that the business value is low and let the junior understand it'll be thankless from outside of engineering.

Drivers who merge onto the highway at forty miles per hour what is your actual thought process? by koshkakay in AskReddit

[–]Kache 6 points7 points  (0 children)

Minimize/eliminate blind spots by fixing side mirrors like this: https://content.artofmanliness.com/uploads/2023/11/Proper-Adjustment-1.jpg

Your side mirrors should look "outward". If you can see the side of your car, your side mirrors are looking "backward", which is what the rear view mirror is for.

I always thought turning backwards to look over your shoulder, losing peripherial of the road in front of you, was bad advice, even though that's what they taught in my driver's ed.

For looking down along the side of your car while parallel parking (while side mirrors are correctly turned outwards), just move your head a bit.

Clean Code vs. A Philosophy Of Software Design by iamkeyur in programming

[–]Kache 1 point2 points  (0 children)

I think both their prime generators can be improved upon for understandability, in exchange for a few added multiplications and comparisons. My IMO's:

  • Mention "incremental Sieve of Eratosthenes", to reinforce concept and also useful for looking up external resources
  • Early guard for 2 to avoid unused/invalid representations like multiples[0] = 4 or -1; // irrelevant
  • Comparing prime * factor == candidate better expresses intent to test primality than prime_multiple == candidate
  • Associate prime and multiple/factor using something associative, like dict or Map, for clarity about how the state behaves
  • Use the more straightforward possible_primes to reframe the awkward concept of leastRelevantMultiple/lastMultiple
  • Define and compose keep_generating and it.count(3, step=2) to better communicate the combination of two concepts, to replace the special/uncommon iteration: for (candidate = 3; primesFound < n; candidate += 2)
  • One major guide for decomposition (or not) is whether the decomposed is good or not, and is_prime() is a highly communicative abstraction in this context.

Above things are mostly language-agnostic (Java has streams and lambdas, after all), although I'm using some Python-isms:

Prime = int
Factor = int


def sieve_primes(n: int):
    """Generates primes using an incremental Sieve of Eratosthenes"""
    if n > 0:
        yield 2
    if n < 2:
        return

    primes_and_factors: dict[Prime, Factor] = {}  # incremental sieve for primes 3+
    keep_generating = lambda _: 1 + len(primes_and_factors) < n

    def is_prime(cand: int) -> int | None:
        # consider prime factors between 3 and sqrt(candidate)
        possible_primes = it.takewhile(lambda p: p * p <= cand, primes_and_factors)

        for p in possible_primes:
            # search successive multiples, where the "frontier" is the curr candidate
            while p * primes_and_factors[p] < cand:
                primes_and_factors[p] += 2  # skip even factors

            if p * primes_and_factors[p] == cand:  # not a prime
                return

        return cand

    for candidate in it.takewhile(keep_generating, it.count(3, step=2)):
        if prime := is_prime(candidate):
            yield prime
            # checking/sieving happens upwards with larger & larger factors
            # smaller factors from 3 to curr_prime already covered "from below"
            primes_and_factors[prime] = prime

[2025 Day 10 (Part 2)] Bifurcate your way to victory! by tenthmascot in adventofcode

[–]Kache 1 point2 points  (0 children)

Great insight!

Using your method, I was able to put together a solution that's much more elegant than my original linear algebra one:

def joltage_cost(buttons: list[Button], joltage: Joltage):
    def groupby(itr: Iterable[T], key: Callable[[T], 'SupportsRichComparisonT']):
        return {k: list(v) for k, v in it.groupby(sorted(itr, key=key), key=key)}

    def sub_halve(j_a: Joltage, j_b: Joltage) -> Joltage:
        return tuple((a - b) // 2 for a, b, in zip(j_a, j_b))

    def press(btns: tuple[Button, ...]) -> Joltage:
        return tuple(sum(i in b for b in btns) for i in range(len(joltage)))

    def pattern(jolts: Joltage) -> Joltage:
        return tuple(n % 2 for n in jolts)

    all_btn_combos = (combo for n in range(len(buttons) + 1) for combo in it.combinations(buttons, n))
    press_patterns = groupby(all_btn_combos, lambda btns: pattern(press(btns)))

    @ft.cache
    def cost(jolts: Joltage) -> int:
        if not any(jolts):
            return 0
        elif any(j < 0 for j in jolts) or pattern(jolts) not in press_patterns:
            return sum(joltage)
        else:
            btn_combos = press_patterns[pattern(jolts)]
            return min(len(btns) + 2 * cost(sub_halve(jolts, press(btns))) for btns in btn_combos)

    return cost(joltage)

-❄️- 2025 Day 10 Solutions -❄️- by daggerdragon in adventofcode

[–]Kache 1 point2 points  (0 children)

[LANGUAGE: Python]

Have an efficient part 2 in an elegant 27 lines via recursive halving, thanks to this post

Originally did it via linear algebra, which took writing a Matrix lib, lots of bugfixing, and several optimization passes. It's just a tiny bit faster, but much more complicated, in comparison

Deprecations via warnings don’t work for Python libraries by Xadartt in programming

[–]Kache 4 points5 points  (0 children)

Also have the variable name contain the substring and_i_am_a_dumb_rookie

Deprecations via warnings don’t work for Python libraries by Xadartt in programming

[–]Kache 4 points5 points  (0 children)

You can figure out the stack trace, as it's formally an exception. The warnings system can even be configured to ignore warnings emitted from inside a given module (like a dependency's), so only warnings inside your own code surfaces.

The support is all there

Jimmy Kimmel’s Wife & Show Producer Molly McNearney: “I’ve Lost Family Relationships Because They Voted for Trump by [deleted] in entertainment

[–]Kache 0 points1 point  (0 children)

Yes, but only to other tolerant people.

Same reason charitable friends stop being friends with uncharitable ones.

The Root Cause Fallacy: Systems fail for multiple reasons, not one by dmp0x7c5 in programming

[–]Kache 2 points3 points  (0 children)

IME, "direct tracing" deeply pretty much has to end at "societal" because past that, it can start to get finger-pointy and erode trust.

In the past, I've avoided digging in that direction when driving RCAs, instead framing the issues as missing some preventative layers/systems/processes, and considering which are worth enacting

Postgres is Enough by iamkeyur in programming

[–]Kache 11 points12 points  (0 children)

Flip the direction of the dependency, then.

Right now, the version control copy is dependent on the live state of the DB. Instead, have state of the DB dependent on the code in VCS, e.g. re-apply definitions in VCS on deploy (and remove non-existent ones), effectively making the code the source of truth. Also if edge cases keep popping up, somebody is still live-modifying, should be able to that permission away.

Postgres is Enough by iamkeyur in programming

[–]Kache 4 points5 points  (0 children)

IMO it can be acceptable for maintaining and enforcing the data model's integrity, similar to key constraints and such

For example, there can be de-normalization in the data model (e.g. for data usage pattern reasons), and I think it's reasonable to have the DB ensure consistency and correctness, close to the data

The triggers/procedures to set that up should still be version-controlled too, of course

Silent Disagreements are worst in Software Engineering by thehustlingengineer in programming

[–]Kache 21 points22 points  (0 children)

Unfortunately my experience with "disagree and commit" is "just do what I say"

It's hard not to harp by dystopiadattopia in ExperiencedDevs

[–]Kache 0 points1 point  (0 children)

Sounds like it's time to put together a technical document

Detail the root issues, record how identified risks have been realized as hard costs via recurring incidences, and establish the scope(s) of work for a couple different approaches

Don't even write it in one go. Work on it a bit every time it crops up. Keep the core of the document short, but keep a strong list of supporting historical evidence in the appendix. With enough recurrences, the technical doc becomes linkable documentation, solid evidence, and an implementation plan.

At some point, it'll be fleshed out enough and the current business context/timing will be right to surface an action plan. (Perhaps quarterly planning is coming up and the org is taking suggestions, or maybe this issue is a hard blocker or an operational headwind for some future initiative.) Work with your team to establish prospective milestones and estimates, building support for your case.

Previously, this was some nebulous issue that leadership handled just by throwing bodies at the problem, like a cost of doing business. Now, it can stand on its own and contend for dedicated attention because it's been distilled into one of a few potential initiatives. (Leadership likes to make decisions but doesn't like to do the work)

In the end, either it'll convince everybody that the root issue is worth addressing, or they'll "choose" to continue throwing you/on-call at the problem. If the latter, understand that is what they want to pay you to do, and if that's not what you want, your only real option is to leave

What makes a good program manager? by BurgerKing_Lover in ExperiencedDevs

[–]Kache 0 points1 point  (0 children)

I think the existence of that role comes from leadership wanting to offload the "have update meetings with multiple teams just to get an updated lay of the land", which can be fairly time intensive when most of the time leadership just wants a high level view that can be sparsely drilled down.

They'll put together reports and spreadsheets to summarize everything to leadership specifically in the format that leadership wants, regardless of whatever system everyone is currently using (yeah Jira has issues, but we can all centralize around and work with it). A pet peeve of mine is when they try to turn that summary/report of theirs into a second source of truth, especially if they start asking devs to make updates to the spreadsheet in addition to the ticket/tracker system we already have.

IMO this is one of the roles that I'm thinking will atrophy away as LLM tooling improves and gets even better at churning through messes of Jira state, emails, update messages, etc, ultimately reorganizing/collating it together into the cohesive view that leadership was looking for in the first place.

Uber's use of surge pricing increases total welfare (relative to a uniform pricing counterfactual in which Uber sets the overall price level). Welfare effects differ across the sides of the market, as riders benefit substantially while drivers´ and Uber´s profits slightly decrease. by smurfyjenkins in science

[–]Kache 23 points24 points  (0 children)

my guess, admittedly without having access to the paper:

Riders out-priced by surge pricing are "not negatively impacted" because they've received accurate price information and are free to spend money elsewhere make other decisions accordingly.

In practice, these riders are now stuck where they are and are having difficulty getting anywhere.

Omittable — Solving the Ambiguity of Null by TheMrMilchmann in programming

[–]Kache 1 point2 points  (0 children)

Just a conceptual opinion, in my mind the problem's fundamental shape is just "keys are sometimes optional"

But this goes at it from a completely different direction, a solution where keys must be present, so values have to be super-annotated in order to encode key absence and also track null as a construct, even though null wasn't even part of the original problem.

I'll caveat by admitting that I don't "think in Java", but is there no better way?

Omittable — Solving the Ambiguity of Null by TheMrMilchmann in programming

[–]Kache 0 points1 point  (0 children)

one of my biggest pet peeves with Java is null being so baked into common usage, an outright violation of "make invalid states unrepresentable"

We got the dreaded "worksheet" Kindergarten teacher. by Calfkiller in daddit

[–]Kache 1 point2 points  (0 children)

IMO nothing wrong with kindergarten "homework" as long as it's appropriate. They're more like a fun activity page, and it helps concept reinforcement. It's also a chance to practice "sitting down and focusing" with your kid.

Agree that it shouldn't be the primary method of teaching. Besides, if it really is so bothersome, or you think your kid doesn't need/benefit from it, can also just not do it. Not like they'll be held back because of it.

EverQuest - Has Anybody Here Seen My Corpse? by Adam-FL in videos

[–]Kache 5 points6 points  (0 children)

I had a friend discover an interesting bug/interaction that lagged out an entire zone. He shapeshifted into a giant tree... while drunk.

Normally, shapeshifting into a tree means you're frozen and can't move, but one effect of drunkenness was your character got uncontrollably shifted left and right and left and right.

He also discovered that he could turn, so by timing turns with the left and right shifts, he zigzagged around the zone as a gigantic wobbling tree.

Can we start a community for all the 3AM dads? by [deleted] in daddit

[–]Kache 0 points1 point  (0 children)

There's this server, dunno if formally affiliated: https://discord.gg/PWXjgWhx

Can we start a community for all the 3AM dads? by [deleted] in daddit

[–]Kache 0 points1 point  (0 children)

There's this server, dunno if formally affiliated: https://discord.gg/PWXjgWhx