« first day (3894 days earlier)      last day (1047 days later) » 

12:00 AM
The study of non-linear physics is like the study of non-elephant biology. (source)
 
 
3 hours later…
3:10 AM
uses java.io.File
 
 
6 hours later…
9:10 AM
hums a song
 
 
4 hours later…
12:56 PM
posted on June 21, 2021

archive - contact - sexy exciting merchandise - search - about ← previousJune 21st, 2021nextJune 21st, 2021: Beats me why some dudes make mistakes! Sure as hell ain't my scene!– Ryan

 
 
1 hour later…
2:18 PM
does anyone have any advice for writing tests for multithreaded programs?
 
dont test
know that your program works
 
isnt testing standard practice?
 
not for me :D
 
well for everyone else haha
 
if I need a test to assert my code works, it is probably too complex
and it should be rewritten to something simpler
 
2:20 PM
yes i know buts its idustry practice
 
or... rarely, it just is something that i'd like to test
 
wietlol do you use @controlleradvice in spring much?
 
I dont use spring
 
how would you do error handling for a spring boot api?
 
I wouldnt
 
Zoe
2:23 PM
@Trajan It's convenient and fast, but not required
 
@Zoe i know but i like to look pro
 
if you want to look pro, keep it simple
and be consistent
 
do you think that looks pro
 
a link to a post with a link to another post?
pro my butt
 
yeah because of scraping
 
2:29 PM
scraping?
 
yeah i posted in here before and then got lots of clones
 
all code in the default package?
ew
 
its a small program?
 
uncontrolled threading in main?
ew
log files in git?
ew
 
@Wietlol what do you mean?
 
2:31 PM
same with /out /build /.idea and maybe even /.gradle
extensive catching and printing of exceptions?
ew
 
@Wietlol these are probally default from the ide
 
to show that as "looking pro", you'd probably need to do a lot of work
 
omg
the thing is i cant even see why it doesnt look good :(
its using all the java layout and naming convetions and is well commented so i thought its ok
 
on top of the above,
- code duplication
- structure duplication
- undescribed method returns
- package level visibility
- primitive error codes
- non-atomic mutation (in an intended multithreaded application)
- non-encapsulated validations
- ancient OOP patterns
@Trajan if you try to sell a pile of poo by putting a label on it with the text "highest quality dump" is not enough to sell poo to people who know their shit
(^ not necessarily related to your code)
but just adding comments and naming things differently is not enough
in fact, adding comments probably means that your code is not self explanatory
perhaps an indication that you should change the code
if a comment describes what the code does, then you might just as well refactor the code to describe what it does
 
2:47 PM
omg
but the generating function in the order book is sychronized, how can it be non atomic?
also how is the multi threading uncontrolled?
 
Zoe
@Trajan let me give you a tip for looking pro:
 
ok
 
the entire function `generateOrderBook` is one big mutating process
however, you only need one operation which is to re-assign the field with a new map of values
it might be synchronized, but is not atomic
 
Zoe
Use your brain to make your own decisions on what's best for your project based on the scope of your project, instead of worrying about patterns, best practices, and good ideas. If you have a multithreaded program you need to test, and you need to test something specifically related to its multithreading (on the level where you test what each individual thread does), you'll quickly find yourself in a world of pain
Or, in the words of a modified xkcd:
Fuck you reddit xd
let's try that again:
 
as for the threadsm you create and start the threads in the main method... but what happens then?
 
Zoe
2:53 PM
Do tests make you look "pro"? maybe. Is it worth it if you spend more time on testing individual threads than you make them actually do stuff? Nej
 
fiveMinuteThread kills the program
 
in this example, it is better to join all those threads
and have them exit properly
 
i couldnt see any other way to run this program for 5 mins
@Zoe i realised that concurrent testing is hard
 
why 5 minutes specifically?
 
its a simulation, and i didnt want the user to kill it manualyl
 
2:57 PM
if you just need it to be 5 minutes, then the main function can sleep for 5 minutes and then signal the other runnables to stop, then joining their threads and exiting gracefully
 
Zoe
hard is an understatement :')
 
surely if the main function i sleeping the other threads wont be running
 
that is not how threads work tho
if you start another thread and then sleep for 5 minutes
the other thread will still continue
 
yeah i dont like my 5 minute thread either
how do i do the joins?
 
PriceProcess priceProcess = new PriceProcess();
OrderBook orderBook = new OrderBook();

Runnable pricingRunnable = new PricingRunnable(priceProcess, orderBook);
Thread pricingThread = new Thread(pricingRunnable);
pricingThread.start();

Runnable rfqRunnable = new RFQRunnable(priceProcess, orderBook);
Thread rfqThread = new Thread(rfqRunnable);
rfqThread.start();

Thread.sleep(300_000);
pricingRunnable.finish();
rfqRunnable.finish();
pricingThread.join();
rfqThread.join();
 
3:02 PM
why do you called finish? thanks
 
because you need to tell them to stop
you could make it an AutoCloseable and use close
but you just need a way to tell them that they should stop their infinite loop
 
they never have finish() in examples haha
 
it is a function you need to make
I suppose the code should also stop using Runnables for the variables
Runnable pricingRunnable = new PricingRunnable(priceProcess, orderBook);
should be
PricingRunnable pricingRunnable = new PricingRunnable(priceProcess, orderBook);
 
thanks
im not why we have to call a finish if we have a join
 
you use finish to tell the process that it should stop
you use join to wait for it to finish stopping
first you want to signal everything to finish, and only after that you want to wait
in some cases, you do want to assert that some process stopped before telling something else that it can stop though
 
3:14 PM
my mind does not think concurrently, im still struggling with this join() logic
 
"join" just means, "block on this method call until the thread finishes".
 
@Michael thanks
 
3:37 PM
i cant see any example of a finish online
finish() function
 
4:29 PM
@Wietlol but i want to clear the hashmaps first, no?
1) where is the code duplication, all the parts are separate?
2) same as above
3) what is an undescribed method return? all my functions return things?
4) not a big deal here?
5) ill check this now
6) same as earlier
7) no idea what you mean
8) not sure what this is, but this is a small project
 
 
1 hour later…
5:51 PM
@Wietlol this doesnt stop the priceprocess where the multithreading is a bit more complicated
 
 
4 hours later…
9:33 PM
 

« first day (3894 days earlier)      last day (1047 days later) »