But then, after a certain job, I realized that this is probably not the case.
Now I belive that most bad code out thare is made by overworked and tired programmers in a rush to deliver something that works.
11–20 of 239 posts
But then, after a certain job, I realized that this is probably not the case.
Now I belive that most bad code out thare is made by overworked and tired programmers in a rush to deliver something that works.
> There are four main concepts I will talk about here. There are 5 concepts in the article. Off-by-one error? :)
If I was to describe the essence of clean code in one word, I would say "balance". Yes, yes, readability and problem separation and stuff is important, but so is efficiency and usability and security and deadline and everything. Bottom line: balance. And it's the hardest thing to achieve.
Literally anything taken too far is a bad thing. And just about everything in life is a matter of finding the right balance.
He advocates prefixes on variable names. I would like to see good examples of this as I have never seen them as helpful (especially the tblUsers and intUserId type that can be common) .
He eventually gets to "hungarian notation" (those redundant prefixes you don't like) towards the end of the piece. tl;dr: misinterpretation of a good idea, cargo-culted down through the ages.
Isn't this just a fancy phrasing for "make your code easy to read"?
The blog post over states its own importance as after learning these clean code would be easy. Like fade diets, magic paradigms etc... another example of someone believing or trying to convince others that there is a "magic path". "Just remember these four concepts", "get a six pack with just 20 minutes a day"...
There are a few good tips in here but really nothing new. A nice reminder that there are some simple steps to help improve your own code.
A large devil of clean code is not just in nitty gritty "have one line per logical action" but rather the deconstruction of a problem into easily followable steps.
In that way this is definitely not an exhaustive description.
He advocates prefixes on variable names. I would like to see good examples of this as I have never seen them as helpful (especially the tblUsers and intUserId type that can be common) .
All strings that come from [user input] must be stored in variables (or database columns) with a name starting with the prefix "us" (for Unsafe String). All strings that have been HTML encoded or which came from a known-safe location must be stored in variables with a name starting with the prefix "s" (for Safe string).
us = Request("name")
...pages later...
usName = us
...pages later...
recordset("usName") = usName
...days later...
sName = Encode(recordset("usName"))
...pages or even months later...
Write sName
The thing I want you to notice about the new convention is that now, if you make a mistake with an unsafe string, you can always see it on some single line of code, as long as the coding convention is adhered to: s = Request("name")
is a priori wrong, because you see the result of Request being assigned to a variable whose name begins with s, which is against the rules.[1] http://www.joelonsoftware.com/articles/Wrong.html
(edit: formatting, citation)
I used to think that a lot of bad code out there was made by lazy, incompetent programmers... But then, after a certain job, I realized that this is probably not the case. Now I belive that most bad code out thare is made by overworked and tired programmers in a rush to deliver something that works.
I used to think that a lot of bad code out there was made by lazy, incompetent programmers... But then, after a certain job, I realized that this is probably not the case. Now I belive that most bad code out thare is made by overworked and tired programmers in a rush to deliver something that works.
Until you have some code reviewer that thinks otherwise because of some "stupid reason" and you can't get around their hard heads.
One example, breaking a 81 char line because it goes over the limit and getting two shorter lines that are awful to read
So yeah I'll go for this when I'm working with reasonable people