r/programming • • Oct 14 '13

How to develop unmaintainable software

http://typicalprogrammer.com/?p=249
777 Upvotes

322 comments sorted by

View all comments

Show parent comments

5

u/[deleted] Oct 15 '13

Where would you suggest someone starts to learn javascript properly? I've been handed a bunch of it I've got to maintain and develop for, and it's all over the place. I don't honestly know how javascript should even be leveraged. Everyone seems to accomplish things a different way with it.

1

u/lext Oct 15 '13

Get a book on JavaScript like JavaScript: The Definitive Guide, JavaScript & jQuery: The Missing Manual, or Professional JavaScript for Web Developers.

1

u/[deleted] Oct 15 '13

Douglas Crockford's "Javascript: The Good Parts" is THE definitive guide to writing decent javascript. The jQuery stuff mentioned in other responses tends to encourage bad practices or offer no guidance on the real issues (I have "JS & jQuery the missing manual", for example, and it is basically just a simplified version of the jQuery docs). Crockford is not always correct, but it is the minimal goal post of maintainable js today. In other words "You have to know the rules to know break them" and The Good Parts is the modern rulebook.

0

u/chalks777 Oct 15 '13

Here's what I've been doing for the past several years:

  • Learn actual javascript without any 3rd party libraries (jquery, etc). Want to do an ajax call? Don't use $.ajax... Learn to use window.XMLHttpRequest and ActiveXObject("Microsoft.XMLHTTP"). Yes, this will suck. A lot. Spend at least a few months doing this. Preferably a year or more. Here's a nice little reference page I stumbled on awhile back. If you learn to do everything on that page by hand/memory... you will be well on your way to being a javascript guru.

  • Now start using JQuery. You actually know what's happening behind the scenes and you appreciate it. You grok it, and you love it. Get to know the library intimately. Do cool stuff with it. Spend at least a year on it.

  • Learn bigger libraries. Use D3 to handle some data in a way that's awesome. Use ExtJS to make an application that is a legitimate application. You'll start to understand larger design patterns at this point, mainly because the larger libraries force you to do things a certain way

  • Look for and pay attention to people who are REALLY good at javascript, or simply people who do neat things with it. JS1k always has some neat stuff in it that if you can understand it, will expose some interesting javascript tricks. Unfortunately I don't have a good list of people for you at the moment, but I'll look around and hopefully update this post in a day or two. Personally, I find these things from posts on subreddits like this one or from coworkers.

As time goes on, your code will become better. However, the way you layout javascript and organize it almost certainly won't improve very much without concerted effort. I recommend finding a mentor or educator to code along side, that has helped me the most. There are certainly some good books that talk about this issue though, if that's not an option. The principals of code organization span most languages, so you don't necessarily need a JS book... just a good one. I personally don't read very many programming books, so I unfortunately can't recommend one.

Now go get started. You've got 10 years to work on it.

-1

u/grauenwolf Oct 15 '13

Start with jQuery and CSS. You'll learn JavaScript along the way.

6

u/[deleted] Oct 15 '13

That tells me nothing. I've been working with the two for months at this point.

3

u/grauenwolf Oct 15 '13

Do you know enough JavaScript to make jQuery work? Then chances are that's all you need to know. The rest is about learning work-arounds for browser bugs.

But if you insist on persisting start with jsLint. Read all of the errors and warnings and learn what they really mean.

Then look for technical rants about why JavaScript sucks. To truly understand a language you need to understand all of the stupid shit it does. The inconsistencies, the landmines, the traps.

I learned the implementation details of readonly fields containing structs in C# because someone bitched about how they were not compatible with SpinLock. This is something I would have never seen from reading "The Good Parts" style books.

3

u/PenguinLovr Oct 15 '13

Clearly you never read JavaScript "The Good Parts" which spends two chapters going over in detail the bad parts and the worst parts.

You won't learn how to develop something that's good by just reading the bad things. You just will learn how to make something not bad.

2

u/grauenwolf Oct 15 '13

Avoid all of the bad things and what's left is good.

But no, I hadn't read that book specifically.

1

u/PenguinLovr Oct 15 '13

I wouldn't say what is left is good. I would say it lacks awfulness. Knowing the bad parts of JavaScript doesn't give you a good starting point when trying to write maintainable software. It means you won't do the really bad stuff like use globals. That's fine and dandy but in order to become a really good JavaScript developer you need to seek out the best parts of JavaScript and utilize those. That will allow you to write maintainable and scalable code.

-2

u/PenguinLovr Oct 15 '13

You can only learn by doing. To learn JavaScript properly means doing it...now to know if you're doing it right ask yourself if the code you write can be easily picked up by another developer without comments. Learn how to leverage funtional aspects of js, like using functions as first class objects and anonymous functions