An empty room, 200 unpopulated chairs and a few dozen black shirts piled up in a mess in the corner. An hour earlier, the room was full in the favor of a meetup with many of my colleagues, speaking and hearing great wisdom all around Front End Development. It’s true that the reason for anyone to come to such a meetup is to hear and be heard, to connect and get to know better the field and your colleagues in that field, but it’s also true, apparently, that when a speaker says to his listeners that he’s giving away black shirts free, he gets their attention for the rest of his words.
When that speaker finished his talk, some of the participants walked up to him for follow-up questions, while most of the others wanted to get their free black shirt he promised. When mentioning bringing shirts for everybody, he also mentioned a few important details: a) there are way enough shirts for everyone that came. b) there is a full range of different sizes that would fit anybody in that room. c) there is men’s model and a women’s model.
Treating those details genuinely draws an image of a bunch of people approaching calmly the shirt stand, getting their right fit and walking away smiling. Those details were, in fact, correct, but one important factor left unreferenced: the shirts were all stacked together; small sizes, with medium sizes, men’s model with women’s model. Some shirts were on the stand itself, some more shirts were packed inside a bag beside the stand.
A hundred calm people got to the stand, wanting to fulfill that ideal situation where they just take the correct item and walk away, but instead tackled by a few different configurations without constancy. Just like traffic jams right at the neck of a crossroads bottle, the first guy searches for his fit, while the guy behind him wait as well as the other 98 guys behind them. It takes a short time until the second guy reaches out to start searching for himself also, even that the first guy didn’t find his yet. Then the third guy and the fourth and everyone all together. The shirts that were folded nicely are now instead messed nicely and the lack of order earlier now becomes a giant pile of people on top of a giant pile of shirts. Looking at this, I couldn’t stop thinking of how different it would be if the shirts were preordered by sizes and models, accompanied with clear signs pointing to the right stack for each configuration.
Your code, my shirt
Think of your code as the shirt stand, think of your objects in your code as the shirts. You have different kinds of objects, but they all can be categorized, making your code object-oriented. Even if not implementing OO principles, still an ordered file structure is required. A good sense behind the decisions you make for where to put each object or function, makes getting to those functions later a lot easier as you’ll instantly, intuitively, know where to look for them.
Medium sized shirts go under the “Medium” sign just like utility functions you create should come right under a “Utilities” object. Women’s shirts sit on the “Women” signed stand just like your template views should sit in a “Views” folder inside your app. Even if you create a library or an API and it’s the most amazing and profound directory, if you won’t categorize it correctly (or also at all for that matter), any one that would come up to your library would find himself looking and searching for where might something be placed. Pull requests or forks of your code would float up breaking your concept of the library as the contributors trying to tweak it, struggling to find their correct hooks in your code.
It’s already a cliché that in life we must have order to get along good. I’m sure that guy bringing all those shirts was fully confident he did all he could to make everybody happy. He almost really did! But planing sizes, models and amounts was just the first phase just like writing an innovative library is. Documenting the code and its ways, categorizing conceptual parts into objects and structuring a strong and unambiguous folder structure are the second and super important phase every one of you should take in consideration when offering anyone anything, for free or not for free. Make order in your code, make sense to everyone else that tries to find a place in it.