5 ms·
I'm glad you had a positive experience, but I'd like to point out that thinking about legibility, whitespace, naming etc should be done regardless of highlighti
by scottLobster 11y ago
I'm glad you had a positive experience, but I'd like to point out that thinking about legibility, whitespace, naming etc should be done regardless of highlighting.
I don't blame you, IMO it's one of the major issues with computer science education. Even basic principles of clean code are often neglected or never taught, in large part due to the lack of professional experience in academic circles. This leaves aspiring developers to figure it out on their own, as you did through turning off highlighting. I'm glad you did, but there are better ways to learn the same concepts IMO.
- crdoconnor 11y ago>Even basic principles of clean code are often neglected or never taught, in large part due to the lack of professional experience in academic circles. There's a lack of experience in professional circles too. One of the questions I always ask during programming interviews (on either side) is "is your code clean? if so, why?". Invariably the answer is a variant along the lines of "if it passes the linter it's clean", which is stupid. I'd like to say that's an automatic fail or automatic "don't work at this company" but it's just far too common.
- dave2000 11y agoPerhaps you should use a less ambiguous term than "clean". They're giving you a correct answer, so perhaps you should ask the correct question? "Is your code readable", perhaps? "Are you proud of your code?". Something like that. No-one's going to admit their code isn't clean, regardless of how they interpret that term.
- true_religion 11y agoI think 'clean' can only be evaluated in context. For instance, whenever I write code for public distribution I try to use the same layout principles and code style rules that are popular within my target audience. Additionally, I try to present concepts in a way that will either be idiomatic to the target audience or at the very least not judged as unusual. To give a silly hypothetical example. If I were writing code to be delivered to a company that never uses list comprehensions within Python, I'd write everything as an explicit for-in-loop. This is less of a problem in certain languages where there's explicit global style guides and a tendency to conservatism (Python). Other communities where that's not the case, like Smalltalk, Lisp, and now Elixir, one can see varying control statements and code inheritance methodologies practiced by different groups simply because of how easy it is to implement, and that doing so isn't shunned.
- crdoconnor 11y ago>They're giving you a correct answer Is spaghetti code clean if it lints successfully?
- dave2000 11y agoYes. And no. Depends on the context. Microsoft and malware coders both think windows is great for the same reason; it's very popular.
- crdoconnor 11y ago>Yes. Depends on the context. I can't think of any context where I'd consider spaghetti code clean. It's exact opposite of clean.
- dave2000 11y agoClean...in the sense that it passes lint, unit testing, continuous integration etc. Not clean in the sense that "internet user #1209828 approves of its aesthetics", which is a metric subject to fashion, opinion etc.
- raarts 11y agoIt's A correct answer but not THE correct answer. The best answer would be clean code is just beautiful and that's why I strive for it.
- marssaxman 11y agoLeaving the definition of "clean" ambiguous does give you some useful information, though, because the context implied by the answer shows you something about the interviewee's priorities. Of course their code is "clean" according to whatever metric is important to them - but what's their metric? What are they focusing on as they work?
- lokedhs 11y agoThis reminds me of one of my favourite peeves when reading code written by maths people: Every variable is one or two characters long, the code barely indented, and absolutely no spaces anywhere in the code. Given that a lot of mathematics involves computer programming these days, I find it remarkable that basic programming principles does not seem to be taught at all. My point here is that this is not just a problem in computer science education. It seems as though every field that touches on programming fails spectacularly in this regard.