20 seconds, Germany. Waiting while they checked if my name was on the list.
20 seconds, Germany. Waiting while they checked if my name was on the list.
Completely depends on how often you need to write boilerplate code, and how error-prone it is.
After writing hundreds of instances of ‘fetch this from the server and show an error if it doesn’t work’, I finally wrote a helper for that. It took 2 hours, shouts at me if I use it wrong, and instantly makes my classes easier to read because all the boilerplate is gone. As an added bonus, the invocation is so small that Copilot can write it error-free, which it couldn’t before.
So fetching things is now a thing of a few seconds instead of one minute with a chance of making a mistake. I say it’s worth it.
C) Write a highly specific, custom-tailored boilerplate generator that does 80% of the work and needs only a day or two to implement.
Vanilla Music – the music player I use.
Psst. We don’t do logic here.
Coding must be a nightmare if you’re choosing programming languages at random 😱
But you must also be learning quite a lot.
Programs aren’t written by a single team of developers that speak the same language. You’d be calling a library by a Hungarian with additions from an Indian in a framework developed by Germans based on original work by Mexicans.
If no-one were forcing all of them to use English by only allowing English keywords, they’d name their variables and functions in their local language and cause mayhem to readability.
[Edit:] Even with all keywords being forced to English, there’s often half-localized code.
I can’t find the source right now, but I strongly believe that Steve McConnell has a section in one of his books where he quotes a function commented in French and asks, “Can you tell the pitfall the author is warning you about? It’s something about a NullPointerException”. McConnell then advises against local languages even in comments
LIFETIME MEMBERSHIP $300
I’m inclined to buy that just because it exists. I hate subscription services so, so much!
This is the best option if you think you’ll use Nebula for more than 5 years.
I work in IT. We get notified when people leave.
The cruelest thing in my company is when we get to know before the person in question…
For the others: https://www.youtube.com/watch?v=UqHh6TvGQIQ
It might be from Flight of the Phoenix (2004) https://en.wikipedia.org/wiki/Flight_of_the_Phoenix_(2004_film)
Just to provide some data on the radiation dose. It’s everyone’s own decision whether a ‘willy-nilly’ PET scan is worth it.
From the English Wikipedia:
FDG, which is now the standard radiotracer used for PET neuroimaging and cancer patient management, has an effective radiation dose of 14 mSv.
The amount of radiation in FDG is similar to the effective dose of spending one year in the American city of Denver, Colorado (12.4 mSv/year). […T]he whole body occupational dose limit for nuclear energy workers in the US is 50 mSv/year.
https://en.wikipedia.org/wiki/Positron_emission_tomography#Safety
From the German Wikipedia:
Es ist bei einer Strahlendosis von 1 Sievert (Sv), der 100 Menschen ausgesetzt sind, mit 5 Todesfällen durch Strahlenkrebs zu rechnen […]. Man müsste also 100.000 PET-Untersuchungen durchführen, um 35 Todesfälle an Strahlenkrebs (nach einer mittleren Latenzzeit von etwa 15 Jahren für Leukämie und etwa 40 Jahren für solide Tumoren) zu verursachen, das heißt etwa eine auf 3000 Untersuchungen
If 100 people received a radiation dose of 1 Sievert (Sv), one would expect 5 deaths due to radiation-induced cancer […]. One would need 100,000 PET scans in order to cause 35 cancer deaths (after a median wait duration of 15 years for leucemia and 40 years for solid tumors), which is about 1 in 3000 scans.
https://de.wikipedia.org/wiki/Positronen-Emissions-Tomographie#Strahlenexposition
You must have exceptionally competent first-level support.
A text editor that doesn’t assume that the keys on my keyboard are in the same order as yours.
Are all public clocks in the US digital clocks? Off the top of my head, I can tell you 4 locations within walking distance that have analog clocks, one of them being the train station.
Thank you for linking the blog posts. They are a really good deterrent from Clean Code. I once thought I’d read it, but Fowler’s advice really is stupid.
In case you’re wondering why I replied three times: “Do one thing” :)
Exceptions are just bad. They are a separate, hidden control flow that you constantly need to be wary of. The name itself is a misnomer in my opinion, because they’re rarely exceptional: errors are not just common, but an integral part of software development
They may be a part of software development, but they should not be common during the normal execution of software. I once read the hint, “if your app doesn’t run with all exception handlers removed, you are using exceptions in non-exceptional cases”.
Throwing an exception is a way to tell your calling function that you encountered a program state in which you do not know how to proceed safely. If your functions regularly throw errors at you, you didn’t follow their contract and (for instance) didn’t sanitize the data appropriately.
Errors as values are much clearer, because they explicitly show that a function may return an error and that it should be handled.
I disagree here. You can always ignore an error return value and pretend that the “actual” value you got is correct. Ignoring an exception, on the other hand, requires the effort to first catch it and then write an empty error handler. Also (taking go as an inspiration), I (personally) find this very hard to read:
res, error = try_something()
if error {
handle_the_error(error)
return_own_error()
}
res2, error2 = try_something_else(res)
if error2 {
handle_other_error(error2)
return_own_error()
}
res3, error3 = try_yet_something_else(res2)
if error3 {
handle_the_third_error(error3)
return_own_error()
}
return res3
This code mingles two separate things: The “normal” flow of the program, which is supposed to facilitate a business case, and error handling.
In this example, on the other hand, you can easily figure out the flow of data and how it relates to the function’s purpose and ignore possible errors. Or you can concentrate on the error handling, if you so choose. But you don’t have to do both simultaneously:
try {
res = try_something()
res2 = try_something_else(res)
res3 = try_yet_something_else(res2)
return res3
} catch (e) {
// check which error it is and handle it appropriately
throw_own_exception()
}
Functions should be small and do one thing […] you end up with a slew of tiny functions scattered around your codebase (or a single file), and you are forced to piece together the behaviour they exhibit when called together
I believe you have a wrong idea of what “one thing” is. This comes together with “functions should not mix levels of abstraction” (cited from the first blog entry you referenced). In a very low-level library, “one thing” may be sending an IP packet over a network interface. Higher up, “one thing” may be establishing a database connection. Even higher up, “one thing” may be querying a list of users from the database, and higher up yet again is responding to the GET /users
http request. All of these functions do ‘one thing’, but they rely on calls to a few methods that are further down on the abstraction scheme.
By allowing each function to do ‘one thing’, you decompose the huge problem that responding to an HTTP request actually is into more manageable chunks. When you figure out what a function does, it’s way easier to see that the function connectToDb
will not be responsible for why all users are suddenly called "Bob"
. You’ll look into the http handler first, and if that’s not responsible, into getUsersFromDb
, and then check what sendQuery
does. If all methods truly do one thing, you’ll be certain that checkAuthorization
will not be related to the problem.
Tell me if I just didn’t get the point you were trying to make.
Edit: I just read
Martin says that functions should not be large enough to hold nested control structures (conditionals and loops); equivalently, they should not be indented to more than two levels. He says blocks should be one line long, consisting probably of a single function call. […] Most bizarrely, Martin asserts that an ideal function is two to four lines of code long.
If that’s the standard of “doing one thing”, then I agree with you. This is stupid.
At the end of my 20s I can feel that I’m becoming stupider. Reading texts or just thinking about a problem take more effort than they used to.
It feels like I’m thirty years too young to get these jokes.