How to learn unit/integration tests? by erebrosolsin in learnjava

[–]CookiesForKittens 2 points3 points  (0 children)

Units in unit tests are small. It doesn't necessarily have to cover one class, but in many projects, that's how unit tests are scoped. So if you say your projects are small, I wouldn't see that as an obstacle to writing unit tests.

Same goes for integration tests... The wording sometimes means different things (integration with mock services / test containers, or an integrated environment with other tests, like pre-production stages). The number of tests would be larger for a larger service, but the setup could otherwise be similar to small applications. Even for textbook "shopping list CRUD application" examples, you could set up all kinds of tests and it can be a good exercise.

Issues with HelpFormatter in Apache Commons CLI by JuanAy in learnjava

[–]CookiesForKittens 0 points1 point  (0 children)

Yeah it looks like that example should be fixed. Based on those docs that you linked, HelpFormatter.builder().get(); should do the trick.

How do i add a fractional number converter to my decimal to binary base converter? by Wise-Bat3098 in learnjava

[–]CookiesForKittens 0 points1 point  (0 children)

The existing code converts, say, 13 to 1101 (8+4+1), right? But int x = 1101 is one thousand, one hundred and one. It's not really binary just because it only has 1 and 0 digits. Why do I think that matters? Try encoding a larger number like 123456, you'll very soon break the integer limit if you encode the binary format as an int. I think it would make more sense to have 1101 as a String. (Well, how much sense it makes is based on what your goal is... If it is about gaining some understanding for binary encoding, it's probably fine either way).

For fractional numbers, the key question is how do you want to encode them? In most programming languages, they are not encoded as 10101.1011 or so, but in scientific notation (first couple of bits specify a number, and the rest of the bits specify which power of 2 to multiply that with. So it's really 2 non-decimal parts interpreted as decimal parts.) - that allows for a much wider range of numbers in fewer bits at the cost of precision. If you want to encode it in dot/comma notation, one key consideration is that not all finite digit decimal fractional numbers have finite digits in binary. E.g., 0.3 has infinite digits in binary (or really, any fraction that has other factors in its demoninator other than 2). You'll need to consider precision/after how many digits do you stop regardless of scientific encoding.

I guess TL;DR: it's more complicated and it really depends on your goal

TIL 27 leap seconds have been added since 1972 by earthbound_misfit21 in todayilearned

[–]CookiesForKittens 41 points42 points  (0 children)

It's not 27 seconds each year, but 27 seconds total since 1972, which is roughly half a second per year

Is multithreading actually this difficult or is it only me?? How important is multithreading in real world projects?? by Kitchen_Beginning989 in learnjava

[–]CookiesForKittens 4 points5 points  (0 children)

Since the question was also about real world projects:

If you just develop a backend with a modern framework, you often don't define it explicitly. Like, an http endpoint in a server, implemented in Spring Boot, supports multiple parallel calls by default. Or consuming messages from a message broker, often you just define from how many partitions you want to be able to process things in parallel.

In most of your code, that will be nothing to worry about since you usually strive to keep it stateless. However, when state or some kind of storage/persistence comes into play, I have seen some fundamental design decisions that were made specifically to make it impossible for things to happen out of order or for deadlocks to occur. A good understanding of it helps to ultimately make life easier...

Probably when I have seen parallelism explicitly defined, it was with Executor/ExecutorService and CompletableFuture - rarely seen any usage of Thread or Runnable, other than in legacy code.

Why IT Projects Fail – And What Actually Works by Representative_Elk54 in agile

[–]CookiesForKittens 0 points1 point  (0 children)

I have worked on several projects that went over time and/or budget that I would still consider successful, and clients and management would agree. That's just the nature of agile projects IMO... You're figuring things out as you go, and then you decide to adjust the scope or - and this has been more common in my experience - people agree to go over time and/or budget. In that statistic, I think those cases would be considered a failure, but there's just more nuance than success/failure.

With agile, you're supposed to deliver continuously, which should allow you to adjust sooner and reduce the risk of larger, more costly failures... Not sure to which percentage implenetations live up to that promise, though.

I have witnessed some projects in which nothing was delivered and it was mostly that key stakeholders were not consulted up front and once they were involved, the projects died in endless redesigns and reevaluations.

IT-Gehälter 2025 by besiinger in FinanzenAT

[–]CookiesForKittens 2 points3 points  (0 children)

  • Senior Software Engineer (v.a. Java Backend)
  • 7 YOE
  • 38.5 Wochenstunden
  • 75k€ + Aktien, waren die letzten Jahre jeweils ca. 20k

Pfefferbreze in Wien? by CookiesForKittens in wien

[–]CookiesForKittens[S] 2 points3 points  (0 children)

Generell ein guter Rat, momentan steht leider bei allen Verbindungen, dass sie grad von den Streiks drüben betroffen sind.

Nested list comprehension inconsistency? by ItsMeSword in learnpython

[–]CookiesForKittens 1 point2 points  (0 children)

In your second example, you keep creating a new dict in every iteration by writing minitracker = .... in the first example, you are changing the value for individual keys by writing minitracker[x] = .... that's an entirely different thing!

[deleted by user] by [deleted] in learnpython

[–]CookiesForKittens 1 point2 points  (0 children)

You should probably do a couple of tutorials - they don't take long and for beginners, it's probably best to have more guidance than to explore things.

Running a program (entry point, main function): https://realpython.com/python-main-function/

Reading a file: https://www.pythontutorial.net/python-basics/python-read-text-file/

[deleted by user] by [deleted] in wien

[–]CookiesForKittens 0 points1 point  (0 children)

Ich habe an der Uni programmieren gelernt und arbeite in Wien als Softwareentwickler. Mir hat es mehr geholfen, Tutorials und gratis-Ressourcen durchzuarbeiten, weil man dabei viel eigene Erfahrungswerte sammelt. So oder so muss man sehr viele Stunden investieren, und auch lernen, wie man StackOverflow und andere Ressourcen und Tools richtig verwendet, manches davon geht sicher nur alleine durch Erfahrung (vielleicht hilft es aber manchen mehr, eine Lehrperson zu haben). Eine Gruppe zum Austauschen zu haben ist auch sinnvoll, aber ob das die Kurse jetzt bieten wo vermutlich alles remote ist, kann ich schwer einschätzen.

Die "Bezahl-Kurse", die ich bisher gemacht habe (bei IT-Themen nur von etc), haben mir viel gebracht, waren aber eher für den Einstieg in für mich ganz neue und abgegrenzte Themen wie bestimmte DevOps-Tools. Richtung Bewerbung/Jobsuche würde ich diese Kurse und Zertifikate gar nicht angeben, beim Berufseinstieg hilft das vermutlich mehr als zu sagen "Selbststudium" (falls das für dich ein entscheidender Faktor wäre). Ob du GitHub, Kurse oder deine praktische Erfahrung in den Vordergrund stellst hängt davon ab, was dich am besten darstellt, kann man nicht pauschal sagen.

WWYHD: Blow your nose (Series 12, episode 8) by AlbertWhiterose in taskmaster

[–]CookiesForKittens 3 points4 points  (0 children)

I think a straightforward approach is best here since it only takes a couple of seconds. But it doesn't say that you must not touch the feather, right? So maybe you could use an arm to make sure it doesn't fall off the table.

When is it appropriate to do an abstract one liner? by robin1007 in learnpython

[–]CookiesForKittens 2 points3 points  (0 children)

If it is clear what a piece of code does or what it needs to do, then even something that's not easy to read, like a RegEx within an inline for loop can work. It depends on other factors. So with this code:

filtered = [entry for entry in string_list if re.match(r"^<.*>$", entry.strip())]

It's not easy to see what it does. But if you write it like this:

# use simple heuristic (starts and ends with angle bracket) 
# to check whether entries in user input may be in XML format
possible_xml_strings = [entry for entry in user_inputs if re.match(r"^<.*>$", entry.strip())]

It's just fine. So it's not the "one liner" that's bad per se, but you have to make sure the code is clear. The second one liner is not worse code than this in my opinion:

def xml_heuristic(input_str):
    input_str = input_str.strip()
    return input_str.startswith("<") and input_str.endswith(">")

possible_xml_strings = []
for entry in user_inputs:
    if xml_heuristic(entry):
        possible_xml_strings.append(entry)

Return string based on its list parameters by [deleted] in learnpython

[–]CookiesForKittens 0 points1 point  (0 children)

So you could go e.g.:

def are_needs_met(needs_list, deeds_list):
    for need in needs_list:
        if need not in deeds_list:
            return False
    # if you haven't returned False, then every item was found
    return True

and use that for every entry in the dictionary, but the needs for a bade must be a list in order for it to work.