How Martial Arts Helped My Programming

Need a new hobby? Like programming? Great! You should learn a martial art. Any martial art. It really doesn’t matter what it is. I personally like boxing, BJJ, and fencing but as long as you’re learning a system, and exercising that system with someone else, this article will give you some insight into how learning martial arts helped me and may help you as a developer.

A New Way to Think About Systems

If you’re developing software, you’re probably a bright baby. Good on you! You can construct the universe in your brain using binary lambda calculus. To me though, that’s just the start. You should start challenging that meat car you drive around to learn in a brand new difficult way, and understand how things fit together in a whole new light.

Learning martial arts is surprisingly like dancing, and not that stuff you do at the club where you awkwardly shuffle , it’s more like swing dance or ball room and there’s a flow to it; A rhyme and reason to each movement. . When you pick up on that flow and rhythm you’ll chain together all of those techniques fluidly and flawlessly. This is what people call a “flow state”.

You’ve probably been there when you’re programming. Just banging out solid line after solid line of code, and getting that five hour commit done in one hour. That’s a hell of a feeling. Challenging yourself to learn a physical system of movement really gets your body in tune with itself and makes finding that rhythm so much easier.

Martial arts are all in the moment. If you don’t slip a punch, you’re going to get your vibe checked. You don’t want to get your vibe checked fam. That spontaneity moves your head away from the flow charts, and into the flow. By finding yourself getting into the moment, you open yourself to flow states more easily, not only in your martial arts, but in your conversations, and yes, your programming.

Determination To Be Better

When you start out in any martial art, you will probably suck. The same is true of programming. That breaking in period is where you learn how to be humble and how to accept help from others. If you’re new to programming/development, that mindset of accepting help from more experienced members in the development process is crucial. You need to be constantly looking for ways to improve your craft; how to slip a punch a bit closer, or how to parry an attack as late as possible.

If you’re in the right head space as a martial artist, you’re constantly looking to find someone who can kick your butt 6 ways to Sunday, because those matches are where you can learn the most. The same is true for a developer. You need to be ready to talk to a senior and accept that he will say your code has some really bad smells in there.

When you hear that, your first thought cannot be “Well up yours chump, my old job thought my code was great.” If the master says your Kung-fu is no good, he’s probably right. Learning to take criticism as an opportunity to learn will help improve your code far more than resisting it and allowing pride to hinder you.

The same can be said in the other direction. If you’ve risen to a senior position in a school, you are taught that your mindset isn’t to destroy newbies that walk through the door. That is how you scare people away from ever wanting to do that task again. Your job is to point out their mistakes and help them learn. That may be in the form of pointing out those mistakes by punishing them in practice, but you will learn the difference between teaching through example and flexing your knowledge like a jackass.

Dealing With Confrontation

If you shrink and buckle in confrontation, or can’t control your temper, see a therapist. After that, go pick up a martial art.

Often times in the office we find that project managers give us unrealistic requirements, our coworkers upset us or any myriad number of things. If you let these things get to you, your work will suck. Both in quality and in experience.

You can’t be a prick, and you also can’t give in to every demand. Neither of those things will help you in the long run. To find that balance, I strongly suggest learning a martial art.

Fighting is scary. Especially if you’re like me, and you don’t like hurting people. That fright is what cultivates the mutual respect that martial artists have for one another. When you go to train with somebody, you’re effectively asking them if you can use their body as a training dummy. In my eyes, that’s straight validation and that kind of positive reinforcement from another person.


With that being said, I hope this article has encouraged you at least give martial arts a try, and good luck on your programming journey.

Organizing your next NodeJS+MongoDB App – Part 1

When dealing with a project of any real substance, one needs to plan (what a thought!). Often this takes place at the diagram level and perhaps even at a technology selection level. In this multi-part post, I wanted to share my method of organizing my app’s backend. In this portion, I’ll be discussing the general layout of our app and explain what each subfolder will hold. Once we’ve established that, in the next post I’ll be going into the nitty-gritty of how some of these bits fit together

Why Read This Post?

You Want Easier To Maintain Files

You don’t want your projects to become 2,000 line monster files. A good developer doesn’t just sit down and start 💩ing out code. Organizing your work into multiple, easier to understand files will slow you down in the short run, but over the life of a 3-6 month project it will pay off in spades.

Your Code Needs To Be Maintained By Someone Other Than You

It’s not just a possibility; it’s an inevitability. Having your project organized into a small set of recognizable folders/files makes wrapping someone’s head around a project much easier than having them read several unrelated files and hoping they fit them together or worse, traversing a disorganized mess of files/folders.

What You Need To Know

Actually not much for this portion! A lot of what you pick up from this post applies to programming in general.

The General Layout

Most of my mongodb+express projects involve the following files/folders

  • Server Folder
    • Schemas
      • SomeSchema.js
      • AnotherSchema.js
      • Schemas.js
    • Routes
      • SomeSchemaRoutes.js
      • AnotherSchemaRoutes.js
      • Routes.js
    • Helpers
      • WhateverYouNeed.js
      • othergoodies.js
  • Files
    • server.js
    • cluster.js

Schemas

The Schema’s folder will hold all of our MongoDB schemas. Each file in this folder will describe a different schema in our database. In most cases, this suffices however in some situations where an object has many methods, I may even have a “SomeSchema” folder with a separate “SomeSchema.js” and a “SomeSchemaMethods.js” file, but more on that in the second post.

This allows us to have all of our schemas in one nice place. To tie them all together we will import each and every one of them into the “Schemas.js” file. This acts as our single access point for our schemas for the rest of our app. Ideally, this will only Routes.js, but in some rare cases, we may need to import a schema else where.

Routes

Routes will handle all of the routes of our app(big surprise huh?) So if we want to create, read, update or delete something, we do it here. Some nice benefits of this are that we can separate database logic and app logic. So if we wanted to implement an extra method from the server that doesn’t interact with the database, we can do it in a single location that is separated from the database logic. For instance, if you had a courtesy route from the app to check if a login token is still valid, you could implement that here.

Helpers

This is our “doesn’t fit neatly into either category” where I usually store my JWT encrypter/validator, validator functions and the like. This is also a good place to store our various middlewares. The important part is that we put all of these miscellaneous functions in one neat area instead of rewriting them all over the place.

Server.js/Cluster.js

This is where we tie it all together. In this set of files, we import all of our routes and various middlewares. After structuring everything in the way we did we can describe our server in one neat, clean line of code. This means the next guy who comes around will understand exactly what is going on as soon as they see it. There should be no need for them to look into any of the aforementioned folders unless they wanted to understand the specific implementation of the methods.

In the next post, I’ll be going into detail in how all of these ideas fit together in the code and what I’ve described looks like.