Coding For Dummies by Nikhil Abraham


44563b90660206b.jpg Author Nikhil Abraham
Isbn 9781118951309
File size 22.1 MB
Year 2015
Pages 288
Language English
File format PDF
Category programming



 

Coding Coding by Nikhil Abraham Coding For Dummies® Published by: John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030-5774, www.wiley.com Copyright © 2015 by John Wiley & Sons, Inc., Hoboken, New Jersey Media and software compilation copyright © 2015 by John Wiley & Sons, Inc. All rights reserved. Published simultaneously in Canada No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without the prior written permission of the Publisher. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at www.wiley.com/go/permissions. Trademarks: Wiley, For Dummies, the Dummies Man logo, Dummies.com, Making Everything Easier, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and may not be used without written permission. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned in this book. LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ. For general information on our other products and services, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002. For technical support, please visit www.wiley.com/techsupport. Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com. Library of Congress Control Number: 2014954659 ISBN 978-1-118-95130-9 (pbk); ISBN 978-1-118-95130-9 (ebk); ISBN 978-1-118-97091-1 (ebk) Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 Contents at a Glance Introduction................................................................. 1 Part I: Getting Started with Coding................................ 5 Chapter 1: What Is Coding?............................................................................................... 7 Chapter 2: Programming for the Web............................................................................ 19 Chapter 3: Becoming a Programmer.............................................................................. 33 Part II: Building the Silent and Interactive Web Page.................................................. 41 Chapter 4: Exploring Basic HTML................................................................................... 43 Chapter 5: Getting More Out of HTML........................................................................... 59 Chapter 6: Getting Stylish with CSS................................................................................ 75 Chapter 7: Next Steps with CSS....................................................................................... 97 Chapter 8: Working Faster with Twitter Bootstrap.................................................... 119 Chapter 9: Adding in JavaScript.................................................................................... 135 Part III: Putting Together a Web Application.............. 157 Chapter 10: Building Your Own App............................................................................ 159 Chapter 11: Researching Your First Web Application............................................... 171 Chapter 12: Coding and Debugging Your First Web Application.............................. 187 Part IV: Developing Your Coding Skills Further........... 197 Chapter 13: Getting Familiar with Ruby....................................................................... 199 Chapter 14: Wrapping Your Head around Python...................................................... 213 Part V: The Part of Tens............................................ 227 Chapter 15: Ten Free Resources for Coding and Coders........................................... 229 Chapter 16: Ten Tips for Novice Coders...................................................................... 237 Index........................................................................245 Table of Contents Introduction.................................................................. 1 About This Book............................................................................................... 2 Foolish Assumptions........................................................................................ 2 Icons Used in This Book.................................................................................. 3 Beyond the Book.............................................................................................. 3 Where to Go from Here.................................................................................... 4 Part I: Getting Started with Coding................................. 5 Chapter 1: What Is Coding? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Defining What Code Is...................................................................................... 8 Following instructions............................................................................ 8 Writing code with some Angry Birds................................................... 9 Understanding What Coding Can Do for You............................................. 10 Eating the world with software........................................................... 10 Coding on the job.................................................................................. 12 Scratching your own itch (and becoming rich and famous)........... 13 Surveying the Types of Programming Languages...................................... 13 Comparing low-level and high-level programming languages........ 15 Contrasting compiled code and interpreted code........................... 16 Programming for the web.................................................................... 16 Taking a Tour of a Web App Built with Code.............................................. 16 Defining the app’s purpose and scope............................................... 17 Standing on the shoulders of giants................................................... 17 Chapter 2: Programming for the Web . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Displaying Web Pages on Your Desktop and Mobile Device.................... 19 Hacking your favorite news website.................................................. 20 Understanding how the World Wide Web works............................. 22 Watching out for your front end and back end................................. 24 Defining web and mobile applications............................................... 25 Coding Web Applications.............................................................................. 26 Starting with HTML, CSS, and JavaScript........................................... 26 Adding logic with Python, Ruby, or PHP........................................... 26 Coding Mobile Applications.......................................................................... 27 Building mobile web apps................................................................... 29 Building native mobile apps................................................................ 30 viii Coding For Dummies Chapter 3: Becoming a Programmer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Writing Code Using a Process....................................................................... 33 Researching what you want to build.................................................. 35 Designing your app............................................................................... 36 Coding your app.................................................................................... 37 Debugging your code........................................................................... 38 Picking Tools for the Job............................................................................... 38 Working offline...................................................................................... 38 Working online with Codecademy.com............................................. 39 Part II: Building the Silent and Interactive Web Page.......41 Chapter 4: Exploring Basic HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 What Does HTML Do?.................................................................................... 43 Understanding HTML Structure................................................................... 44 Identifying elements............................................................................. 45 Featuring your best attribute.............................................................. 46 Standing head, title, and body above the rest.................................. 48 Getting Familiar with Common HTML Tasks and Tags............................. 49 Writing headlines.................................................................................. 51 Organizing text in paragraphs............................................................. 52 Linking to your (heart’s) content....................................................... 52 Adding images....................................................................................... 54 Styling Me Pretty............................................................................................ 55 Highlighting with bold, italics, underline, and strikethrough......... 55 Raising and lowering text with superscript and subscript............. 56 Building Your First Website Using HTML.................................................... 57 Chapter 5: Getting More Out of HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Organizing Content on the Page................................................................... 59 Listing Data...................................................................................................... 61 Creating ordered and unordered lists............................................... 62 Nesting lists........................................................................................... 63 Putting Data in Tables.................................................................................... 64 Basic table structuring......................................................................... 65 Stretching table columns and rows.................................................... 66 Aligning tables and cells...................................................................... 67 Filling Out Forms............................................................................................ 70 Understanding how forms work......................................................... 71 Creating basic forms............................................................................ 72 Practicing More with HTML.......................................................................... 73 Table of Contents Chapter 6: Getting Stylish with CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 What Does CSS Do?........................................................................................ 75 CSS Structure.................................................................................................. 77 Choosing the element to style............................................................. 77 My property has value......................................................................... 78 Hacking the CSS on your favorite website......................................... 79 Common CSS Tasks and Selectors............................................................... 81 Font gymnastics: size, color, style, family, and decoration............ 82 Customizing links.................................................................................. 86 Adding background images and styling foreground images........... 88 Styling Me Pretty............................................................................................ 92 Adding CSS to your HTML................................................................... 92 Building your first web page............................................................... 94 Chapter 7: Next Steps with CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 Styling (More) Elements on Your Page........................................................ 98 Styling lists............................................................................................. 98 Designing tables.................................................................................. 101 Selecting Elements to Style......................................................................... 103 Styling specific elements.................................................................... 104 Naming HTML elements..................................................................... 107 Aligning and Laying Out Your Elements.................................................... 109 Organizing data on the page.............................................................. 109 Shaping the div.................................................................................... 111 Understanding the box model........................................................... 113 Positioning the boxes......................................................................... 114 Writing More Advanced CSS....................................................................... 118 Chapter 8: Working Faster with Twitter Bootstrap . . . . . . . . . . . . . . . 119 Figuring Out What Bootstrap Does............................................................ 119 Installing Bootstrap...................................................................................... 121 Understanding the Layout Options............................................................ 122 Lining up on the grid system............................................................. 122 Dragging and dropping to a website................................................ 124 Using predefined templates............................................................... 125 Adapting layout for mobile, tablet, and desktop............................ 126 Coding Basic Web page Elements.............................................................. 128 Designing buttons............................................................................... 128 Navigating with toolbars.................................................................... 130 Adding icons........................................................................................ 131 Build the Airbnb Home Page....................................................................... 132 ix x Coding For Dummies Chapter 9: Adding in JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 What Does JavaScript Do?........................................................................... 135 Understanding JavaScript Structure.......................................................... 137 Using Semicolons, Quotes, Parentheses, and Braces.............................. 138 Coding Common JavaScript Tasks............................................................. 139 Storing data with variables................................................................ 139 Making decisions with if-else statements........................................ 140 Working with string and number methods..................................... 144 Alerting users and prompting them for input................................. 146 Naming code with functions.............................................................. 146 Adding JavaScript to the webpage................................................... 148 Writing Your First JavaScript Program...................................................... 149 Working with APIs........................................................................................ 149 What do APIs do?................................................................................ 150 Scraping data without an API............................................................ 151 Researching and choosing an API.................................................... 152 Using JavaScript Libraries........................................................................... 153 jQuery................................................................................................... 153 D3.js...................................................................................................... 153 Searching for Videos with YouTube’s API................................................. 155 Part III: Putting Together a Web Application............... 157 Chapter 10: Building Your Own App . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 Building a Location-Based Offer App......................................................... 159 Understanding the situation.............................................................. 160 Plotting your next steps..................................................................... 160 Following an App Development Process................................................... 161 Planning Your First Web Application......................................................... 162 Exploring the Overall Process.................................................................... 163 Meeting the People Who Bring a Web App to Life................................... 165 Creating with designers..................................................................... 165 Coding with front- and back-end developers.................................. 167 Managing with product managers.................................................... 168 Testing with quality assurance......................................................... 169 Chapter 11: Researching Your First Web Application . . . . . . . . . . . . 171 Dividing the App into Steps......................................................................... 172 Finding your app’s functionality....................................................... 172 Finding your app’s functionality: My version................................. 172 Finding your app’s form..................................................................... 174 Finding your app’s form: The McDuck’s Offer App design............ 178 Table of Contents Identifying Research Sources...................................................................... 179 Researching the Steps in the McDuck’s Offer App................................... 181 Choosing a Solution for Each Step............................................................. 184 Chapter 12: Coding and Debugging Your First Web Application . . . 187 Getting Ready to Code................................................................................. 187 Coding Your First Web Application........................................................... 188 Development environment................................................................ 188 Pre-written code.................................................................................. 189 Coding steps for you to follow.......................................................... 192 Debugging Your App.................................................................................... 195 Part IV: Developing Your Coding Skills Further............ 197 Chapter 13: Getting Familiar with Ruby . . . . . . . . . . . . . . . . . . . . . . . . . 199 What Does Ruby Do?.................................................................................... 199 Defining Ruby Structure............................................................................... 200 Understanding the principles of Ruby............................................. 201 Styling and spacing............................................................................. 202 Coding Common Ruby Tasks and Commands.......................................... 203 Defining data types and variables.................................................... 203 Computing simple and advanced math........................................... 204 Using strings and special characters............................................... 205 Deciding with conditionals: If, elsif, else.......................................... 206 Input and output................................................................................. 208 Shaping Your Strings.................................................................................... 209 String methods: upcase, downcase, strip........................................ 210 Inserting variables in strings with #................................................. 210 Building a Simple Form-Text Formatter Using Ruby................................ 211 Chapter 14: Wrapping Your Head around Python . . . . . . . . . . . . . . . . 213 What Does Python Do?................................................................................ 213 Defining Python Structure........................................................................... 214 Understanding the Zen of Python..................................................... 215 Styling and spacing............................................................................. 216 Coding Common Python Tasks and Commands...................................... 217 Defining data types and variables.................................................... 217 Computing simple and advanced math........................................... 218 Using strings and special characters............................................... 220 Deciding with conditionals: If, elif, else........................................... 221 Input and output................................................................................. 222 xi xii Coding For Dummies Shaping Your Strings.................................................................................... 223 Dot notation with upper( ), lower( ), capitalize( ), and strip( )...... 224 String formatting with %.................................................................... 224 Building a Simple Tip Calculator Using Python........................................ 225 Part V: The Part of Tens............................................. 227 Chapter 15: Ten Free Resources for Coding and Coders . . . . . . . . . . 229 Learning-to-Code Websites......................................................................... 229 Codecademy........................................................................................ 229 Coursera and Udacity......................................................................... 230 Hackdesign.org.................................................................................... 230 Code.org............................................................................................... 231 Coding-Reference Websites......................................................................... 232 W3Schools........................................................................................... 232 Mozilla Developer Network............................................................... 233 Stack Overflow.................................................................................... 233 Tech News and Community Websites....................................................... 234 TechCrunch......................................................................................... 234 Hacker News........................................................................................ 235 Meetup................................................................................................. 236 Chapter 16: Ten Tips for Novice Coders . . . . . . . . . . . . . . . . . . . . . . . . 237 Pick a Language, Any Language.................................................................. 237 Define a Goal................................................................................................. 238 Break Down Your Goal into Bite-Sized Steps............................................ 238 Distinguish Cupcake from Frosting............................................................ 239 Google Is a Developer’s Best Friend........................................................... 239 Zap Those Bugs............................................................................................ 240 Just Ship It..................................................................................................... 241 Collect Feedback........................................................................................... 242 Iterate on Your Code.................................................................................... 242 Share Your Success and Failure................................................................. 243 Index.........................................................................245 Introduction T he ability to read, write, and understand code has never been more important, useful, or lucrative as it is today. Computer code has forever changed our lives. Some people can’t even make it through the day without interacting with something built with code. Even so, for many people, the world of coding seems complex and inaccessible. Maybe you participated in a tech-related business meeting and did not fully understand the conversation. Perhaps you tried to build a web page for your family and friends, but ran into problems displaying pictures or aligning text. Maybe you’re even intimidated by the unrecognizable words on the covers of books about coding: words such as HTML, CSS, JavaScript, Python, or Ruby. If you’ve previously been in these situations, then Coding For Dummies is for you. This book explains basic concepts so you can participate in technical conversations, and ask the right questions. Don’t worry — in this book I’ve assumed you are starting with little to no previous coding knowledge, and I haven’t tried to cram every possible coding concept into these pages. Additionally, I encourage you here to learn by doing, and by actually creating your own programs. Instead of a website, imagine that you wanted to build a house. You could spend eight years studying to be an architect, or you could start today by learning a little bit about foundations and framing. This book kickstarts your coding journey today. The importance of coding is ever increasing. As author and technologist Douglas Rushkoff famously said, “program or be programmed.” When humans invented languages and then the alphabet, people learned to listen and speak, and then read and write. In our increasingly digital world, it is important to learn not just how to use programs, but how to make them as well. For example, observe this transition in music. For over a century, music labels decided what songs the public could listen to and purchase. In 2005, three coders created YouTube, which allowed anyone to release songs. Today more songs have been uploaded to YouTube than have been released by all the record labels in the last century combined. Accompanying this book are examples at www.codecademy.com, whose exercises are one of the easiest ways to learn how to code without installing or downloading anything. The Codecademy companion site includes examples and exercises from this book, along with projects and examples for additional practice. 2 Coding For Dummies About This Book This book is designed for readers with little to no coding experience, and gives an overview of programming to non-programmers. In plain English, you learn how code is used to create web programs, who makes those programs, and the processes they use. The topics covered include: ✓ Explaining what coding is and answering the common questions related to code. ✓ Building basic websites using the three most common languages: HTML, CSS, and JavaScript. ✓ Surveying other programming languages such as Ruby and Python. ✓ Building an application using everything you learn in the book. As you read this book, keep the following in mind: ✓ The book can be read from beginning to end, but feel free to skip around if you like. If any topic interests you, start there. You can always return to the previous chapter, if necessary. ✓ At some point you will get stuck, and code you write will not work as intended. Do not fear! There are many resources to help you including support forums, others on the Internet, and me! Using Twitter, you can send me a public message at @nikhilgabraham with the hashtag #codingFD. ✓ Code in the book will appear in a monospaced font like this:

Hi there!

. Foolish Assumptions I do not make many assumptions about you, the reader, but I do make a few: I assume you don’t have previous programming experience. To follow along, then, you only need to be able to read, type, and follow directions. I try to explain as many concepts as possible using examples and analogies you already know. I assume you have a computer running the latest version of Google Chrome. The examples in the book have been tested and optimized for the Chrome browser, which is available for free from Google. Even so, the examples may also work in the latest version of Firefox. Using Internet Explorer for the examples in this book, however, is discouraged. I assume you have access to an Internet connection. Some of the examples in the book can be done without an Internet connection, but most require one so you can access and complete the exercises on www.codecademy.com. Introduction Icons Used in This Book Here are the icons used in the book to flag text that should be given extra attention or can be skipped. This icon flags useful information or explains a shortcut to help you understand a concept. This icon explains technical details about the concept being explained. The details might be informative or interesting, but are not essential to your understanding of the concept at this stage. Try not to forget the material marked with this icon. It signals an important concept or process that you should keep in mind. Watch out! This icon flags common mistakes and problems that can be avoided if you heed the warning. Beyond the Book A lot of extra content that you won’t find in this book is available at www. dummies.com. Go online to find the following: ✓ The source code for the examples in this book and a link to the Codecademy exercises: You can find these at www.dummies.com/go/codingfd The source code is organized by chapter. The best way to work with a chapter is to download all the source code for it at one time. ✓ Cheat Sheet: You can find a list of common HTML, CSS, and JavaScript commands, among other useful information, at www.dummies.com/cheatsheet/coding ✓ Extras: Additional articles with extra content are posted for roughly each section of the book. You can access these additional materials at www.dummies.com/extras/coding ✓ Updates: Code and specifications are constantly changing, so the commands and syntax that work today may not work tomorrow. You can find any updates or corrections by visiting www.dummies.com/extras/coding 3 4 Coding For Dummies Where to Go from Here All right, now that all of the administrative stuff is out of the way, it’s time to get started. You can totally do this. Congratulations on taking your first step into the world of coding! Part I Getting Started with Coding Visit www.dummies.com for great For Dummies content online. In this part . . . ✓ Understand what code is and what you can build with it. ✓ Review programming languages used to write code. ✓ Code for the web using front-end and back-end programming languages. ✓ Follow the process programmers use to create code. ✓ Write your first program using code.

Author Nikhil Abraham Isbn 9781118951309 File size 22.1 MB Year 2015 Pages 288 Language English File format PDF Category Programming Book Description: FacebookTwitterGoogle+TumblrDiggMySpaceShare Online exercises developed by Codecademy, a leading online code training site, help hone coding skills and demonstrate results as you practice. The site provides an environment where you can try out tutorials built into the text and see the actual output from your coding. You’ll also gain access to end-of-chapter challenges to apply newly acquired skills to a less-defined assignment. So what are you waiting for? * The current demand for workers with coding and computer science skills far exceeds the supply * Teaches the foundations of web development languages in an easy-to-understand format * Offers unprecedented opportunities to practice basic coding languages * Readers can access online hands-on exercises and end-of-chapter assessments that develop and test their new-found skills If you’re a student looking for an introduction to the basic concepts of coding or a professional looking to add new skills, Coding For Dummies has you covered.     Download (22.1 MB) Learn To Code With Games Starting Out with C++ from Control Structures to Objects, 8th Edition Beginning Programming With Java For Dummies (3rd Edition) Building High Integrity Applications With Spark Android Apps For Absolute Beginners (3rd Edition) Load more posts

Leave a Reply

Your email address will not be published. Required fields are marked *