# Looking at others code

**URL:** <https://forum.freecodecamp.org/t/looking-at-others-code/138756>\
**Category:** General\
**Created:** [July 28, 2017, 4:10pm UTC](https://forum.freecodecamp.org/t/looking-at-others-code/138756 "2017-07-28T16:10:15Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![fmccaa1](https://avatars.discourse-cdn.com/v4/letter/f/85f322/32.png) [@fmccaa1](https://forum.freecodecamp.org/u/fmccaa1)\
**Post date:** [July 28, 2017, 4:10pm UTC](https://forum.freecodecamp.org/t/looking-at-others-code/138756/1 "2017-07-28T16:10:15Z")

</div>

Is it bad looking at other people code?

---

<div class="post-metadata">

**Author:** ![michaelhenderson](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/michaelhenderson/32/356215_2.png) [@michaelhenderson](https://forum.freecodecamp.org/u/michaelhenderson)\
**Post date:** [July 28, 2017, 4:25pm UTC](https://forum.freecodecamp.org/t/looking-at-others-code/138756/2 "2017-07-28T16:25:48Z")

</div>

it depends.  
I look at and reference other peoples code all the time through Google and other resources. I do not use it until I understand what it is doing and why.

---

<div class="post-metadata">

**Author:** ![fmccaa1](https://avatars.discourse-cdn.com/v4/letter/f/85f322/32.png) [@fmccaa1](https://forum.freecodecamp.org/u/fmccaa1)\
**Post date:** [July 28, 2017, 4:41pm UTC](https://forum.freecodecamp.org/t/looking-at-others-code/138756/3 "2017-07-28T16:41:14Z")

</div>

Thank you very much sir

---

<div class="post-metadata">

**Author:** ![ppc](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ppc/32/63349_2.png) [@ppc](https://forum.freecodecamp.org/u/ppc)\
**Post date:** [July 28, 2017, 4:49pm UTC](https://forum.freecodecamp.org/t/looking-at-others-code/138756/4 "2017-07-28T16:49:08Z")

</div>

it depends

if you copy a solution to freecodecamp exercises in order to understand it later then you lose out on the main benefit of the exercises which is to give beginners an opportunity to gradually develop problem-solving skills

if you look at code that is somehow better than your solution you miss out on practicing iterative development which is to quickly get a working solution first then review and identify or measure areas of improvement - then actually make small incremental enhancements

What is your motivation or need to look at someone else’s code?

---

<div class="post-metadata">

**Author:** ![fmccaa1](https://avatars.discourse-cdn.com/v4/letter/f/85f322/32.png) [@fmccaa1](https://forum.freecodecamp.org/u/fmccaa1)\
**Post date:** [July 28, 2017, 4:50pm UTC](https://forum.freecodecamp.org/t/looking-at-others-code/138756/5 "2017-07-28T16:50:41Z")

</div>

No need just wondering in case I can learn it from them and apply it to my own code

---

<div class="post-metadata">

**Author:** ![ppc](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ppc/32/63349_2.png) [@ppc](https://forum.freecodecamp.org/u/ppc)\
**Post date:** [July 28, 2017, 4:55pm UTC](https://forum.freecodecamp.org/t/looking-at-others-code/138756/6 "2017-07-28T16:55:34Z")

</div>

I feel developing problem-solving skills is essential and way more important for someone learning to program than copying coding techniques from other people

---

<div class="post-metadata">

**Author:** ![fmccaa1](https://avatars.discourse-cdn.com/v4/letter/f/85f322/32.png) [@fmccaa1](https://forum.freecodecamp.org/u/fmccaa1)\
**Post date:** [July 28, 2017, 4:56pm UTC](https://forum.freecodecamp.org/t/looking-at-others-code/138756/7 "2017-07-28T16:56:41Z")

</div>

I understand and I totally respect your opinion bro

---

<div class="post-metadata">

**Author:** ![tmpbit](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/tmpbit/32/48843_2.png) [@tmpbit](https://forum.freecodecamp.org/u/tmpbit)\
**Post date:** [July 28, 2017, 8:33pm UTC](https://forum.freecodecamp.org/t/looking-at-others-code/138756/8 "2017-07-28T20:33:51Z")

</div>

I think that looking at somebody else’s code might point you to right direction or show you how to solve problem more elegant (it depends of course). Stealing the code is not good, but learning on it is OK 🙂  
It’s my opinion

---

<div class="post-metadata">

**Author:** ![DanCouper](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/dancouper/32/158608_2.png) [@DanCouper](https://forum.freecodecamp.org/u/DanCouper)\
**Post date:** [July 29, 2017, 10:31am UTC](https://forum.freecodecamp.org/t/looking-at-others-code/138756/9 "2017-07-29T10:31:51Z")

</div>

Yes, read other people’s code all the time, particularly if it’s good code. Read it to see how something is done that you’re stuck on, or different ways to do something that you wouldn’t have thought of. You do need to figure out how it works and why it works, not just copy blindly. You can do all the tutorials and practice exercises and toy projects you want, but you _need_ to see how other people have solved problems. In particular, the thing most exercises don’t or can’t teach is how to structure code for real-world projects.

A large chunk of any dev job involves understanding other peoples’ code (writing code is normally done less often, sometimes much less often, and is generally the easier part), get used to doing it now.

Eg, I’ve been a JS Dev for years now, the things I think that taught me more than any book, tutorial or exercise were the source code to [underscore](http://underscorejs.org):

[http://underscorejs.org/docs/underscore.html](http://underscorejs.org/docs/underscore.html)

The source code to its child project, underscore-contrib:

> **[documentcloud/underscore-contrib](https://github.com/documentcloud/underscore-contrib)**
>
> underscore-contrib - The brass buckles on Underscore's utility belt

The source code to [Backbone](http://backbonejs.org):

[http://backbonejs.org/docs/backbone.html](http://backbonejs.org/docs/backbone.html)

Both of those projects have been superceded now (Underscore by Lodash, Backbone by different frameworks like React and Angular), but the code is really good. The functions Underscore provide make most of the FCC algorithm exercises trivial; in a sense I have “cheated” on them by learning how to write, say, a useful range function, by reading that source code, then applying that knowledge 5-6 years later when doing the FCC exercises. Similarly I could say I “cheated” when I learned how to use generators in JS: the way I learned how to use them was to copy code verbatim from Python’s Itertools library and translate it to JS: I don’t know Python at all well, but this allowed me to use Python tutorials to learn the JS version - at the time I wanted to learn to use generators, they were a new feature in JS, so there were few resources, whereas they’d been around for a long while in Python.

* * *

As an example, there is a challenge “Falsely Bouncer” in the FCC algorithms section. Many languages provide a function/method for lists/arrays, normally called `compact`, which does exactly what the challenge asks for. Underscore has an implementation of compact:

```auto
//Trim out all falsy values from an array.
 _.compact = function(array) {
   return _.filter(array, _.identity);
 };

```

Which, when you dig through the code, is the same as:

```auto
var identity = function(x) {
  return x;
};

var compact = function(array) {
   return array.filter(identity);
 };

```

Which is the same as

```auto
function compact(arr) {
  return arr.filter(x => x);
}

```

Which if I change the name of the function, is a possible answer for the falsey bouncer problem. Putting myself in the position of a learner, I still need to understand _why_ it works. But now, I can ask “I have this function which works, it removes the falsey values. Why does it work?” That is a good question which, for someone who understands coercion in JS is very easy to answer well.

---

<div class="post-metadata">

**Author:** ![Boda](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/boda/32/103141_2.png) [@Boda](https://forum.freecodecamp.org/u/Boda)\
**Post date:** [January 26, 2018, 12:09pm UTC](https://forum.freecodecamp.org/t/looking-at-others-code/138756/10 "2018-01-26T12:09:26Z")

</div>

Thanks Dan. I’m new to coding and you have made me comfortable with using solutions to learn from. Roger

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 16, 2021, 6:00pm UTC](https://forum.freecodecamp.org/t/looking-at-others-code/138756/11 "2021-01-16T18:00:31Z")

</div>

Closed on January 16, 2021, 6:00pm UTC


