Due to the nature of software development, there are many resources and code samples available online. You probably already know this and have used sites like StackOverflow. This site (GitHub) was built to help people share code.
In fact, sharing code, either as an open source project or teaching through blog posts or talks, is part of the ethos of many software developers and especially within the Ruby on Rails community.
Learning to utilize Google and find solutions online is an essential part of learning to code and being a successful developer.
That said, it does not come without some murky ethical waters, particularly for students.
Programmers use the term debugging to describe trying to figure out why code isn't working the way they expected it to.
- Remove code until it's working again, then add code back in, one small change at a time, until you can pin-point the code that breaks.
- Look at the console and play with the code. Does it output what you thought it would in the console? If not, figure out what would. If it does, what's different about my code file? (the web inspector, js console, or IRB)
- Read the error message a lot of times the error message you receive will tell you exactly what you need to do to fix your solution. Make sure to read the message.
- Print stuff out. In HTML, you can add borders to elements with CSS. In JavaScript, you can use
document.write
,console.log
, andalert
. In Ruby, tryputs
,print
, orp
. - Describe the code, line-by-line, to an imaginary friend, rubber ducky, or a friendly bear.
- Research. This includes Google, StackOverflow, books, and blog posts.
You should try to solve a challenge or at least psuedo-code using just what you've learned and the resources we've given you. If you get stuck or during refactoring, you can feel free to google for help. However, you should always understand the code you submit. If you cannot describe the solution to a non-technical person, then you should not submit that code.
Learning to Google effectively actually takes some practice and skill. It's an important skill for you to learn. There are two main times you will Google or do online research:
- To debug a code problem
- To figure out where to start or go next when you get stuck.
Note: you may not understand all of these tips. They should all make sense later in Phase 0
If you are getting an error message, always google it in quotes first.
Using the right words in Google is essential. You should play with this as you go along to see how it changes your results.
Questions you should ask yourself to find keywords are:
- What tech are you using? (HTML, CSS, Ruby, etc)
- Are you using a framework (Rails), library (jQuery), gem (Jekyll), or specific technique (Object-oriented)?
- What are you trying to accomplish? (Position div in center? Return a string in Ruby?)
- Are there other or generic terms for anything? (i.e. "element" instead of "div"; "class" instead of "object")
If you still can't find help, try breaking up your question into smaller questions. For example, if you are trying to add a header with a red background, you could search for "create header" or "background color."
Breaking down problems into smaller, more manageable pieces is the most important skill you will learn at DBC. Try to do it everywhere.
Once you get some results, make sure to ask:
- How old is this post?
- Who wrote it? Are they trust-worthy?
- Does it solve my problem?
- Does it solve part of my problem?
- Do I understand the solution? If not, what can I do to understand it?
Take a look at these resources as you think about online research:
- If you only learn one technical skill, learn this one
- Quick Tips to make your Google Searches Smarter
- 3 Things to try when Google doesn't have the answer .
When you research solutions online and read through documentation, you will often encounter sample code. Do NOT copy and paste this code into your code base.
- Copied code often will not work (ie - if you copy the
$
for Command Line code). - When you copy code, you don't take the time to think. What is it that I want to do next? (clone a repo). What is the command to do that?
- Copied code represents technical debt in your coding project. If you don't understand every line, you could be introducing a bug or security issue.
- Try out the code in a separate file (you can copy and paste it here). Understand what it does and how to use it.
- In your own code, use the code samples as a reference. Try to type without looking first (to help you learn) and if you can't remember / don't know the command yet, then look at the sample.
- Make sure to translate the sample to your environment by replacing generic values (USERNAME, filename, etc) with actual values.