SOLID Go
SOLID is a famous cargo-cult that is used to poke “bad” code during code review. Jokes aside there are some solid, pun intended, ideas within SOLID. This post is yet another attempt to dismantle this set of principles and understand them better. The SOLID stands for(pasted from wiki): S ingle-responsibility principle: “There should never be more than one reason for a class to change.“In other words, every class should have only one responsibility O pen–closed principle: “Software entities … should be open for extension, but closed for modification.” L iskov substitution principle: “Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it.“See also design by contract. I nterface segregation principle: “Many client-specific interfaces are better than one general-purpose interface.” D ependency inversion principle: “Depend upon abstractions, [not] concretions.” S single responsibility Out of all these, only first one makes sense right away. If you are not a complete beginner, you won’t create a struct that does shipping calculation, checks weather condition, sends push notification and orders pizza. Don’t you? ...