<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Babafemi Kuku on Medium]]></title>
        <description><![CDATA[Stories by Babafemi Kuku on Medium]]></description>
        <link>https://medium.com/@babafemikuku?source=rss-b9d403c93c14------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*uEAUB7lxvypbaZOMsgRuIA@2x.jpeg</url>
            <title>Stories by Babafemi Kuku on Medium</title>
            <link>https://medium.com/@babafemikuku?source=rss-b9d403c93c14------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 09:49:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@babafemikuku/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Functional options may not always form closures]]></title>
            <link>https://medium.com/@babafemikuku/functional-options-may-not-always-form-closures-b428661ee7b0?source=rss-b9d403c93c14------2</link>
            <guid isPermaLink="false">https://medium.com/p/b428661ee7b0</guid>
            <dc:creator><![CDATA[Babafemi Kuku]]></dc:creator>
            <pubDate>Tue, 06 Oct 2026 00:00:21 GMT</pubDate>
            <atom:updated>2026-10-08T21:55:09.435Z</atom:updated>
            <content:encoded><![CDATA[<p>This post builds on our <a href="https://babafemikuku.com/posts/go-closures-functional-options-pattern">previous discussion</a>, where we took a deep dive into closures using the Functional Options Pattern. Please refer to it before going through this.</p><p>Here, we’d be taking it a little bit further.</p><p>We saw how something like WithHost(&quot;localhost&quot;) returned a function that still had access to host when that function was called later.</p><p>At this point, it would be tempting for you to think that:</p><blockquote>Functional Options = closures.</blockquote><p>But…that’s not quite right. Why?</p><p>Closures are one way to use the <em>functional options</em> pattern, but they’re not a requirement.</p><p>I discovered this myself when I was poking around the <a href="https://github.com/aws/aws-sdk-go-v2">AWS SDK for Go</a>. It has a WithPresignExpires option that looks very similar to the closure-based example we discussed in my previous post, but there&#39;s something different going on underneath.</p><p>So, let’s take a look.</p><pre>func generatePresignedURL(s3Client *s3.Client, bucket, key string, expireTime time.Duration) (string, error) {<br>    presignClient := s3.NewPresignClient(s3Client)<br><br>    objectInput := &amp;s3.GetObjectInput{<br>        Bucket: &amp;bucket,<br>        Key:    &amp;key,<br>    }<br><br>    presignedHTTPRequest, err := presignClient.PresignGetObject(context.Background(), objectInput, s3.WithPresignExpires(expireTime))<br>    if err != nil {<br>        return &quot;&quot;, err<br>    }<br><br>    return presignedHTTPRequest.URL, nil<br>}</pre><p>Here, I was working on a function that returns presigned URL for an object in an s3 bucket, so I needed to use PresignGetObject from the SDK. I want you to focus on the last argument that PresignGetObject takes. Notice the With... pattern.</p><p>You might expect that it returns a closure just like we discussed in the previous post. But notice what I found when I poked around:</p><pre>func WithPresignExpires(dur time.Duration) func(*PresignOptions) {<br>    return withPresignExpires(dur).options<br>}<br><br>type withPresignExpires time.Duration<br><br>func (w withPresignExpires) options(o *PresignOptions) {<br>    o.Expires = time.Duration(w)<br>}</pre><p>WithPresignExpires doesn&#39;t return a closure!</p><p>So, what does it return? We learnt that closures help functions remember stuff in their lexical scope right, so how does dur survive after WithPresignExpires is eventually called? There&#39;s no closure here, so what&#39;s up?</p><h3>Enter Methods as Values</h3><p>We’d come back to functional options. Let’s take a little detour if you don’t mind.</p><p>In Go, <a href="https://go.dev/tour/methods/1">methods</a> are simply functions that are associated with a type.</p><p>For example:</p><pre>// a type<br>type Server struct {<br>    host string<br>}<br><br>// a method<br>func (s *Server) setHost(host string) {<br>    s.host = host<br>}</pre><p>Notice it looks like a function but with some special kind of backpack (called it’s receiver).</p><p>Normally, we expect to call the method directly like so:</p><pre>// type initialized<br>server := &amp;Server{}<br><br>// you have called me now<br>server.setHost(&quot;localhost&quot;)</pre><p>But, hey! There’s something else we can do.</p><p>We can take the method and bind it to it’s receiver, and then assign it to a variable rather than call it now:</p><pre>// you can invoke me later<br>setHost := server.setHost</pre><p>Now setHost is a variable that holds a <em>method value</em> that we can call later:</p><pre>// invoking the method value we stored<br>setHost(&quot;localhost&quot;)</pre><p>So what’s going on here?</p><p>When we write:</p><pre>setHost := server.setHost</pre><p>the server struct value is already attached/binded/glued to the setHost method we defined earlier.</p><p>That’s what a method value is: a method with its receiver already bound to it, which you can call later.</p><blockquote>Note that the name of the variable that keeps the method value can be anything. But I think it just makes sense to name it according to the method name, so when you call it later, you easily know what you’re calling. That’s why I named the variable setHost to match the method setHost. But you could have done:</blockquote><pre>anotherName := server.setHost<br><br>anotherName(&quot;localhost&quot;)</pre><h3>Back to the AWS example, shall we?!</h3><p>Now let’s look at this line again:</p><pre>...<br>return withPresignExpires(dur).options<br>}<br><br>type withPresignExpires time.Duration<br><br>func (w withPresignExpires) options(o *PresignOptions) {<br>    o.Expires = time.Duration(w)<br>}</pre><p>We can break it down.</p><p>First, withPresignExpires(dur) converts the dur value of type time.Duration to a value of type withPresignExpires (a custom type).</p><p>And when we write withPresignExpires(dur).options we&#39;re simply binding the options method to the value we just converted (a.k.a it&#39;s receiver), which we can call later.</p><p>So conceptually:</p><pre>option := withPresignExpires(dur).options</pre><p>means:</p><p>“Keep this method value inside an option variable, so I can call it later.&quot;</p><p>And when it runs, the receiver w is still the withPresignExpires value created from dur.</p><p>Notice the difference between calling the method immediatley and storing, then calling later:</p><pre>// called immediately<br>withPresignExpires(dur).options(presignOptions)<br><br>// saved in a variable and called later<br>option := withPresignExpires(dur).options<br>option(presignOptions)</pre><h3>Let’s call it a wrap</h3><p>Unlike our previous closure example, where reference to a value is captured inside an enclosing function. Here, dur isn&#39;t being captured from an enclosing function scope. The dur value became the receiver of the option method. And anything we were ready to call the method value, the dur value (method receiver) we created is still alive and would be referenced by the method.</p><p>So the key lesson here is that: closures remember variables from an enclosing scope, while method values carry around their receivers with them.</p><p>Both of them allow you produce a function that you can pass around, remember values, and call later. And that’s exactly what the functional optional pattern needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WQkVBMvqpHv_6TAG5HBYOQ.png" /></figure><p>The functional options pattern doesn’t require closures specifically. It simply requires functions that can be used to configure something. Closures and method values are just two different ways to produce those functions.</p><p>See you in the next one. :)</p><p><em>Originally published at </em><a href="https://www.babafemikuku.com/posts/functional-options-may-not-always-form-closures"><em>https://www.babafemikuku.com</em></a><em> on October 6, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b428661ee7b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding closures in Go through the functional options pattern]]></title>
            <link>https://medium.com/@babafemikuku/understanding-closures-in-go-through-the-functional-options-pattern-bd9d6da056cb?source=rss-b9d403c93c14------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd9d6da056cb</guid>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Babafemi Kuku]]></dc:creator>
            <pubDate>Fri, 25 Sep 2026 00:00:23 GMT</pubDate>
            <atom:updated>2026-09-28T21:40:49.804Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Closures might sound like one of those advanced Go concepts, but they’re easier to understand than you think.</em></p><p>I came across this <a href="https://golang.cafe/blog/golang-functional-options-pattern">article</a> lately explaining 3 different and common ways to configure a server, with functional options pattern being the main idea or talking point (you can skim through the <a href="https://golang.cafe/blog/golang-functional-options-pattern">article</a> and come back). So I thought I’d build on it and explore one of the concepts commonly used to implement that pattern: <em>closures.</em></p><p>In this post, we’ll use the Functional Options Pattern to understand what closures are, how they work, and why they make this pattern possible.</p><h3>Let’s start with the name</h3><p>Let’s be honest, the name sounds like one of those Go concepts you only get to understand after becoming a senior engineer, right?</p><p>But… it turns out that it’s quite simpler than you thought. So, let’s break it down.</p><p><em>Functional.</em> Easy peasy right?! Functional simply means…functions are involved. So like in the second example from the article, rather than pass configuration values to your server, we pass functions that do the configurations.</p><p><em>Options.</em> Also simple. Options mean…options. You’ll want to be able to pass different things into what you’re creating; like host, port, maximum connections etc. Options means you’re not forced to pass in some exact set of things, you can pass in anything you want to pass in. So nothing really mysterious here.</p><p>And finally… <em>pattern.</em> Well, a pattern is just a reusable way of solving problems.</p><p>Bringing it all together, it’s safe to define functional options pattern as a reusable patters where functions are used as optional configurable options. In other words, functions are the options you pass in.</p><p>But there’s a piece of ‘magic’ hiding inside those functions.</p><h3>Closures</h3><p>Let’s take a look at the Functional Options Pattern from the article. This is one of the configuration options.</p><pre>func WithHost(host string) func(*Server) {<br>    return func(s *Server) {<br>        s.host = host<br>    }<br>}</pre><p>At first glance, this looks pretty straightforward.</p><p>WithHost receives a host, and instead of using it immediately, it returns a function.</p><p>Notice something interesting here: What happens to host after WithHost finishes executing?</p><p>You might expect it to disappear since it was a parameter belonging to WithHost. But, when the returned function is called later, it can still access host (the returned functions from WithPort, WithTimeout, WithMaxConn behave the same way too).</p><p>How are they able to do this?! Because they are <em>Closures.</em></p><p>A closure is simply the combination of a function with references from the its surrounding scope where it was created.</p><p>In our example, we say the returned function <em>closes</em> over the host variable.</p><p>So when we do:</p><pre>// option now holds the returned function<br>option := WithHost(&quot;localhost&quot;)<br><br>// The returned function still has access to `host`,<br>// and `host` is &quot;localhost&quot;.<br>option := func(s *Server) {<br>    s.host = host<br>}<br><br>option(server)</pre><p>So, option is not just holding a ‘regular’ function. The function it holds still has access to and makes reference to the variables from the scope where it was created, even though that enclosing function had already finished executing.</p><p>And that’s the closure.</p><h3>Back to the pattern</h3><p>Now that you understand closures, the Functional Options Pattern should look a lot less mysterious.</p><p>Do you remember the original example from the post?</p><pre>server.New(<br>    server.WithHost(&quot;localhost&quot;),<br>    server.WithPort(8080),<br>    server.WithTimeout(time.Minute),<br>    server.WithMaxConn(120),<br>)</pre><p>To be more verbose, here’s what’s happening:</p><pre>server.New(<br>    func(s *Server) {<br>        s.host = host // &quot;localhost&quot;<br>    },<br>    func(s *Server) {<br>        s.port = port // &quot;8080&quot;<br>    },<br>    func(s *Server) {<br>        s.timeout = timeout // &quot;time.Minute&quot;<br>    },<br>    func(s *Server) {<br>        s.maxConn = maxConn // &quot;120&quot;<br>    },<br>)</pre><p>Each With... function creates a closure that remembers the value it was given. New(options ...func(s *Server)) then receives those functions and invokes them to configure the Server.</p><p>Now that you know what’s happening inside those With... functions, you might find that the Functional Options Pattern makes a lot more sense.</p><p>So if you skimmed through the reference <a href="https://golang.cafe/blog/golang-functional-options-pattern">article</a> at the beginning, this might be a good time to go back and read it again.</p><p>See you in the next one!</p><p><em>Originally published at </em><a href="https://www.babafemikuku.com/posts/go-closures-functional-options-pattern"><em>https://www.babafemikuku.com</em></a><em> on September 25, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd9d6da056cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Collecting blogs]]></title>
            <link>https://medium.com/@babafemikuku/collecting-blogs-864e388551da?source=rss-b9d403c93c14------2</link>
            <guid isPermaLink="false">https://medium.com/p/864e388551da</guid>
            <dc:creator><![CDATA[Babafemi Kuku]]></dc:creator>
            <pubDate>Wed, 16 Sep 2026 13:58:10 GMT</pubDate>
            <atom:updated>2026-09-29T09:18:57.336Z</atom:updated>
            <content:encoded><![CDATA[<p>A collection of my favorite engineering and dev blogs.</p><h4>By person</h4><ul><li><a href="https://blainsmith.com/">Blain Smith</a></li><li><a href="https://dave.cheney.net/">Dave Cheney</a></li><li><a href="https://www.jim-nielsen.com/">Jim Nielsen</a></li><li><a href="https://www.ssp.sh/posts/">Simon Späti</a></li><li><a href="https://terriblesoftware.org/">Terrible Software</a></li></ul><h4>By company</h4><ul><li><a href="https://www.datadoghq.com/blog/engineering/">Datadog</a></li><li><a href="https://www.mailgun.com/blog/">Mailgun</a></li><li><a href="https://posthog.com/blog">PostHog</a></li><li><a href="https://blog.sentry.io/">Sentry</a></li><li><a href="https://temporal.io/blog">Temporal</a></li><li><a href="https://www.twilio.com/en-us/blog">Twilio</a></li><li><a href="https://news.ycombinator.com/news">Y Combinator: Hacker News</a></li></ul><p><em>Originally published at </em><a href="https://www.babafemikuku.com/posts/collecting-blogs"><em>www.babafemikuku.com</em></a><em> on September 10, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=864e388551da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Going with Go]]></title>
            <link>https://medium.com/@babafemikuku/going-with-go-92d6c092d17e?source=rss-b9d403c93c14------2</link>
            <guid isPermaLink="false">https://medium.com/p/92d6c092d17e</guid>
            <dc:creator><![CDATA[Babafemi Kuku]]></dc:creator>
            <pubDate>Mon, 14 Sep 2026 00:00:46 GMT</pubDate>
            <atom:updated>2026-09-16T22:30:20.385Z</atom:updated>
            <content:encoded><![CDATA[<p>Whether it’s for a new job, a side project, or out of boredom, I’ve always had a knack for learning new stuff. After1̶2̶0̶ ̶y̶e̶a̶r̶s̶ 4 years of React-bending (yes, like the Avatar), I decided it was time to learn a new element.</p><p>In this post, I’ll be sharing why I decided to learn Go and how it’s going.</p><h3>It’s…just simple</h3><p>It’s been about a year since I picked up Go, 3 months since I started contributing to production software with it, and I still maintain what I initially assumed about it; it’s simple. Though, despite it’s simplicity, I didn’t like it at first. In fact, I had to abandon it for about a month or so. It wasn’t because it was complex, I just wasn’t comfortable with some of its syntax; capitalizing types to make them public, the numerous ways to print stuff, and a couple of other things that felt strange coming from JavaScript/TypeScript backgound. But after returning to it, and the more I used it, the more those things actaully made more sense.</p><p>One of the things that fascinated me early on was seeing what people were able to build with so little code. I remember coming across a web crawler written in Go that was only about 240 lines long (excluding import statements). The idea that something useful and powerful could be implemented so concisely made me even more curious about the language. You can find the repository <a href="https://github.com/afazio1/web-crawler/blob/main/main.go">here</a>.</p><p>When I say it’s simple, I mean in terms of predictability and readability; when I pick up 5 different Go codebases that solve different problems, I can easily follow along because there aren’t too many constructs or diverse patterns to solve problems, the language encourages conventional approaches.</p><p>I also consider explicitness an act of simplicity. An example is error handling. Coming from a JS/TS background, you have to throw and handle errors that jump across your code. In Go, you handle errors <em>explicitly</em> right where they happen. I strongly believe that all of the above have made it easy for me to maintain and debug applications easily till this point.</p><h3>The things that hooked me</h3><p>When it comes to learning a programming language, high availability of resources is a huge factor for me. At first, I didn’t have to guess which tutorial was good or not good, or a waste of time. With Go, a bulk of stuff I needed to get me started was right there on the official <a href="https://go.dev/learn/">website</a>.</p><p>Another resource I immediately fell in love with was <a href="https://gobyexample.com/">Go by Example</a>. The simplicity of seeing core concepts at a glance, as well as code snippets right beside them was a major win for me. It’s a very straight to the point source of knowledge. I still refer to it a lot in my day-to-day work, and it’s one of my favourite places to go when I need a refresher.</p><p>A third resource I came across was <a href="https://quii.gitbook.io/learn-go-with-tests/">learn go with tests</a>. This one teaches Golang with an emphasis on test-driven development. I loved how it reinforces TDD patterns and teaches you to write tests in a step-wise fashion.</p><p>Lastly, one of my favs that drew me closer to the language was <a href="https://www.boot.dev/">Boot.dev</a>. After going through a couple test lessons, I knew I had to subscribe. And since then, it’s been the platform I’ve learned Go from the most.</p><p>One can go through some resources and gradually fall in love with them later. For me, these resources got me hooked instantly.</p><h3>So…what’s the point? ¯\(ツ)/¯</h3><p>If there’s anything that I want you to take away from this, it’s that you don’t have to like something immediately for it to be worth learning.</p><p>When I first picked up Go, some of its conventions felt unnecessarily strange to me. I put it down for a while. But coming back to it with better resources and more context completely changed how I saw the language.</p><p>So if you’re picking up something new, don’t spend forever looking for the perfect course, tutorial, bootcamp, or roadmap. Find a few solid resources, bury yourself in them, and give yourself enough time to get past the parts that are unfamiliar.</p><p>You might not fall in love with the thing immediately. That’s okay.</p><p>Sometimes, you just need to spend enough time with it before the things that felt strange start to make sense.</p><p><em>Originally published at </em><a href="https://www.babafemikuku.com/posts/going-with-go"><em>https://www.babafemikuku.com</em></a><em> on September 14, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92d6c092d17e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hello, world!]]></title>
            <link>https://medium.com/@babafemikuku/hello-world-4fc8b1341307?source=rss-b9d403c93c14------2</link>
            <guid isPermaLink="false">https://medium.com/p/4fc8b1341307</guid>
            <dc:creator><![CDATA[Babafemi Kuku]]></dc:creator>
            <pubDate>Sat, 01 Aug 2026 00:00:12 GMT</pubDate>
            <atom:updated>2026-09-16T09:53:25.074Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi there! Welcome to my new <a href="https://www.babafemikuku.com/">website</a>. In this short one, I’d be sharing with you about why I went back to the drawing board. Enjoy!</p><h3>A change of focus</h3><p>In my previous site, I spent so much time stressing over how beautiful and engaging I needed it to look. I cared so much about cooking up the perfect micro interactions, how to factor in sleek gsap-style animations and other things that make a site “pop” and feel engaging. Overtime, I realized that it made me lose focus from what I really wanted my site to be about: <em>communicating knowledge with simplicity and clarity</em>. I want to focus more on my writing much more than the visual appeal and interactions on my site.</p><h3>Keeping it simple</h3><p>Over the course of my journey as a software engineer, I’ve come to really appreciate and work towards <em>simplicity</em>. In a world where creating stuff is now cheap, simplicity in my opinion would be a distinguishing element. So I wanted something very minimal, with less design choices, little or no animations, colors, elements; nothing too fancy. Just a place I plan to write, and write, and just write, communicate knowledge and share my experience! I look forward to seeing my blog posts grow in quality and quantity.</p><h3>An opportunity to build with Nuxt</h3><p>I love React and have written it for the past 4 years. So, unsurprisingly, I’m very used to it and comfortable with it’s inner working. But I’d always been looking for an opportunity to write something different. I tried up Angular, but somehow, it felt like an overkill for my website or a side project. Vue was my next consideration but I didn’t like it at first compared to the way I instantly connected to React back in 2021. So, early this year, I had to learn Vue in preparation for a new company I was going to join. My FE lead is a bit anti-react, so there was no escaping learning and mastering Vue. A few months down the line after joining the company and writing Vue a lot, I realized it wasn’t such a bad idea.</p><p>So long story short, here we are ;‑).</p><p>This website was completely developed with Vue’s official framework, Nuxtjs.</p><h3>I’m full stack now ^_^</h3><p>Being an engineer that works across the stack doesn’t actually excuse you from having an interesting and visually appealing site. I believe that full stack engineers are tilted more to one side, either frontend or backend. For me, I’ve had to learn Golang, and write it in production level code at work over the past 6 months. Consequently, I find myself researching and learning more about backend stuff that frontend. This exactly has influenced how I thought when I was planning this website.</p><p>My previous site obviously showcased my frontend side, I had a sleek carousel, dark/light modes etc. I had a lot of fun building the UI, experimenting with animations, and trying to make every little interaction feel interesting. This time, I wanted to build something that reflects where my interests are currently taking me.</p><p>I still enjoy building sleek interfaces, and I still get excited about a well-designed component. But I’m currently and increasingly fascinated by the world behind the interface, and a bit bored of adjusting button positions and colors. Just kidding, frontend engineering is wayyyy more than that. :-}</p><h3>So what’s next?</h3><p>Honestly? More writing!</p><p>Off the top of my head, I don’t have a grand content plan or a list of fifty topics I’m going to write about. I just want to document what I’m learning (majorly backend related), the problems I’m solving, the things I’m getting wrong, and the things that eventually make sense.</p><p>There might probably be some frontend stuff in here too. I can’t completely escape React just yet ^_^.</p><p>I also expect some of these posts to be rough around the edges. Some ideas will change as I learn more. Some things I write today might make me cringe a few years from now. But I think I’d rather have a compilation of how my thinking evolves than wait until I have everything perfectly figured out before I write anything.</p><p>So, welcome (again) to my new <a href="https://www.babafemikuku.com/">site</a>.</p><p><em>Originally published at </em><a href="https://www.babafemikuku.com/posts/hello-world"><em>https://www.babafemikuku.com</em></a><em> on August 1, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4fc8b1341307" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>