loading...
Cover image for Top 5 DEV Comments from the Past Week
The DEV Team

Top 5 DEV Comments from the Past Week

peter profile image Peter Kim Frank ・1 min read

This is a weekly roundup of awesome DEV comments that you may have missed. You are welcome and encouraged to boost posts and comments yourself using the #bestofdev tag.

Let's kick things off with a great reply to Convince me that types are awesome by @deciduously :

With types, you can make illegal states unrepresentable. Instead of storing a bunch of strings, you can store a Name and and Address, and can encode into the type system that ContactInfo must contain a phone number, an email address, or both but not nothing. By encoding that requirement into the type system, it becomes impossible to represent an incomplete record in your program. It also aids refactoring - if your business logic changes, your compiler will guide you through the refactor for ensuring your whole codebase reflects the change.

Replying to What have been the broken promises of computer technology? , @shiling talks about some of the negative trends enabled by technology:

When I was young, I was so amazed by the Web, because I love books and thought of it as one big infinite library. I thought it would help make people less ignorant and cure stupidity (hey I was a precocious 10 year old!). Oh boy, was I wrong, especially with the Advent of social media and fake news. People are just so addicted to gossipy tales instead of learning about the world.

The I've never become overly convinced that switch statements are that much cleaner than if else if else if else if else thread prompted some great discussion. @0xrumple had the top reply with this note:

That's why we never have switch in Python 😁

And, the dictionary is always a better and cleaner alternative for the ugly switch.

def my_switcher(x):
    return {
        'a': 1,
        'b': 2,
    }[x]


print(my_switcher('a'))
print(my_switcher('b'))

@unclebob chimed in to the Open/Closed principle: How do you convince other devs ? thread with a great explanation:

The Open-Closed principle says that modules should be open for extension but closed for modification. That means you should be able to extend the behavior of a module without modifying it. Or, to say this another way, you should be able to add new behaviors by adding new code, not changing old code.

When you change old code, you risk introducing bugs in existing behaviors. You also complicate the design of the old code to accommodate the new behaviors. You also must redeploy the old code ever time a new behavior is added.

When you conform to the OCP you do not risk introducing bugs into old code. You do not complicate the design of the old code. And you do not have to redeploy the old code. That old code can sit in Jar files or DLLs or Gems, or whatever module format you use, unaltered.

This facilitates a plugin structure. New features are plugins to the existing application. They can be deployed independently. They can be deployed optionally. And, best of all, they can be developed independently.

So it’s not just a matter of adding classes vs. changing a method. Rather it’s a matter of organizing the code such that behaviors are isolated, independently deployable, independently developable, and optional. Who wouldn’t want that?

Finally, adding to the discussion of Jack Of All Trades or Master of One?, @georgecoldham talks about the importance of following your passion and curiosities:

Im a firm believer in following your passion(s).

You look at everything everyone else is doing with wonder, you want to be able to do that (and that thing over there, oh and the one you saw yesterday, and that side project you looked at last week, oh and ....).

Over time you will develop a deeper knowledge of a few things you have to work on because of jobs or overwhelmingly strong interest to know about one thing etc. You will find yourself curious about more technical elements, and go deeper down the rabbit hole.

Value the ability to be able to learn quickly much higher than the ability to regurgitate technical information, Its a much more valuable skill. The ability to waffle technically will become easier the more you know about and have used.

If you have to interview, then spend a week learning the technical waffle and interview shit, then hope you really dont need it.

See you next week for more great comments ✌

Posted on Jul 2 '19 by:

peter profile

Peter Kim Frank

@peter

Doing a bit of everything at DEV.

The DEV Team

The team behind this very platform. 😄

Discussion

markdown guide
 

Congrats to @deciduously , @shiling , @0xrumple, @unclebob , and @georgecoldham for making the list this week!