It’s honestly quite easy. Basically, anything can tick off a developer. The more “religious” views the developer holds, the easier it is. In my opinion, there’s no culture more toxic than that of developers, programmers, and engineers.
Yeah, there’s even much discussion on when you’re a measly developer — aka code monkey — an esteemed programmer, or a sanctimonious engineer. Some engineers are furiously agitated when called “developer.”
I’m just going to enumerate a bunch of stuff that really hits home with developers, in no particular order. …
There comes a point when unit tests and mocking just won’t cut it.
Writing unit tests with a mocked database may be great when you want to verify that a piece of code runs correctly, given some expected input.
Using an in-memory provider is the natural next step. But while an in-memory provider is useful, it’s only a hollow shell compared to the real thing. For example, queries that succeed when testing with an in-memory database may fail hard when executed on the real database.
In-memory databases provide you with a false sense of confidence.
You’ll eventually need to be…
I often take jabs at curly braces app coders with no appreciation for reducing complexity, thinking any problem — without side-effects — is solved by piling onto already incomprehensible
But, I never really got around to explaining my underlying reasoning and guiding principles — besides that, traditional branching is equivalent to hardcoding and looks nasty.
Sidebar: I want to keep this practical. I won’t go all academic on you. I’ve provided links at the end if you’re more interested.
If easily comprehensible, extensible, maintainable, and working code is the pinnacle of software development, then why do…
Code often gives rise to “WTF”-moments whenever the reader doesn’t understand a piece of code’s purpose, goal, or the code is overly verbose.
I think you know exactly what I’m talking about.
Reading code, understanding the syntax, patterns applied, etc., is no issue. But, you still wonder, “wtf” is going on here? Why did he write it that way? What’s that conditional checking, and why? The list of questions goes on.
Clean code is all about communicating your intent as clearly as possible.
Sometimes that means writing more code and other times less code. But, most importantly, your code should…
I know what you’re thinking “double the amount of code?! Who is this nutjob.” And “you’re the reason a clock app takes 20MB.”
But, let's get one thing straight.
Lines of code have never been a good metric for code quality. Ever.
Lots of developers want to skill up and abandon their old ways. Expanding your repertoire of approaches and techniques to eliminate branching is one quick way to do so. Often, your code also becomes cleaner in the process.
Crazy code like the above example needs to go. It’s not readable. It’s not maintainable or flexible. It’s just terrible…
One question lots of beginner developers often ask is “is unit testing worth it?”, “Why should I unit test”, or see them make claims like “testing is a waste of time”.
Guess what the very first thing any beginner developer does whenever they’ve completed a feature, say, created a repository class and used it in a web controller action.
You guessed it: they make a request to the endpoint using postman or thru the browser. They’re testing to see if the repository is actually returning what they’re expecting.
Primitive types don’t convey any meaningful domain knowledge — so don't build your domain classes solely with these types.
Obviously, you can’t avoid strings (though, technically not a primitive type), ints, doubles, and other primitive types entirely. They’re the fundamental building blocks for any piece of code and application. But, you can make an effort where it matters.
Neglecting to write proper domain classes and value objects is a recurring theme of many codebases.
Let’s take a look at how you can write better classes that properly capture domain-specific knowledge and business rules, resulting in safer, more flexible code.
You’ve noticed structuring code isn’t that easy. Starting from scratch often begs the question “where should this class go?”. Even the simple act of naming a solution, module, project, or what have you, can be mindboggling difficult.
It’s very likely you’ve already read tons of articles on this matter. You get different answers every time. This is great, as it broadens your repertoire of possible approaches, but, at the same time, it poses new questions. Also, having lots of options may even hinder your decisiveness.
Great, you’re in a hurry, I get it. Here’s how I typically structure my code…
Attending meeting-filled days wearing blue-light glasses, with a pizza slice in one hand and a dumbbell in the other, striking a perfect balance of endorphins and staying healthy, you wonder how the best developer ever gets any work done.
The secret is, he knows coding is only the last-mile to any solution.
We all know one engineer who seems to have the answers to all and everyone’s questions — or, more importantly, knows how to dig out answers.
The one who knows exactly how to deal with that difficult issue you’re facing, or, can elegantly model a complex domain and…
I’ll just cut right to the chase. No introduction needed.
Look at this method
WithdrawMoney(string accountIban, decimal amount). In a (European) financial system, you’re dealing with IBANs, which is a plain text string looking something like this
Despite being purely text, some stringent rules govern how IBANs are constructed and validated.
Simply using a
string type is communicating to the world — anyone using your code — that any text whatsoever is completely OK to pass in.
This is obviously wrong.
A much better approach is to capture the domain knowledge in a special class and verify that it’s…