In the picture above, what would you rather own, the Swiss army knife or all the tools on the right? When traveling, portability is the most important thing. The Swiss army knife is the appropriate tool.
But for day-to-day life — would you cut bread, mend the car, or open cans with a Swiss army knife? Probably not. You can do it, but it’s much easier to use a bread knife, a set of screwdrivers, or a can-opener.
Real-life code should be treated the same. A do-it-all class (god object) it’s ok, it will get the job done when you…
Both images above are formed from the same number of pixels, but while one looks like a bear, the other one looks more like a shocked square. It is not a difference of quantity, but one of granularity. It is easier to compose something with smaller pieces.
The same logic can be applied to writing good, resilient code. Client code shouldn’t be forced to implement methods that it doesn’t use. This is the Interface Segregation Principle as defined by Robert C. Martin.
Code should be flexible enough to allow client code to use only the needed abstractions. …
And the number one spot for the most overlooked SOLID principle goes to… Liskov substitution. No surprises here.
I’m not going to bore you with the scientific definition. In short, the principle states that all object types should be substitutable for their subtypes without changing the correct behavior.
The key to understanding the principle stays in “correct behavior”. Let’s look at the principle with an example.
As part of the software engineering team at AutoPilotCars AI startup, we have to come up with a solution to control normal cars (like a Toyota Camry).
After much thought, the team has decided…
In 1955 Raymond Kroc, a mixer salesman, opened his first franchised McDonald restaurant. He was 53 years old. At an age when most think about retirement, he was searching for new enterprises. Were he to focus on his niche, he would have never built the World’s largest restaurant chain.
Our writing can benefit immensely from the same type of courage. Online writing, for example, used to be reserved for high school teenagers and computer geeks. Now there is a blog for everything, like fashion, finance, gaming, sex, physics. More and more writers are moving away from traditional media to online.
Trucks are one versatile piece of equipment. They can do different tasks based on the type of trailer attached to them. We can even chain trailers (if the load-weight allows it).
In short, trucks are open for extension with different trailers but closed to modifications (like engine or cabin). Writing extensible code should be just as easy as swapping trailers on a truck.
Let’s imagine we have to write a program that makes cacao ice cream for Ted&Kelly Ice-Cream Corp.
The code, although basic, looks ok. No principle seems to be broken. …
Imagine every time you listen to “Single Ladies” the song would change.
1st time: “All the single ladies...”
2nd time: “Every single lady…”
3rd time: “All sole ladies…”
If that were the case, no-one would have shared the song, it wouldn’t have become a hit and we wouldn’t have laughed at the “Single Ladies” baby dance. Humans expect things to remain the same when all they do is observe. “Friends” must remain the same every time we rewatch it.
Code makes sense when it is a natural extension of familiar things. …
The hydrogen propulsion dream has been around for quite some time. Harnessing the most common gas in the universe with water as the only byproduct was seen for a long time as something belonging to Jules Verne’s novels.
The thing with SciFi novels is that you never know when it will become reality. 100 years after the launch of “The Mysterious Island”, the world was introduced with the first working prototype, the Chevrolet Electrovan. But there is a long way from prototype to mass-adoption.
“mind-bogglingly stupid”, Elon Musk
A key player in the electrification of our cars, Elon Musk has…
Tell me if this sounds familiar to you: you just started to watch a tutorial/read an article. You find the concepts interesting so you promise yourself you’ll pay attention. But then, disaster. Your attention gets stolen. How did they manage to squeeze a DSLR quality camera in such a small phone? Why did my friend buy that stupidly expensive jacket, it’s not worth the money. Have they truly put a man on the moon?
5 seconds. That’s how long your mind wandered. Now nothing makes sense. So, scroll back and rewatch it. Or re-read the last paragraph. …
Boxing and Unboxing stay at the base of C# programming. You bump into them when calling functions, creating objects, at interviews, and so on. They are ubiquitous in the .NET space, so a solid understanding will improve your skills. Let’s explore these concepts and how they are related to stack and heap memory.
First, this is the technical explanation, straight from Microsoft:
“Boxing is the process of converting a value type to the type object or to any interface type implemented by this value type […] Unboxing extracts the value type from the object. Boxing is implicit; unboxing is explicit…
Bitcoin has come a long way since it was launched in 2007. It evolved from a geek instrument to a market value of 850B $ (as of 13 Feb. 2020 ). In 13 years the coin reached a valuation 10 times smaller than the gold market cap. Simply amazing.
But all existing cryptocurrencies have failed to deliver on the biggest promise, to provide a valuable alternative to fiat money. For example, Bitcoin hit 2 roadblocks that stop it from becoming a true currency:
A software developer interested in writing about programming, technology, environment, and self-development. Twitter @mihais77