Ask HN: How to learn best practices when you have no one to teach you?
440 pointsI 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
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
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...
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.
Firefox: https://addons.mozilla.org/en-US/firefox/addon/videospeed/
Chrome: https://chrome.google.com/webstore/detail/video-speed-contro...
Continue this thread — 4 replies
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).
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.
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
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.
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.
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
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.
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.
It'll soon become obvious which ones are good codebases and which ones aren't.
———
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?
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.
(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
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).
https://www.dropbox.com/s/q5mtxxk6bswkag6/Read%20Code.pdf?dl...
https://www.nemil.com/on-software-engineering/index.html
(The article has a few great HN threads on reading code; after all, there are lots of contexts where you need to read without working someone in person who’s been involved in that code)
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.
* 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.
All comments shown.
Couldn't load more comments. Check your connection and try again.