Skip to main content


Showing posts from May, 2021

Simple code: Functions and methods

What makes a good function or method? I don't think it's a single thing but a combination of things where each is significant. If one the things is flawed it affects to all others and the whole function is flawed. So what are those "things"? Have a meaningful name Function should have a name that describes it's purpose or functionality. When a function has a meaningful name it's easy to read and understand what's it's purpose. Let's take a example. If function's purpose is to find a customer by it's id a good name could be findCustomerById(id: String) or it could just as well be just  findCustomer(id: String) because the function signature implies that the customer is found by it's id the word find also implies that the customer might be found or it might not be found. If the function's name would be changed to getCustomer(id: String) it's meaning changes because now it implies that there's no fallback, the customer is e

Simple code

I've been writing a series of blog posts trying to summarize what are the key incredients of good code. The working title for the series was called "my view of clean code" but clean code is already a existing term (and a book, read it if you haven't). My view is mostly same, a bit different and with a idea that these are not rules or laws but conventions, ideas and practices that can be applied in many situations but this is not a silver bullet. I'll be publishing ten posts in addition to this one on various subjects that relate to code, code bases, interactions in code or interactions between systems and how to build all this with the aspire to make everything simple so that the code is as easy to test, reason and as understandable as possible. Each post will be a short and simple description of the subject with possibly some example code. A new post will be published every other week. In the first part I'll be writing about functions and methods and that wil