How Software Engineers Can Write Better Code

preview_player
Показать описание

There's a better way to write code, and that's by having your code meet 3 high-level goals. As a programmer, every time you write code you want to be asking yourself if this code meets those 3 goals. And in doing so, it’ll have you build a coder’s mindset so every time you pick up a coding task, you’re thinking like a programmer without even thinking about it.

0:00 Write Better Code
0:46 Write Code that Solves a Specific Problem
4:52 Code Example of How to Do It
5:16 Code Example of How NOT to Do It
6:06 Why It's Wrong
7:29 Shortform Sponsor
9:29 Write Code that's Easy to Read and Maintain
10:45 Code Example of Poorly Written Code
11:40 Code Example of Properly Written Code
14:35 Write Code that's Scalable and Extendable
18:03 The Coder's Mindset
20:08 I appreciate you!

------------------------


📓 Learning Resources:

👨‍💻 My Coding Gear:
Рекомендации по теме
Комментарии
Автор

I hope this video helps you out! I've included timestamps to help you navigate around the video.


PS - There are code examples throughout the video that show how to implement what I'm explaining. Hope they help!

fknight
Автор

Choose simplicity over complexity every time you can

LogicEu
Автор

Finally some solid programming advice, explained by someone who really gets it and knows how to explain things. Not just someone repeating stuff they read.

TheIllerX
Автор

I had to laugh when you mentioned testing bubble sort with 3 things and then saying "Oh, that's great! I've solved my problem!" I had a similar problem with another developer on an actual project. Because he didn't want to bother to learn the library for a file-based database system, he decided to implement nested linear searches for a daily transaction extract. The structure of the data was a members table (unique members), an accounts table (a member could have 0 or more accounts), and then a transactions table (an account could have zero more transactions). The first data set we tested with had 21 members, each with one account and one transaction. The nested linear search worked fine for that. But, when it went to production, we were going to be dealing with 3000 members, 4500 accounts, and an ever-growing list of transactions. In less than 2 weeks, the process took more than 24 hours to run.

warspaniel
Автор

Banger of a video from 30 seconds in.. instant like.

I'm gaining a lot of ammo here for my upcoming meeting I have with the other devs in my company (that I've been at for 2 months) to split out code more.. we have controllers with thousands of lines of code in them at the moment that do about 5000 things, which is making my job of building out an API to integrate with other companies a nightmare to try to parse out logic here and there from existing functionalities. At least I'm getting to build out service classes exactly like I want to 🙂

KBoxx
Автор

With the combo function you mentioned, I wish you'd gone into more detail about how one requirement (vowel counting) is asking a question about the state of its inputs, while the other (letter substitution) is manipulating that state. It leaves you with multiple questions like "What happens if the letter substitution involves a vowel?" and "How do I get the vowel count *after* the letter substitution?"

taserianAlephNull
Автор

"thinking like a programmer without even thinking about it" -- I feel like I've finally reached this point and it is peaceful. Going to work and doing my job has become calmer and more productive now that I don't need to put much energy toward being conscious of how I code. It's nice.

kell
Автор

One key to simplicity, transparence and reliability is refactoring. If you see a complicated code, that operates already, refactor it by transforming to the use of well understood patterns.

jensBendig
Автор

It was a great inspiration for the upcoming new year as a freshmen in college it really boosts me up - from India

RaghuArunkumar
Автор

Very good content, looking forward to more of this type!

koti
Автор

Now just starting my coding journey, this was very helpful to watch so I can start to implement this from the start. As well just pausing at 17:55 gave me a good idea of how real lines of code look like for a product. Very organized and helped me just understand it a little.

zahkarii
Автор

Map function adds complexity of your own code and own function rather than relying on built in functionality of regular expression replacement, which does the job more concisely.

supremoluminary
Автор

Another great video! Thanks Forrest. You helped me get through college with some of your advice. Keep up the great work!

SoLiDStretchDB
Автор

And #4 use gof design patterns. Use standard names and solutions.

martinbakker
Автор

Very good video!
But I must say I mentioned a habit, especially with javascript and python devs, that they tend to use objects or modules wherever they can; because it's so easy to just call an objects function to return one value but writing a function for that.
That may be convenient and even good for the project, but in a lot of cases, it takes double the time of compute!
Let's take the first example of replacing all occurrences of one letter by another. - I really was too lazy now to test it but am pretty sure that the simple loop would be the fastest solution. - Please correct me if I'm wrong! - This is just an example.
I know that functional programming seems like a habit of oldies, but it is not. - If you may replace an object/object call with a clearly written function without the use of oop and you do it every time it is applicable in your project, you'll gain a lot of speed!

henrischomäcker
Автор

I think code should be easy to reason about, hence I like to use functional concepts in my code. Pure functions is on of the biggest thing, Immutability also. Mutating state can be hard to not do in some languages but then it is really important that functions does one and one thing only (no side-effects).

I also like to use monads to compose functions. You can do so much with, wrap try catch logic behind it as an example. The underlying code can be more complex but using it is smooth as butter 😊

joeldegerman
Автор

7:00 You forgot to mention the fact doing both count and replacement on the string turns messy if you're replacing vowels with consonants or vice versa.

Maybe if YOU wrote the code, you'll know in which order the operations are applied and have a good idea of what behaviour to expect... for like 2 days after you write it.
But anyone else or even your future self will have no idea what to expect just going by the function's name and will have to go through the trouble of reading the code(and if they have any sense also splitting it into two function).

roostermaind
Автор

When I was an assistant superintendent during my construction days I don't know how many times I've had to tell people during orientation not to use a drill as a hammer, I mean it may work but eventually it's gonna blow up on you lmfao!

Trollleben
Автор

4:54 Maybe I can find a video of yours, explaining lambda functions. I did not learn about it, yet.

edu_aqui
Автор

Great content really enjoyed it!! can you make a video on how to decide design patterns for python or if you've a set of rules while structuring all your classes and your code? I end up making so many classes and calling them everywhere, want to understand how you handle it, Thanks!

AbhayNayak
visit shbcf.ru