New answers tagged

2

Types should be discriminated This way of having one mega container that doesn't discriminate will make the code run through all objects multiple times. Let's imagine there are 10000 objects (because particles, for instance), but only 3 MouseInputter? Well, the CPU will do nothing but loop 99.997% of the time. Just create several Maps: one for your entities ...


4

Overall review I think it's too early to give a profound review of your architecture, so here's only what I found at a quick glance. It would be helpful to see the interface definitions besides the Engine class, at least (with Javadoc, please). Naming conventions With Java naming conventions, method names begin with lower case. Javadoc There are no Javadoc ...


0

Starting with the requirements it's not clear to me why "instead of having all threads running at the same time, we wanted them to timeout." If I understand your goal correctly, you want to implement rate limiting on an executor. It could be used to optimize throughput and mitigate noisy neighbors running on the same machine. There are different ...


2

Your try: value = socket.gethostbyname(s) except socket.gaierror: raise argparse.ArgumentTypeError(f"Host '{s}' could not be resolved.") return value should probably be try: return socket.gethostbyname(s) except socket.gaierror as e: raise argparse.ArgumentTypeError(f"Host '{s}' could not be resolved.") from e in other ...


2

It's finished and works nicely however I am not very happy with having to write twice global host_IP in main() and scan_tcp(). I don't really understand the issue. The variable already has global scope since you assign it a None value on top of your code. Then all you have to do is pass it as a function argument, for example (preferably in lowercase ...


2

Kuba makes excellent points in his answer. I'm going to present some alternatives though: Keep it simple A lot of complexity in your code (and also in Kuba's answer) comes from opening and closing the log file repeatedly. Things simplify greatly if you open it once and keep it open until the Logger is destroyed. Then the code becomes: class Logger { public: ...


5

The design that you claim "works" comes with a caveat: it works extremely poorly. You might not have noticed it when logging is set to a low level or when only one or two threads do the majority of logging. The threads that log infrequently still stall for many orders of magnitude longer than necessary. A simple logger should be able to saturate ...


Top 50 recent answers are included