DEV Community


Posted on


sometimes you have to build the product the client needs, not the one you want...

So we had a client with a unique situation. They had a website but their advertising people, who somehow own rights to the website and all that Jazz, basically gave them an ultimatum. Pay us for our services, or else we shut you off at the end of the month.

Seems pretty straight-forward, but the catch was that the advertising firm did fulfill their end of the contract. Long story short, they needed a website.

We mock something up, based on a template we found, gave it to design to make it unique. We were using this as a way to get other clients the same way. Build a couple templates that we can churn and burn relatively quickly, and then each time we do it it will get easier and easier.

I loved this idea! I wanted to go full hog, I wanted to give them every option they could ever imagine. You want a hero element? What size? What color? What header? What content? I gave them everything. Flash forward two weeks, deadline is in two days, it’s time to put in content. I’m fixing up a few things here or there, and I haven’t made the website client ready yet (modx has template variables, which you need to order properly for the front end of the McD to be more legible), but content was getting put in. Oh, and also sometimes the browser just wouldn’t connect to the server.

So this is borderline catastrophe, we check the logs and it’s a couple megabytes, so I’m given the task of parsing that and figuring out what the issue is.

Now I’m not a PHP developer, I would never claim to be. I love JavaScript, I love being able to do synchronous code and a sync code all together. It’s very fun and interesting. Turns out, synchronous code has some weird quirks.

They way our cms parsed the templates, it would render the chunks and snippets first, then the template fields, then logic.

Now I had just built an entire website made of really complex components that worked really well, and they relied on...a lot of logic. Basically, MODx had already built both the snippets and the chunks and now the template field was asking the cms to go back and delete one of those based on the logic.

This caused a bunch of errors, which sadly are not all figured out, and I had to spend all of yesterday and today parsing back through my own code (you best believe I’m gonna be documenting before I start coding on the next template we build) and extracting my beautiful components into less logic based components that MODx could parse in a reasonable fashion.

Did the website go up in time? Well, as of writing this (8:55pm), and considering they’re on west coast time, we’ve still got a couple of hours.

What kills me is that if I had just built the website the clients needed, I would’ve been done weeks ago. Instead I tried to be smart and out think the clients. Check this field, if empty check this field, if that’s empty check this field, so on and so forth. KISS really goes a long way.

Well my dog is whining at me to pay attention to her, but hopefully I learned my lesson.

Top comments (0)

An Animated Guide to Node.js Event Loop

Node.js doesn’t stop from running other operations because of Libuv, a C++ library responsible for the event loop and asynchronously handling tasks such as network requests, DNS resolution, file system operations, data encryption, etc.

What happens under the hood when Node.js works on tasks such as database queries? We will explore it by following this piece of code step by step.