The use case to check an HTTP link is broken or not sounds quite simple to implement on the surface. But the implementation soon gets messy when the number of tasks, such as searching for HTTP Strings in multiple files, sending HTTP requests, receiving HTTP responses, and displaying those responses to the console, grows drastically enough to consume too much resources of a computer and eventually freezes the machine.
I am using Java to program the httplinkchecker. Multi threading is my first consideration to reduce the performance bottleneck, of course, at the cost of making the code complicated.
During my initial research, I found HashMap was mostly frequently used to store links found in a file. I use ArrayList instead because of simplicity. However, when trying to retrieve and store links from all the files of a sub-directory, I force myself into using ArrayList of ArrayList, which gives me unease feeling about this data structure without knowing the exact reason.
After reviewing my colleagues who program the same tool in Java, I find it quite amusing on the way a C/C++ programmer programs in Java. It IS really hard to learn a new language well, let alone thinking in its idioms. Since Java claims to be an Object Oriented programming language, you can usually hear a new programming learner complains that the language forces one to construct everything in objects. Well, at least one solution exists: to throw everything into one giant class.
The following are links to my interactions with our colleagues:
1. https://github.com/jossiey/LinkChecker-CmdLC/issues/3
2. https://github.com/pyvelkov/DeadLinkage/issues/8
Top comments (0)