danrot

joined 1 year ago
 

For some refactoring I needed to find all HTMl tags not being self-closed. I decided to use regular expression for that, and this is what I came up with.

[–] danrot@kbin.social 1 points 9 months ago

I agree that some stuff is easier when not squashing commits, but for the teams I've been working with I've felt that the pros of squashing outweigh the cons, but of course YMMV.

But I didn't know about git bisect skip, thanks for the tip! But sincere question: What happens if there are e.g. three adjacent broken commits? If I have skip all three of those and the error was introduced in one of them, then git cannot tell me which commit introduced the error, right?

[–] danrot@kbin.social 1 points 9 months ago

I swear, I didn't come up with that myself, I read that somewhere else, but of course I don't have a source anymore πŸ™ˆ Maybe some git developer is a huge fan of wordplays?

 

The value of a clean git history is often underestimated. I will explain one of the advantages based on the git bisect command.

 

An approach to standardizing common pattern matching use cases.

 

Mocking libraries come with disadvantages, but fortunately they can be replaced by in-memory implementations, at least for repositories.

 

GitHub uses MySQL to store vast amounts of relational data. This is the story of how we seamlessly upgraded our production fleet to MySQL 8.0.

 

The shell history is cluttered with useless commands if stuff like tokens are included. Shell variables allow to exclude such content from the history.

 

Neovim comes with a very powerful command system, which can even be combined with existing shell commands!

 

It was not trivial to setup nginx with php-fpm to run in separate containers in kubernetes. Therefore I want to explain how I got it to work.

[–] danrot@kbin.social 1 points 11 months ago

I think this is one of the most common misconceptions about DRY. Just because you have two times the same line in your code base it is not automatically a violation of DRY. If you compare if a number is bigger than 18 it is definitely not a good idea to extract that part if you are comparing the hour of the day once and the age the other time. In that case it would even be bad to create an abstration, and it would not be a violation of DRY. And I agree that something like this leads to code that is hard to maintain.

[–] danrot@kbin.social 1 points 11 months ago

I have also seen well commented code, but in this article I concentrate on the bad ones. Are you saying you have never seen a bad code comment?

[–] danrot@kbin.social 1 points 11 months ago

I think this is also in line with my article, since not being able to put yourself into somebody else's shoes (or even in yourself future's ones) is the reason for so much bad comments. But adding a comment to every single line cannot be the solution either, at least not in a higher programming language.

[–] danrot@kbin.social 1 points 11 months ago

I agree with almost all of what you say, but the thing IME is that in most cases people learn to comment a lot, which results in comments that feel like they've been done just for the sake of it, which is one of the main problems IMO. It's not like "just add a comment, it won't hurt", since comments can be immensely misleading and literally take a lot of time until figuring out that the comment was wrong if you trust the wrong ones.

I also agree that this tends to be worse with bad code, which also is not surprising. Sometimes it feels to me like people think they can fix bad code with some comments, and I think that is far from being true.

I also admit that especially the title of the article might be a bit provocative, but giving the general positive sentiment of comments I think this is called for. Sometimes you have to exaggerate a bit to get some attention. I don't like click-baiting either, but unfortunately it works ;-)

[–] danrot@kbin.social 1 points 11 months ago

I give you that, but I am not talking about assembly languages, therefore the examples from my blogpost aren't showing any :-)

[–] danrot@kbin.social 1 points 11 months ago

Totally agree, that's why I also mentioned this in the article.

Very often good code that is self-explanatory does not need any comments at all and if it does, the comment should describe why it has been implemented this way instead of just repeating what the code already says.

 

Comments in code are quite often a code smell. Let’s see what is suboptimal about comments and talk about some strategies to avoid them.

 

Sometimes you want a command to be automatically executed as soon as a certain file changes. There is a small tool called entr, which helps with that.

 

Creating objects is a very basic task. Although this seems like a simple problem, it can be improved by using patterns like builder and factory.

[–] danrot@kbin.social 2 points 1 year ago

Doesn't it also use case and esacand a few others? Such a weird language^^

[–] danrot@kbin.social 1 points 1 year ago (1 children)

That's true, but the syntax is different then. In this blog post I cover fish, and I didn't intent to say that this cannot be done in other shells (and I think I never said so).

 

Quite often I want to execute the same command for multiple files. It is quite easy to achieve that using the fish shell, once you get the hang of it.

view more: next β€Ί