
Steal the Code - holman
http://zachholman.com/2010/10/steal-the-code/
======
futuremint
This is usually how I go about learning a new area of development. I think
through the problem, get an idea of how it might work, maybe even write some
code, then go spelunking on github & google to see how other people solved it.

Sometimes I'm surprised to find my method was spot on. Other times I find
someone who already iterated the solution a few times and I can jump over
those mistakes to a more mature solution.

Learning to read other people's code and quickly get the gist of how it works
and recognizing patterns is crucial in becoming a proficient programmer.

------
random42
_hammering things out on your own is great. That’s almost an entirely
different class of learning, and it works well in the majority of cases._

I am deliberately taking this para out of context to point out how learning by
"hammering things out" is something to be discouraged highly, especially to
the young professionals. Sure, Advance work require breakthrough, _but it
cannot happen, unless you know/read/learn from your peers, in any field of
work._ Future of any field, is always based on the shoulders of the past work.

------
kevinelliott
I've long been considering putting together a directory of projects whose code
is fantastic for learning from. There's just too much code out there, and it
would be nice to see lists of "great iPhone code to learn from", "effective
and architecturally sound Ruby on Rails projects that scale", etc. This would
really require some assistance from the community, but long term I think it
would highlight code from quality hackers, and improve the status quo of
programmers out there.

Any such thing already exist?

~~~
blehn
As a programming novice, I think that's a great idea. (I haven't seen anything
like it... the closest might be stack overflow, where the best solutions
generally get voted to the top, but it tends to be fairly narrow in scope.) It
would be especially great if some or all of the code was annotated with
something like docco <http://jashkenas.github.com/docco/>

------
castis
I've found this to be an excellent method of learning patterns through
different languages.

This approach only truly works if you understand what you're doing after
you've 'borrowed' code. If you just blindly copy down the concepts and paste
where you need them without understanding why that block works the way it does
then you're not going to be up shits creek when it comes time to debugging
that part of the application.

------
mrjjwright
I have been doing this a lot more recently. I try to find smart programmers
who run highly organized, designed, and maintained little projects and read
their code, or step through it in a debugger. I am learning JS this way. I
then try to use their ideas in some way or copy them to take that ownership
step. Great post.

------
tesla
Another way to phrase this: read other people's code.

Reading code is important. Programmers should read code all the time.

------
steveklabnik
I posted the beginner's version of this over on the Hackety Hack blog the
other day. In my mind, this is one of the greatest advantages that Open Source
has to offer: the ability to learn how things work, by looking at them, taking
them apart, and utilizing it in your project.

This is also why I'm a BSD (well, WTFPL...) kind of guy, over GPL. Feel free
to take my code, and use it however you'd like. The thought of someone making
bad software because they couldn't follow my lead due to a licensing issue
makes me sad.

~~~
drv
Copying the _concepts_ in a piece of code doesn't fall under the restrictions
of copyright, so the license is irrelevant; there's no copying of the actual
code involved here.

~~~
steveklabnik
Yeah, but there's still a reason why "clean room" implementations exist.

Regardless, I was talking about straight-up copy/paste, I should have been
more clear.

------
fady
I would agree with you, in regards to HTML, CSS, & JS. Im a semi-web developer
,and I like to look at markup of some of my favorite devs, to see how they did
a certain layout, or how they made that cool effect, etc... good post

------
inetsee
“Good artists copy, great artists steal”.

quotation from Pablo Picasso

------
nlawalker
AKA "learn by example."

------
bayareaguy
The FreeBSD ports tree is a great place to steal code.

------
hyperlexic
I have been trying to teach myself programming for a couple years now, because
I got sick of getting a great idea and then having to 1) explain it to the
development team, 2) waiting for development 3) iterating through
modifications.

So as a new programmer with no ambition of paying another fortune for
'university training' I entered the rabbit hole of learning from online
resources, videos and books.

The signal to noise ratio is abominable, simply because a new programmer
doesn't know stink-code from unstink-code. Horrible, exploitable examples of
all languages flourish on high traffic sites and sites that rank high for
"$language tutorial". these get re-pasted on 10,000 s of sites and become 'the
way it is done'. You might get some comments in the original post that the
author didn't properly secure the code, but rarely will you get that commenter
to show the proper way to do it.

The gap between 'hello world' and real programming resources is only getting
worse, and it affects the quality of Internet programming in general.

You can find a 1000 great tutorials on making cool online forms and widgets
using jQuery - but they almost ALL will add the caveat "obviously for sake of
brevity i'm not sanitizing data - you will want to take care of that". well,
maybe we don't need any more tutorials that don't go into the details securing
your data, because I'd venture to guess many newbies (like myself in the
beginning) will download the demo script and upload it to our shared host and
say 'done'. That leaves a lot of vulnerable low hanging fruit that is then re-
copied by more people entering programming, and perpetuates the stinkcode that
is so ubiquitous that it becomes 'standard'.

This leads to another problem newbatroids will face - seeing the same type of
applications in tutorials built by the same language over and over. JavaScript
(and the awesome jQuery library) is NOT simply an easy way to make cool photo
sliders. We sure don't need any more tutorials on making cool photo sliders
and other UI candy with client-side programming languages and libraries that
have immense power to do other things-very very cool things. The lack of
compelling, interesting examples of what JavaScript can do really limits the
overall advance of web development, since newbatroids don't know it's not just
for making Fancybox widgets or cool rollover effects or menus and aren't shown
the real power of the language. The problem is that these are very common
entry points for new programmers. JavaScript can be an incredible tool to
teach programming since it's everywhere - free - and full of problems that
must be fixed which teach the new programmer the difference between stink and
unstink code. Crockford's series of videos and books really opened my eyes to
the bigger picture.

Another problem newbatrons will face is the inability to decouple UI and
'design' from the programming logic, and by necessity then needing to learn
how to do both - which starts to really - really - really - suck after a few
big projects. It's easy to say 'split your code into a model, view and
controller', but a newbariffic probably isn't a part of team and is hammering
together some frankenstein-esque 'thing' made up of photoshop slices, PHP code
(maybe formed into functions) and probably cut and paste jquery UI plugins
from online resources. maybe they have experienced the fun of the nervous
breakdown when a client is asking for heavy modification of a wordpress
template and wants it to be pixel perfect with proper typography, and cool
features that lead our young programmer into hacking away at variable-quality
plugins that may or may not break on the next update.

In terms of online free resources/tutorials, it's huge. But there's also a
vast gap between the proverbial 'hello world' and real deal programming. I
would venture to say many new programmers start with a WAMP like environment,
tool around with Wordpress or some other easy publishing platform and then
find themselves really struggling to make the leap to 'proper' programming.

For one, I would like to see you smart guys help out us wannabe-programmer
marketing turds by showing us how to set up a proper development environment -
and i mean everything from the machine i run locally - and the software i use
to make software - to 'cloud' based hosting to explaining at least where to
start conceptually so i can do my own informed research. Do tutorials in real-
world development environments. use linux and the command line. force
newbatronics to understand how to properly code from 'hello world' and not
even allow a messy windows based environment or plug and play platforms unless
that's clearly as far as the programmer wants to go - and for many that's far
enough.

Probably the most informative exercise I did was building a web app - then
trying to hack it from as many ways as i could imagine. I spent a great deal
of time learning about client-side security by continuously hacking my own
applications and trying to anticipate how a skilled hacker would utilize the
seemingly infinite attack surface exposed by bad client-side programming - i
was amazed and horrified at how easy it was - and mobile hasn't even really
hit yet, but hold on to your hats with that one. but that exercise taught me
so much about programming in general, that it changed the way i conceptualized
'programming'. I thought it was about objects and functions and operators
whatnot - but realized how much of it is policies and structure and scope.
That could have been stressed more in my opinion from the popular online
programming sites, but i guess it's easier to get traffic with the headline
'50 mindblowing jQuery photo sliders' rather than 'stop using global variables
and learn about function scope'.

