@henrikjernevad@mastodon.social avatar

henrikjernevad

@henrikjernevad@mastodon.social

Software architect and developer with a passion for simple, effective solutions.
Focus on software design and backend development.

Tech: #typescript #kotlin #java

This profile is from a federated server and may be incomplete. Browse more on the original instance.

rjomara, to Blog
@rjomara@mastodon.social avatar

Spent the day trying to come up with a draft of the digital garden setup. It's been a tough one, because I'm not quite able to get to the point I’d like it to be.

But I'm resigned to making something to start with. Something I can improve when my skills and tools allow. So I'll keep plugging away at it.

https://microblog.rjomara.com/2024/05/09/playing-in-the.html

henrikjernevad,
@henrikjernevad@mastodon.social avatar

@rjomara Not sure what tools you are using. I use Obsidian (https://obsidian.md) for my personal note keeping as well as blog writing. Personally, I then use Hugo to generate my site. But i know that many use the first-party Obsidian Publish plugin or the third-party Digital Garden plugin (https://dg-docs.ole.dev). That may be a large change from what you are currently using, but it may perhaps serve as inspiration?

Crell, to Kotlin
@Crell@phpc.social avatar

Having tasted extension functions in , I really really want them in . I am not sure how that would be even feasible, though. 😞

henrikjernevad,
@henrikjernevad@mastodon.social avatar

@Crell @maxalmonte14 I currently write TypeScript and I really miss extension functions too. Especially since the JS standard library is so thin. And map.groupBy(...) is so much nicer than Map.groupBy(map, ...).

And as for hacking the prototype, the big difference is that you explicitly import extension functions when use them. So it is not forced upon anyone else, and the world does not break if someone else creates an extension function with the same name.

henrikjernevad,
@henrikjernevad@mastodon.social avatar

@Crell @maxalmonte14 Yes, I guess a lot of it comes down to if you're coming from a dot-separated/OOP background, or combinator/FP background.

henrikjernevad,
@henrikjernevad@mastodon.social avatar

@Crell @maxalmonte14 I agree. And I think several languages has shown that the last few years. From the ones I am familiar with, Scala was a surprisingly successful FP/OOP hybrid experiment. Then Kotlin took "the best parts to the masses". But even Java and C# has moved a lot towards FP. And JavaScript is flexible and weird enough to fit both camps.

henrikjernevad, to programming
@henrikjernevad@mastodon.social avatar

Today's post discusses moving from imperative while and for loops to declarative collection functions like map and filter.

https://henko.net/blog/there-is-no-loop/

underlap, (edited ) to random
@underlap@fosstodon.org avatar

Just set up webfinger so "AT mastodon AT underlap.org" is an alias for my mastodon account on fosstodon.org. (I can't post the actual account because mastodon replaces it with the account it refers to!)

Thanks to https://guide.toot.as/guide/use-your-own-domain/ and https://stolley.dev/posted/getting-webfinger-to-play-nicely-on-nginx/

henrikjernevad,
@henrikjernevad@mastodon.social avatar

@underlap Can you post as that alias, or will everything translate to the actual address immediately? If you could use it as a "persistent" alias (like I do with a custom domain backed by GMail) I could see myself using that a lot.

henrikjernevad, to random
@henrikjernevad@mastodon.social avatar

All blog posts are now tagged in an attempt to make the blog more browsable. Each post also features a “Related reading” section at the bottom which links to other posts with the same tag(s).

https://henko.net/blog/i-added-tags/

treyhunner, to python
@treyhunner@mastodon.social avatar

So before you remove that "else" statement, think about whether it makes your code more readable or not.

Read more 👉 https://trey.io/FlSco3

henrikjernevad,
@henrikjernevad@mastodon.social avatar

@treyhunner @bugroar Nice post! I thought about this case too. In some languages (e.g. Kotlin) the regular "if statement" is in fact an expression. So then you could have return if (condition) { expression } else { expression } where { expression } can be any number of statements as long as the last one is an expression. This style further highlights the importance of the else branch as removing it would break the expression.

underlap, to random
@underlap@fosstodon.org avatar

Is "release early, release often" as good a policy for personal blog posts as it is for software?

Certainly writing helps clarify your thinking, but what about the publication step? Is publishing a post and responding to feedback an essential step in finding out what you have to say on a subject?

Discuss.

henrikjernevad,
@henrikjernevad@mastodon.social avatar

@underlap I'm sure it is correct from a learning perspective. It probably applies to any "knowledge product". On the flip side, I blog primarily for personal reasons, so I will blog in a way which gives me the most enjoyment. I often get enough of the "do just enough to make it work" kind of tasks at work, so it gives me more satisfaction to allow myself to spend enough time on each post to pass my personal quality standards.

clobrano, to random
@clobrano@fosstodon.org avatar

How does anybody get good in writing software design docs? The more I try, the less I feel confident 🙄

henrikjernevad,
@henrikjernevad@mastodon.social avatar

@clobrano I find it helpful to think about what you want to achieve by writing the documentation. Who is it for? What do you want them to understand? Then think about what you need to say to do that.

Try to put yourself in the shoes of the reader. If they did not know anything except that which you have written, would it make sense? Have you introduced all terms before using them? Do you consistently use the same words for the same concepts? Is each paragraph conceptually coherent?

henrikjernevad,
@henrikjernevad@mastodon.social avatar

@clobrano And of course, you get good at writing design docs like you get good at anything. You practice. 😊

henrikjernevad, to programming
@henrikjernevad@mastodon.social avatar

Why should you unit test? What should you unit test? And how much?

Today's blog post answers these questions and provides some helpful guidelines.

The post is actually a lightly edited extract of a book on unit testing that I started about 10 years ago but never finished. Still, it has aged reasonably well.

https://henko.net/blog/why-write-unit-tests/

henrikjernevad,
@henrikjernevad@mastodon.social avatar

@bluGill Thanks for your comment!

I feel that your conclusion is a bit harsh. Many tests serve other programmers just as well as the original author. For example the "to explain", "to feel safe", and "to get faster feedback" tests. But I could perhaps add a "to prevent future bugs" case.

I do agree with idea that many can be deleted once they've served their purpose. To a large degree, I think that follows from the other sections. But I think it is worth exploring further.

henrikjernevad,
@henrikjernevad@mastodon.social avatar

@bluGill I should also add that tests can fulfill multiple purposes. A test originally added to drive design may very well be one that is then kept to prevent future bugs.

henrikjernevad,
@henrikjernevad@mastodon.social avatar

@bluGill I think it is perfectly reasonable to keep most tests. For example, what you are worried about now seems like a pretty good proxy for what you will be worried for in the future. And why would not the next person working on that unit of code want fast feedback?

henrikjernevad,
@henrikjernevad@mastodon.social avatar

@bluGill Unit testing can obviously not take the place of proper technical writing. But in most projects it is not feasible have a professional tech writer write documentation for every function in the system (or even a majority). Thus tests can play a role of informal documentation. One of the first things people tend to look for in documentation is examples. Tests can provide that.

henrikjernevad,
@henrikjernevad@mastodon.social avatar

@bluGill @underlap I agree. I don't view TDD as a replacement for design. I think of it as a vehicle or structure for doing design. (One of many.) TDD is to design like haiku is to writing poems.

henrikjernevad,
@henrikjernevad@mastodon.social avatar

@underlap @bluGill Yes absolutely! I typically use TDD to drive design at a file or function level. For larger things there is a lot of design before I get to that stage.

But even for more traditional up-front design, I often think "What do I want? What do I need to change to get that?"

I also feel TDD helps a lot with scope control. It makes scope creep or gold plating more obvious.

henrikjernevad,
@henrikjernevad@mastodon.social avatar

@bluGill I updated the post based on your comments, adding sections “To prevent future bugs” and “One test can fulfill multiple purposes”. Thank you for your feedback!

underlap, to random
@underlap@fosstodon.org avatar

I've amalgamated two previous posts on blocking AI web crawlers: https://underlap.org/blocking-ai-web-crawlers

henrikjernevad,
@henrikjernevad@mastodon.social avatar

@underlap Nice post!

But I can't help to wonder, if crawlers/bots will not respect robots.txt, will they provide an honest user agent?

underlap, to random
@underlap@fosstodon.org avatar

A couple of days ago, I had an idea for a useful utility and so today I thought I'd have a go at starting to code it. It felt like chiselling granite. Why should that be?

New post: Starting a new programming project, https://underlap.org/starting-a-new-programming-project

henrikjernevad,
@henrikjernevad@mastodon.social avatar

@underlap And if it is a personal project, who cares if you make it "unnecessarily" reusable? It is your project! 😊

henrikjernevad, to programming
@henrikjernevad@mastodon.social avatar

I think that testable code is reusable code. When you test a function, you run the code in another context than it was built for (the production code). If your code is not reusable you will feel that pain in your tests.

This blog post gives an example of how getting side effects out of functions make them both easier to test and reuse.

https://henko.net/blog/testable-code-is-reusable-code/

henrikjernevad, to programming
@henrikjernevad@mastodon.social avatar

“Temporal dependencies” sounds complicated, but it is really just a fancy way of saying “things that must be done in the right order”. And you can make your code better by removing them.

https://henko.net/blog/remove-temporal-dependencies/

henrikjernevad,
@henrikjernevad@mastodon.social avatar

@underlap Your right, in the example I made the assumption that controlling the timing of the initialization was valuable, otherwise the init function could have been private.

As for thread safety, JavaScript generally runs on a single thread, so there should be no race conditions. (Assuming there is only one place where init is called.) There are exceptions though: https://henko.net/blog/death-by-a-thousand-inconsistencies/

bluGill, to programming
bluGill avatar

Have you ever mocked your logger in a test, or wished you could? That is something like

TEST(some test name)

    mockLogger logger

    logger.expect_call(log("some string"))

    DoSomething(logger)

henrikjernevad,
@henrikjernevad@mastodon.social avatar

@bluGill @DmMacniel If I want to log things that are important enough for me to test, I would consider creating a custom interface with individual functions for each important event. Then I would make one implementation of that interface which performs the corresponding logging, and another implementation which can be used for test. That way it becomes clear that the behavior is important, and avoids string parsing to extract the important information.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • anitta
  • mdbf
  • magazineikmin
  • InstantRegret
  • hgfsjryuu7
  • Durango
  • Youngstown
  • slotface
  • everett
  • thenastyranch
  • rosin
  • kavyap
  • khanakhh
  • PowerRangers
  • Leos
  • DreamBathrooms
  • vwfavf
  • ethstaker
  • tacticalgear
  • cubers
  • ngwrru68w68
  • modclub
  • cisconetworking
  • osvaldo12
  • GTA5RPClips
  • normalnudes
  • tester
  • provamag3
  • All magazines