TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Common Species Of Code

91 pointsby GotAnyMegadethover 11 years ago

14 comments

adwfover 11 years ago
The startup one is eerily familiar. I sometimes think the most frequent comment I write is along the lines of &quot;TODO: Should really write a better version of this, but it works for now...&quot;<p>I&#x27;ve even started writing those comments before I&#x27;ve written the function :(
评论 #6712322 未加载
评论 #6712302 未加载
duweaseover 11 years ago
The Enterprise code brings back awful memories of working with a framework architected by someone who had obviously read the Design Patterns book and had the take-away of &quot;Use these as often as they can be wedged in to have a better system.&quot;<p>God forbid I needed to add a single boolean field to a single screen. By the time I submitted the DB change request, then changed the abstract factory interface, then the abstract factory class, then the factory interface that generated, then the factory class, then the abstract DAO interface that generated, then the abstract DAO class, then the parent DAO interface, then the parent DAO class... <i>pauses to catch breath</i> ...then the child DAO interface, then the child DAO class, then the controller object interface, then the controller class, then the actual page, then the unit test, it was 4AM and time to go to sleep.<p>Let this be a cautionary tale to any future architects out there.. remember that flexibility is a MEANS, with the ends being less time and money spent coding and maintaining code. It&#x27;s not an ends to itself, and can even be a hindrance to the ends.
robomartinover 11 years ago
Closed-form expression [0], good up to n == 71:<p><pre><code> def fibonacci(n): gr = (1 + (5**0.5)) &#x2F; 2 return int((gr**int(n) - (-gr)**int(-n)) &#x2F; 5**0.5) </code></pre> [0] <a href="http://en.wikipedia.org/wiki/Fibonacci_number#Closed-form_expression" rel="nofollow">http:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Fibonacci_number#Closed-form_ex...</a>
评论 #6711971 未加载
Tehnixover 11 years ago
In a similar fashion, &quot;The Evolution of a Haskell Programmer&quot; (I&#x27;m sure there are for other langs also) <a href="http://www.willamette.edu/~fruehr/haskell/evolution.html" rel="nofollow">http:&#x2F;&#x2F;www.willamette.edu&#x2F;~fruehr&#x2F;haskell&#x2F;evolution.html</a> :)
评论 #6712550 未加载
benvdsover 11 years ago
A CS 101 student apparently writes the most readable code.
评论 #6711491 未加载
评论 #6712512 未加载
评论 #6712256 未加载
评论 #6712014 未加载
snorkelover 11 years ago
The Large Company version is way too small. It should have at least 20 code files and is provided to other departments as a hosted service that no one has access to due to security restrictions, and the only documentation for how to use it is a powerpoint that is 3 years out of date.
评论 #6712425 未加载
jfasiover 11 years ago
Don&#x27;t forget the tests of each. The startup&#x27;s tests are all commented out because they failed at some point or another, the large company&#x27;s tests are five times as long as the actual code they test, and all other categories consist of the stubs provided by the IDE.
Fargrenover 11 years ago
Why do they all(except Hackaton) use an exponential complexity algorithm for a polynomial time problem? Linear, even.
评论 #6711711 未加载
robomartinover 11 years ago
I&#x27;ve been watching my son go through MIT 6.00.1x. He&#x27;s working on the first midterm this very minute.<p>One of the things I&#x27;ve noticed is that, yes, code quality is from OK to horrid sometimes. Rather than stand behind him and correct every little detail I&#x27;ve let him navigate the problem sets and quizzes mostly on his own. When he gets stuck I give him a shove in the right direction and see what happens.<p>I&#x27;ve reflected on this as I&#x27;ve never really looked at student code. By the time I was a college student taking my first programming course I had already built a number of microprocessor boards, learned how to program them in machine language and moved on to Forth and C. I think my code was reasonably clean by that stage. Still, I know it wasn&#x27;t professional grade by any measure.<p>It&#x27;s easy to forget where we all started from and, as a result, criticize student code as naive. Well, in most cases, it is. That&#x27;s a fact.<p>What I have now realized from watching my son learn to code as well as interacting with him through the process is that he is not learning to code. He is learning to think. He is learning about dissecting problems into small conceptual units that he can then translate into code. Sure, he is learning python in the process. However, the problem solving, solution structuring and problem representation skills that are very much necessary to be a good software developer are mostly language agnostic.<p>Realizing this, the fact that he is writing code that isn&#x27;t the cleanest or the slickest possible solution to a problem stopped bothering me. I want him to learn how to think first.<p>Not to say that I&#x27;ve completely ignored the issue. I let him finish the assignments on his own and then we sit down and do a code review session where I point out where and how things could be better. We&#x27;ve had cases of a dozen lines of code replaced by just a couple. And that&#x27;s OK. That&#x27;s how he is going to learn.
msaneover 11 years ago
Oh man these samples are really well done. Really hilarious.
thaumasiotesover 11 years ago
I wrote an explicit-formula fibonacci function once. I think you lose precision before n=100. It was disappointing.
评论 #6712263 未加载
tudorconstantinover 11 years ago
and the cat writes the most correct code according to most programming best practices - except for giving meaningful names to constants, variables and functions
评论 #6712169 未加载
thatthatisover 11 years ago
The startup code is the cs101 code with two additional cases handled (and minus the contrived x==2 state), and a lot of documented thought about what could be done to improve.
alixaxelover 11 years ago
I think this pretty much nailed the reality. ^^