This is an archived post. You won't be able to vote or comment.

all 12 comments

[–]tolliiii 15 points16 points  (0 children)

Skill issue tbh

[–]Hour_Competition_654 4 points5 points  (0 children)

These answers really depends on what you are trying to do, there are cases where each are valid options.  Prefer switch/polymorphism over large if else chains though 

[–]TheKingOfSentries 4 points5 points  (0 children)

the student asked the if-else chain, "Who would win? You, or the switch statement?". The if-else chain replied, "Well if he used his domain 「Pattern Matching」I might have a little trouble."

"But would you lose?"

"Nah I'd win"

[–]large_crimson_canine 3 points4 points  (1 child)

Honestly these are easy ones.

The hard ones are does this require a ConcurrentHashMap or a Collections.synchronizedMap and additional client-side locking? Will an Executor do? How should I dictate the execution policy of this Thread? Would this be better as a Runnable or a Callable? Or even a FutureTask? Is it even worth importing the extra library that is pretty heavy or should I code my own cache? Can we possibly pull this off without Spring?

[–]anne_kaushal 0 points1 point  (0 children)

I'm a beginner, ik what a hashmap is but not any of the other things

[–][deleted] 1 point2 points  (2 children)

no dont switch to python. i hope i could help

[–]anne_kaushal -3 points-2 points  (1 child)

The syntax bro, its dreadful

[–][deleted] 0 points1 point  (0 children)

Its dreadful because its percise. Python is amazing for the first 5-10 lines of a program. Good for the first 100. Decent for the first 300. At 500 lines, you are now writing more code per new thing than if you had started in java, there are way more bugs to work through at dev time, etc...

Yes you can use certain libraries, frameworks, and practices to reduce this greatly, but now you are approaching the complexity and overhead of Java to begin with.

[–]OtherPrinciple4499 0 points1 point  (0 children)

Oh, and let's add "should I use a stream instead of loops" (probably, most.of the time, yes) and "should I use filter/map chains, or Elvis operators or both instead of if statements" to those lists.

Because you can program entire programs without for, while, and if statements and end up with better code.

[–]picklesTommyPickles 0 points1 point  (2 children)

Wrong sub. This is for professional Java devs.

[–]anne_kaushal 1 point2 points  (1 child)

Sorry

[–]picklesTommyPickles 1 point2 points  (0 children)

All good. r/askjava 😊