Elektrine lite

← Feed

@amio@lemmy.world

Post #2225090

2026-04-20 18:20 UTC

Realistically, whichever one is the most commonly used in your project/framework/language/whatever, so it doesn't stick out as an inconsistency. If you're wondering about this now, it's a potential point of confusion for anyone who needs to read the code, including future you. If you want to be really picky about engineering: are you sure you do need to write the function at all? How does the new function save time/effort or make code easier to read and write? Do you write a lot of code where you need random vectors, and does "random vector" mean the same thing in all cases? Would the function itself just make more code that needs maintaining, possibly indefinitely?

Replies (1)

  • I already named the variables minimum and maximum, so inclusive should make more sense. The code generates a vector within a square/cube defined by 2 other vectors. Those are all good questions, and yes. - It saves time because I (and future plugin users) don't have to implement placing a vector in 2/3d space randomly, and it makes the code cleaner. - Not a lot, and yes. - The function is pretty much set-and-forget, but I might write an unit test just in case the laws of mathematics change overnight.

    Open ##2225092