Everyone can write bad code
madaan.github.io
madaan.github.io
I don’t even highlight as I read, but I would close such a page out of principle.
(I am sure the people who do it consider those who don't weird!)
I think it started in like 1998 when I was a kid using ancient slow browsers on tiny fuzzy monitors over dialup speed internet. I'd be in the middle of reading an article/forum/etc and something would make me lose my place, like a picture (finally) loading above, or trying to scroll at 7 fps and the page jumping way past where I was (I never trusted pgdn), and it would be quite the chore to find my place again. So I started selecting around where I was reading, especially before scrolling, just so I can easily find my place again and it just became a habit.
Now I'm using a giant WQHD monitor at 144 Hz using the fastest page renderer in the world (webrender), so I really don't have those excuses anymore, yet the habit remains. At this point it's probably more ADD and habit than anything else; if I'm not selecting text, I'm fidgeting with something, a pen, usb drive, etc.
Highlighting text as I read helps me out when I'm having trouble focusing on the page.
Yeah, it's a foreach loop. I remember my keywords.
# Set x to 1
x = 1
...not even kidding.
Writing good code is hard,
writing good tests is hard,
writing good docs is hard,
and even harder is writing code to do the right thing.
If someone has lots of exploratory code, trying out different approaches to a problem, maybe producing some performance comparisons, maybe exploring that weird API the other part of the company is offering, these are all valid reasons to not follow a prescriptive methodology.
Yes, having short iterations with working software as a deliverable is great.
Having close contact with your user base for fast feedback is great.
Having continuous integration so that at almost any point we can see genuinely where we are is great.
But honestly, after those three, which I think compare to "use memory managed languages" in the list of genuinely useful software engineering innovations (and let's face it, none of them are software but process, and they are all arguably the same thing - fast feedback loops) I struggle with the religious zeal for pair programming or other "must haves".
it's not they aren't sensible practises, but with a gun to your head, you need to carefully choose what to throw away.
Trying to simplify my argument:
There are no silver bullets left in the software pistol. we can make our code as sweet as we like but the value will come from building the right thing, not building the wrong thing in the right way.
So just strive to write code that _just_ accomplishes your objective.
> writing good tests is hard
So just write tests that are good enough to cover the code you've written.
> writing good docs is hard
So just write docs that are good enough to explain what's necessary to the audience for the doc.
I personally don't see the linked article as evangelical - but maybe that's because I'm brainwashed by the message it. But to me a 16 point list doesn't read at all like a silver bullet.
“Classes less than 9000 LoC have to be combined and do not deserve their own file.”
“Method documentation is just because it is required. Contents can be just the method name.”
“Code reuse is king. If you need different functionality but share at least a field just override all methods and do not call base.”
“Just access the resources you need but don’t bother deaccessing, someone else can do that for you.”
“Method names are worthless, their IDE will suggest them anyway.”
“If you need new functionality but do not want to break the old just add another field and an if statement to enter a new code path.”
\\ cheesy US presenter voice \\ Today! in another episode of code reviews at the office!!
Disclaimer: love my job and my colleagues :)
Oof.
def a(b, c, d, e=None):
if e:
is way more common in my code than it should be.“If you refactor a method without increasing its cyclomatic complexity don’t bother sending for review.”
Unless this was cheeky sarcasm in which case you shouldn't replace the previous point just add this one.
Edit: Now that I think about it, it isn't the re-writing I mind so much, it is the prospect of re-debugging
The trick here is that you have to understand what each tool is doing before you use it, and that's the opposite of what computer languages are driving towards these days. There is a big push towards abstracting away the actual work, potentially so the compiler can apply optimizations under the hood, but this requires the programmer to either know tons of details about what the compiler does, or to trust it implicitly and hope they don't write code that is grossly inefficient. Or maybe what you do is grossy inefficient, but it can be automatically parallelized well so you don't notice it too much.
Making the choice to work with collections that can be accessed in O(log n) rather than O(n^2) is a trivial optimization.
Maybe you don't need to scope out every subroutine, but taking the time to review the basic performance features is something we can all strive to do.
"Optimization" means "making code run faster without changing what it does". If you're changing the code's behavior in an observable way, that's not optimization.
Keywords: small efficiencies.
How it's usually used: I shouldn't think about performance up front at all.
Nothing teaches this better than seeing code making thousands of ephemeral objects in Java in a heap profiler and getting GC stalls with no big place to fix.
The problem begins where deadlines are too close to fix minor inefficiencies...
Maybe someone smarter than me could write about the trade-offs involved with each and when to break the rules.
- click-bait title
- authoritative tone
- devoid of insights or new information
- arguments that are either badly argued or blindingly obvious