52

Why every beginner front-end developer should know publish-subscribe pattern?

 5 years ago
source link: https://www.tuicool.com/articles/hit/JruYZrF
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

AKA: How to understand asynchronous JS code in a less painful way.

Let’s begin our story. It all starts, when you find yourself in one of the most exciting points of your web development journey: a moment of shifting your focus from styles, esthetics and grid systems to logic, frameworks and writing JavaScript code.

eiAVrub.png!web
It starts like this…

At this very moment you begin to see that when it comes to JS, it’s much more than few simple jQuery tricks and visual effects. You see a big picture of yourself creating web applications — not just mere webpages.

While you put more and more effort into creating JS code, you start to think about interactivity, your subsystems and logic. Things begin to work — and at last, you feel the life in your apps. A whole new, exciting world appears in front of you. And with that, a whole lot of new great problems.

BvInueQ.png!web
…and end up in this. And it’s not the end!

But you’re not discouraged — new ideas are popping out constantly, you write more and more code. Various techniques from that certain blog post are being tested, assorted approaches of solving problems are being tinkered with.

Then, you start to feel a small itch.

ZVriYbN.png!web

Your script.js file grows. An hour ago it had 200 lines of code, now it exceeds 500 lines. “Hey” — you think— “it’s not a big deal” . You’ve read about clean and maintainable code — and to achieve that, you begin separating your logic into files, blocks and components. Things start looking beautiful again. Everything is neatly catalogued like in an meticulously organized library. You feel good, because various files are named properly and placed in a certain directory . Code become modular and more maintainable.

Out of nowhere, you start feeling another itch coming — but the cause is not clear yet.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK