Lurker News
I am currently working for a startup and am one of 3 developers. Most of my work revolves around building the API in Node + Express as well as some small projects with MongoDB. The other developers don't really assist me since they have their own projects to work on, and, honestly, they have less experience and knowledge than I do.

So my question is: What is the best way for me to go about learning best practices in API development, or using MongoDB, or even just being a better software developer in general?

Comments (197) 98 threads

WestCoastJustin4 replies#
Conference Youtube videos. They are a goldmine of useful tips and tricks. Go look for videos from the Node [1] and MongoDB [2] conferences and you will find tons of war stories and what is actually working for people. Using this option arguably connects you directly with some of the best people in the world who are actually using this stuff.

ps. using the youtube 2x playback speed option can really help digest lots of video content quickly [3]. I use this almost exclusively on youtube now.
[1] NodeConfEU 2018 - https://www.youtube.com/watch?v=UMgMSb7d-Os&list=PL0CdgOSSGl...
[2] MongoDB - https://www.youtube.com/user/MongoDB/videos
[3] https://sysadmincasts.com/episodes/52-video-playback-speed

LandR5 replies#
I would say do not look to conference videos for how to write production quality code... Most talks at conferences are shallow and at worst just the blind leading the blind.

Be very careful, I've even seen people from places like Microsoft showing code at conferences that would fail even a decent code review process.
I think for this reason conferences are a complete waste of time. Talks are too short to go into anything approaching useful detail, and s spend an hour talking about pointless demo quality code.. Or the talkers arent experts in what they are talking about. Waste of time.
I would say the same for the majority of blogs. Most are garbage and it can be difficult to tell the code is garbage if you're a beginner. I dont know a single development blog worth reading...

dustindiamond#
What was the last conference you attended and when?
behringer#
It's true. The best way to learn is to do. Second best, look at production quality source code. Third best, buy a book written by an actual authority on the topic.
askmike#
The blind leading the blind? Most conferences have lineups of well respected people involved in an ecosystem. From language authors to open source maintainers and such.

It seems you don't seem to understand the purpose of conferences and blogs. These talks are not to showcase the best quality production code that can pass any review process. They are to showcase new developments and new approaches to do things in a specific field. It's meant for people already in the field (or starting to get into it) trying to learn more.
If such talks have high quality production code in slides the message would get easily buried under stuff that isn't important for conveying the message they are trying to say.

wizardofmysore#
It depends on which conference you are looking at, if Brian Goetz had a talk on concurrency best practices then it would definitely be something to think about.
muzani#
This often happens when conferences and blogs are used as a marketing outlet. There is still plenty of gold, but you have to sift through all the garbage of people using it as a way to make themselves more visible.
thoman231 reply#
I'm glad to hear I'm not the only one who watches YouTube presentations on 1.5-2x speed. I mentioned that at work once and people looked at me like I was crazy.
shemtovo2 replies#
Not crazy at all. Problem is YouTube only goes to 2x
mpkc#
You can use console in browser to control playback rate: 1. select video element with: $('video') 2. than set playbackRate property on it

example write in console: $('video').playbackRate = 3; (and playback rate would be 3x) Works with rates between 0.0625 - 16.0(tested in Chrome and FF).

unknownbreaker#
Yes! Videos are the best.

Two things:
1) Sometimes it can be hard to find good YT vids, especially a series of vids that will deep dive into the topic you care about. Maybe sign up for an online course where there videos of the instructor coding in real-time and address things in detail.
That will definitely give you a place to start with someone who has actually professionally done things you’re doing according to some best practice.
2) After you’ve got an idea of what you think is best practice, even if you have lots of questions remaining, just keep moving ahead with your project with a focus on making sure your API successfully does what you plan for it to do.
it’s not possible for you to know all the best practices, especially in isolation, and still be productive. you have to get your work done, and some of it is just going to be terrible. It’s possible that you may end up with a lot of tech debt that requires time to go back over it to refactor, but what does your boss expect if you’re alone and making the whole thing by yourself?
Unfortunately, you have to meet your timelines, so compromises must inevitably be made. More could be said about this, but i’ll leave it there.
Also, overtime, you will start to see what the better way to implement things are, as you continue building out features and run into use-cases you might not have thought of previously. The videos and documentation you read later on will make more sense since you have a framework in your mind of how the patterns get used or implemented in code.

sumanthn#
Yep, seconding this.

https://www.infoq.com/ is my favorite because they get talks from some of the most experienced software dev folks, and they cover almost every topic of software engineering

iheartpotatoes1 reply#
"Best practices" is a bit of a red herring. Every company differs considerably, and online blogospher experts throw the term around as sort of a gatekeep-y way to keep the order ("What do you mean you don't know (arbitrary) best practices??!?!") The only way to learn best practices is to work at multiple companies / projects.

For example, I worked at Intel, Lucent, Apple and DEC. Each one had significantly different "best practices". When I look at how we did code there vs something like, oh, the GNU project, they were WORLDS apart. So even if you made the claim, you'd still fall short from the new environment.
If you're lucky, eventually YOU'LL be the one defining best practices.

Gibbon12 replies#
I'll second that a lot of 'best practices' is cargo cult like gate keeping.

Just learn how to write idiomatic code in whatever language / framework you are using. At least the approaches are good enough. And other OCD/Autistic programmers won't lose their shit when they see it.
Do try to write code in an active AKA explicit way. Whne you read the code it should be obvious what it's trying to do. Code where the right thing 'just happens' is never clever it's just bad.
Do remember the process you use for a tiny team is different than google or facebook or a web dev sweatshop.

seniorsassycat2 replies#
'idiomatic' vs 'best practices'?
Gibbon14 replies#
My inner Northcote Parkinson sort of triggers on 'best practices'. Best tends to imply that all the other ways to skin the cat are 'bad.' Which is likely objectively untrue.

Idiomatic is more neutral and means basically just do it the way everyone else tends to. The real advantage to that is you generally avoid pitfalls and annoying other coders.

Continue this thread — 4 replies

mikekchar#
Thanks for that! "Idiomatic" is such a better word for describing what you actually want. "Best practices" implies that we know for sure that the practice will result in a better outcome. This is almost never true because programming is a very situational activity requiring a lot of judgement calls. If you turn off your brain and apply "best practices", the result is almost always horrific.

However, "idomatic" means writing in a way that other people are likely to be able to understand. That's a great goal! Often it's worth it to write code that isn't quite as good for the situation if it is more idiomatic. It's a judgement call still, but it's still important to know what is and isn't idiomatic so that you can make that judgement call.

danite1 reply#
Please don't use autistic or OCD as slurs.
throwawaythekey#
Is it being used a slur? It's a fundamental characteristic of those types of people.
opportune2 replies#
I did a quick control-f "read" and almost everyone is telling you to read books or articles about best practices. That might be useful once as a highlevel overview when getting started on a topic, but my personal advice is to only do that briefly. You'll get the most bang for your buck READING CODE. There is no better way to improve as a developer than reading good code.

Reading articles and books will teach you things that sound good but may not hold up in real life. Code is battle tested and real. To learn about art, you can read volumes about form, shape, color, composition etc. but you really need to look at great art. Same with code.
Of course, you may wonder "how do I find good code?" I would just try to find high-profile OSS that deals with whatever kind of tech you are interested in. It may not all be good, but if you diversify the code bases you read, you will notice the differences and learn for yourself why some might be better than others.

lallysingh#
Yes, this. Read lots of code. Ask why they choose that implementation. Read their bug reports.

It'll soon become obvious which ones are good codebases and which ones aren't.

afarrell5 replies#
How do you learn to read code without guidance and without getting lost? How do you keep your thoughts organized? At each step, how do you confidently decide where to go next?

———
I’d like you to take as given that I’m reasonably intelligent — I graduated from MIT and have been working as a software engineer for 6 years. Yet when I sit down to read https://github.com/cypress-io/cypress or https://github.com/webpack/webpack, I don’t know where to start or how to incrementally build up an understanding.
How can I learn how to read a project’s worth of code?

e_carra#
I have the same problem. Every now and then I find some interesting OSS project I want to contribute or understand at a deeper level, but it's really hard to start doing something on it if there isn't an updated guide for contributors.
sidcool#
Great question. This question itself is worth a separate thread.
olikas2 replies#
I've spend my career reading code. I find it particularly difficult without guidance. I would recommend using some old school technology (pen/pencil and blank paper) and draw diagrams, write down every question and observation, notes. Others may recommend using some digital tool, but be mindful how much energy you spend organising your thoughts, drawing with a digital tool. If your goal is to understand a software, then don't waste time creating beautiful documentation first.

It is also important to have a clear goal. Let's say you want to understand how webpack starts up, or how it does a specific feature. Make this question your main concern and don't wander around. Don't try to understand everything at once. Divide and conquer.
It is also useful if you can ask questions, but please spend some time coming up with a theory first why things are the way they are. Formulate a hypothesis (e.g. "this piece is necessary because it handles an edge case", or "this piece of code looks uglier than the rest, is there a reason?") and try to prove it. If you can engage with the community, the better, but please don't outsource your "thinking efforts" to other project members. You can't learn how to reason about code, if you don't reason.
The most important one: be humble. Just because you would've solved a problem differently, it doesn't mean that the code is bad. Don't spend time judging the code. You are there to learn from others, so be open to other solutions. Whether it is a good or bad example is so difficult to judge... be patient and you will realise what kind of code is easy to understand. Once you have some idea, take that knowledge to your next project. This may take weeks/months/years depending on the project size.

dmux1 reply#
This is all great advice. Two things that have helped me in particular

(1) applying the "analytical reading" rules defined in "How to Read A Book" to a code base. One of those rules, as Olikas said, is formulating hypotheses and questions and "actively engaging" with a code base (or any text).
(2) Compare and contrast a similar project (i.e. using the same language and framework) to figure out whether the structure of the project in question is following a general layout or not (e.g. Maven projects in Java).

Continue this thread — 1 reply

afarrell#
> I would recommend using some old school technology (pen/pencil and blank paper) and draw diagrams, write down every question and observation, notes.

I have found paper and pencil to work best for my brain trying to manage attention while doing many tasks, so I take this to heart. That said, I think there is probably a tool I can use to be significantly more effective in organizing my thoughts—but probably one made of paper and pencil in the genre of the bullet journal.
If anyone knows of any techniques of organizing notes like this, I’d be grateful for some names that I can google. For now, I’m going to try experimenting with various ways of using flashcards (ALA record cards).

opportune#
Well, I can definitely say I'm not an expert at it. Theoretically you might have more experience than me. But my job has me reading lots of open source code to try to learn about poorly documented APIs, so I've been kind of forced into it.

For me, I just try to follow the data and logic flow from beginning to where I want to do things. Though if I see something like a "strategy" pattern I ignore it unless I really need to know how it works; same goes for other code branches that seem unimportant to the greater program. You absolutely should use something like an IDE where you can move around quickly and get neat features like jumping to a class definition, find usages, etc. in case you get lost. It definitely takes time and isn't something you can just sit down and do for 8 hours straight. I generally can only look at code for 90 minutes before my eyes start glazing over and I need to take a break.

d0m#
Adding on top of what others have said..

* Switch job to a place where you can be pushed and mentored
* Make a lot of mistakes, but be sure to learn from them
* There are so many amazing books where the authors shared their mistakes/experience and how they made things better
* It's often much better to slow down and get things right by researching, discussing and prototyping than rushing and having to rebuild it a few times or maintaining shitty code.
* Try to think of the 10X when working on something. Of course, optimize for the current spec, but what happens if you get 10X more loads/users? Is there a way you can make it work for that use-case with roughly the same time? Often, the answer is yes by using a well-tested library and better tools. Ironically, sometimes being forced to think at a bigger scale makes you realize that your solution wasn't that great after all.. and that this problem was already solved.

Load more comments