3 ms·
But code like that pass your unit tests, integration test, CI, and LINT? If it does, you may consider to improve the quality of your tests. If you don't have
by siscia 7y ago
But code like that pass your unit tests, integration test, CI, and LINT?
If it does, you may consider to improve the quality of your tests.
If you don't have all of those it is your fault since you are cowboy coding instead of doing engineering and at this point he is playing along.
- mikeash 7y agoHow are tests supposed to help when someone writes atrocious code that works? The posted pseudocode probably gets the job done.
- siscia 7y agoI answer to brother below. Anyhow, if it get the job done, just carry on. The importance of a random snippet of code of a random company is so small that is pointless to discuss about it. Just don't let him do any design work and be quick to throw away bad code and refactor. You got all your tests and procedure in place so it should not be that hard. We are really overestimating the importance and difficulties of our work.
- sethammons 7y agoI don't agree. I think there is no reason to get over pithy about code style. Question one is "does it work," but question two is "can others read and maintain it." By adding in extra logic and lines that do absolutely nothing, the next reader of the code has to slow down and think, "ok, person A did this for a reason, what is their reason..." and disassemble the bad code only to realize that they just waited their time doing so. Readable and maintainable need to be considered for any code that will be maintained or read by others.
- pault 7y agoCan you show me a linter or a unit test that would reject that code?
- siscia 7y agoThe introduction of such tools serve not to prevent bad code to land, but to force people and code into a process. If somebody code is routinely denied to land on code base because of some of the issues catch by automatic tools, it is reasonable to assume that the quality of the code and the thought given to the code will improve. Is this person routinely writing code so bad that passes all the automatic tests? By the way, such code ends up having a quite high cyclomatic complexity.
- pault 7y ago> Is this person routinely writing code so bad that passes all the automatic tests? Yes, a linter or a test cannot know if you are writing silly, unnecessary code, or re-implementing functionality that already exists elsewhere, or making multiple changes downstream when you could make it once upstream. Only a human can see those things, which is why we have code reviews. And for posterity, yes we are using CI, pre-commit linters, unit tests, integration tests, end-to-end tests, and have formal branching, merging, review process, and coding standards. There are no cowboys here, and nothing that you are suggesting will prevent someone from writing low quality code that requires an excessive amount of time to protect the codebase from.