|
|
|
|
|
by badminton1
3387 days ago
|
|
Being a full stack developer means being proficient on the frontend as well as backend. Unfortunately none of those tutorials prepare you to work at the backend of a production service. To say you can do backend code because you can write in JavaScript is like saying you can write a paper on cardiology because you know English. Knowing the language is a small part of the job. There is a lot of domain knowledge that is required in addition to the language. Learn networking, learn operating systems, learn distributed systems, learn performance and scalability, learn about databases. Then learn node. |
|
Let's take a look at the "best practices" tutorial from nodeschool.io, one of the recommended tutorials.
https://github.com/excellalabs/js-best-practices-workshopper...
Can you list all the mistakes in this code?
- Using IEEE 754 floating point numbers (built-in Number type in JavaScript) for storing a balance is unsafe. Read more here: http://stackoverflow.com/questions/3730019/why-not-use-doubl...
- Your bank would never represent a balance in that way. They store transactions individually and they fold them to compute your balance.
- The input validation is extremely weak. Pass in: undefined, NaN, Infinity or some funny value and you will end up with a corrupted balance, or force "decreaseBalance" to increase, and "increaseBalance" to decrease.. The isValidAmount method should use "isFinite" rather than strong comparison with null.
And let's better stop here...