Keeping your classes immutable and stateless makes your code way less prone to bugs. Yet somehow this clean code rule isn’t as popular and as often invoked as SRP, YAGNI, DRY, KISS and others... Maybe it’s because of the lack of a catchy acronym?
Anyways, I’d like to take a look at two examples of when sticking to this rule could save your ass (or at least save you some time debugging).
Having 100% of LOC covered by unit tests certainly feels like a great achievement. But beware – that doesn’t necessarily mean your code is perfectly covered. Lines of code coverage is a really nice indicator of your app’s stability, but is can also hide some risks.
Programming isn’t that hard. Really. With enough time and determination, almost everybody could write some useful code. The Internet is full of tutorials that teach you programming from scratch, full of people who faced the same problems you do, full of people who solved those problems and shared their solutions for you to use, and finally full of free libraries that you can just use. All you need to do is learn some tools, google your problems and put together pieces of code that you find.
But if it’s not a black magic, not a secret knowledge, then why are software developers so well paid?
Putting emojis in your database should be a piece of cake, right? You’ve had enough trouble with encodings in your lifetime, and now that we have the blessing of UTF-8, you’re always so careful to use it everywhere, so you’d expect all the characters to just finally work out of the box, right?
Well, I did expect that. But I’ve recently realised I can only put some emojis (like “❤️”) in by blog posts. Most of them were just lost or replaced with “?” by MySQL... Oh, those damn encodings again!
But fortunately the solution is quite simple.
Code golf is a type of recreational computer programming competition in which participants strive to achieve the shortest possible source code that implements a certain algorithm. [source]
Picco is a tiny PHP web framework that only takes ~2,5 kB of space and has no dependencies on other libraries, while still providing quite a lot of features, being extensible and reasonably easy to use.