The story starts few weeks ago when on codereview my colleague asked me to inline class if possible. I, being a SOLID dev, was shocked: why would I increase coupling, break SRP, and thoughts like this.
So far I can be sure that the only type of comments in code is legal, needed…
Here’s a quote from Linus Torvalds in 2006:
I’m a huge proponent of designing your code around the data, rather than the other way around, and I think it’s one of the reasons git has been fairly successful… I will, in fact, claim that the difference between a bad programmer…
I’ve got an abstract class, with a needed method, which I want to reuse
Reuse the method in the rest of the system in most appropriate way
Sometimes we have to deal with properties, which can be null
null
/** * @var string|null */private $description;
It’s fine, IDE will generate a getter for us
public function…
There is a common opinion that OOP patterns reduce complexity of code and project in general.
To me it was sort of obvious, before I spoke to a frontend guy, who hates OOP and does some functional programming. He said that he hates all…
I like to use constant literals in tests instead of constants itself.
Encapsulation picks up where abstraction leaves off. Abstraction says, “You’re allowed to look at an object at a high level of detail.” Encapsulation says, “Furthermore, you aren’t allowed to look at an object at any other level of detail.” — Code Complete
When we’re looking at code — we can see how it works, we can see that data comes inside, how is it being processed and how returned.
But often nobody can say why someone wrote this code.
A lot of books/articles say about taking ownership.
The boy-scout rule says about leaving the place cleaner than it used to be.
But what is the scope of ownership? If I am changing a method in a class, am I responsible for all the class? How cam…