Pinpoint: A virtual user conference in
Smarty

5 principles for creating stupidly brilliant JavaScript applications

Andrew Townsend
Andrew Townsend
 | 
April 11, 2022
Tags
Smarty header pin graphic

Have you ever tried to add a minor feature to your application only to discover that you’ll have to re-write large blocks of code first? Or maybe you’ve spent hours deciphering hundreds, or perhaps thousands, of lines of existing code just to find out a task only required two lines of additional code. If you’re like most developers, you’ve wasted countless, frustrating hours wading through immensely complicated code trying to force it to do things it wasn’t built for.

In his presentation, Mike Manwill, Frontend Team Lead here at Smarty, discussed 5 principles to help you create stupidly-simple applications that are maintainable, extendable, and bug-resistant. He calls it “writing stupid code”.

“If you can’t explain it simply, you don’t understand it well enough.” - Albert Einstein.

Mike explained that “smart” code is “dumb” for several reasons. It is difficult to read and understand, making it difficult to hand off to predecessors or other coders on the team. It is bug-prone, and debugging can be very very difficult. Extending it becomes time-consuming and difficult, especially if you’re not the one who authored it. Estimating work needed becomes virtually impossible if your code is too smart. And finally, it tends to have a short lifespan and needs to be overhauled frequently because it can be so frustrating to work with.

Smart code is dumb image

Aside from spotting those challenges, there are five other symptoms of “smart code”.

  1. Your functions take lots of parameters
  2. There is a lot of conditional logic
  3. You need to explain your code via commented code
  4. Brittle code (it breaks every time you change it)
  5. The code is difficult to follow

So, we’ve identified the problem. You’re tired of being frustrated with this “smart code”. How can you make it better? For the main part of his presentation Mike went over the five principles you can follow to create brilliant “dumb code” that lasts.

  1. Take time to really understand the problem
  2. Decouple different ideas
  3. Pass the thing instead of the parts to build the thing
  4. Refactor (just because it’s working doesn’t mean you’re done)
  5. TDD (Red, Green, Refactor)

You can watch the video recording of his session (super short, only 28 minutes!) and see his examples and explanations first hand by clicking the button below.

Try our stupidly brilliant address validation and address autocomplete tools. You can sign up for a free account by clicking the link below.

Subscribe to our blog!
Learn more about RSS feeds here.
rss feed icon
Subscribe Now
Read our recent posts
Around the World in 80 Days (with Smarty!)
Arrow Icon
Phony passports. Runaway trains. Rogue elephants. Hot air balloons. Phileas Fogg dodged them all in the 1956 movie adaptation of Jules Verne’s novel, Around the World in 80 Days. His race was against time. Today, your ecommerce business is running a race of its own; delivering quickly, accurately, and affordably across a world full of logistical landmines. Fortunately, you don’t need a valet named Passepartout to guide you (although wouldn’t that be fun?!) You just need Smarty. Smarty is your passport to global address data perfection, specializing in address verification, autocomplete, geocoding, and enrichment.
Address component analysis: A smarter way to validate addresses
Arrow Icon
Most address validation tools give you a simple thumbs up or down on an address because it either matches or it doesn’t, right? But what if you need more than just “valid” or “invalid” as a response? What if you could know exactly what part of the address is off, like a misspelled street name or an unconfirmed vanity city (like Hollywood), and why it isn’t considered valid?What if part of an address needed to change in order to make it a mailable, valid address? We think you’d want to know that, too.
BREAKING: Rooftop geocodes walk off the job—chaos mounting by the hour
Arrow Icon
Dateline: Tuesday, 8:04 a. m. In what experts are calling “the biggest location intelligence crisis since the discovery of space,” rooftop-accurate geocodes have officially gone on strike. The high-precision coordinates—normally pinpointing locations down to the exact rooftop for deliveries, telecom installs, insurance claims, and analytics—appeared on Smarty TV and issued a short but cutting statement this morning:“We’re tired of being taken for granted. We’re tired of being treated like just another number.

Ready to get started?