One of the classic "code smells" is called Primitive Overuse.
It's deceptively simple.
Note: This is an excerpt from my book Refactoring TypeS...
For further actions, you may consider blocking this person and/or reporting abuse
There are a couple of good examples here! One thing that I donβt like about the enum is that it mixes two concerns:
I would probably use a type like a tuple that returns something like
{Success, [FirstTime]}
{Failure, [LockedOut]}
Just a quick scratch, but you might the idea.
The canonical term you'll find in other documents including research papers is Primitive Obsession.
Smells usually don't tell us that something is wrong, but only indicate their might be something stinky. Overuse sounds very emotive to me.
Great article idea
Yes, I wanted the book to be a bit more approachable and less academic-like, so I took some liberties with the official terms for most code smells.
Thanks!
Ah. That makes sense to me!
I'm personally not a fan of this specific term (whereas I like the other conventions you've forgone π₯π) because the term is judgy and opinionated.
Keep writing π»
Any reason we wouldn't use switch/case with the strategy pattern?
You can. If there many different cases then I just find this technique cleaner.
Great post
Thanks Ben.
Hm... cool patterns! And thanks for sharing parts of your book for free. Definitely buying it π
Awesome!
As a student this is helpful because we donβt practice enough hands-on to develop smarter codings. Thanks for sharing!
hehe, I am a swift/iOS developer by preference, (web) fullstack developer by trade. Iβve spent a long time wishing j/typescript had a pretty way of doing guard statements, and widely adopted.