Home > Store

Learning to Program

Register your product to gain access to bonus material or receive a coupon.

Learning to Program

Best Value Purchase

Book + eBook Bundle

  • Your Price: $39.89
  • List Price: $68.98
  • Includes EPUB and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    Adobe Reader PDF The popular standard, used most often with the free Acrobat® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

More Purchase Options

Book

  • Your Price: $27.99
  • List Price: $34.99
  • Usually ships in 24 hours.

eBook

  • Your Price: $27.19
  • List Price: $33.99
  • Includes EPUB and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    Adobe Reader PDF The popular standard, used most often with the free Acrobat® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

About

Features

  • Teaches ideas and techniques that can be used in practically any modern programming language
  • Demystifies program organization, accessing and storing data, controlling program flow, testing, debugging, reusing code, and much more
  • Illustrated with easy, brief hands-on projects for building simple, useful Chrome extensions

Description

  • Copyright 2015
  • Dimensions: 7" x 9"
  • Pages: 336
  • Edition: 1st
  • Book
  • ISBN-10: 0-7897-5339-1
  • ISBN-13: 978-0-7897-5339-7

Everyone can benefit from basic programming skills–and after you start, you just might want to go a whole lot further.

Author Steven Foote taught himself to program, figuring out the best ways to overcome every obstacle. Now a professional web developer, he’ll help you follow in his footsteps. He teaches concepts you can use with any modern programming language, whether you want to program computers, smartphones, tablets, or even robots.

Learning to Program will help you build a solid foundation in programming that can prepare you to achieve just about any programming goal. Whether you want to become a professional software programmer, or you want to learn how to more effectively communicate with programmers, or you are just curious about how programming works, this book is a great first step in helping to get you there.

Learning to Program will help you get started even if you aren’t sure where to begin.

•  Learn how to simplify and automate many programming tasks

•  Handle different types of data in your programs

•  Use regular expressions to find and work with patterns

•  Write programs that can decide what to do, and when to do it

•  Use functions to write clean, well-organized code

•  Create programs others can easily understand and improve

•  Test and debug software to make it reliable

•  Work as part of a programming team

•  Learn the next steps to take to build a lifetime of programming skills

Extras

Related Articles

Browser BASIC (BBASIC): Adding an Easy-to-Use and Portable Language to a Web Page

Gaining Code Confidence Through Testing

Author's Site

Please visit the author's GitHub repository for Learning to Program here

Sample Content

Online Sample Chapter

"Hello, World!" Writing Your First Program

Sample Pages

Download the sample pages (includes Chapter 1 and Index)

Table of Contents

Introduction Why I Wrote This Book 1

    Why You Should Read This Book 3

    Your Project 3

1 “Hello, World!” Writing Your First Program 5

    Choose a Text Editor 5

        Core Features 6

    Making Your Choice 8

        Sublime Text 9

        TextMate 9

        Notepad++ 9

        Gedit 9

        Vim 10

        Eclipse 10

        IntelliJ 11

        Xcode 11

        Visual Studio 11

    Create a Project Directory 12

    Start Small: Create a Test File 12

        How HTML and JavaScript Work Together in a Browser 13

        The Value of Small Changes 15

    Build on Your Success 17

        Reference Your JavaScript in manifest.json 20

        Let It Run! 20

    Great Power, Great Responsibility 21

    Summing Up 21

2 How Software Works 23

    What Is “Software”? 23

    Software Life Cycle 24

    Source Code—Where It All Starts 25

        A Set of Instructions 25

        Programming Languages 26

        From Source Code to 0’s and 1’s 31

        Compiled vs. Interpreted Languages: When Does the Source Code Become Binary? 31

        Runtime Environment 32

        Execution by the Processor 34

    Input and Output 34

        Making Software Useful (and Reusable) with Input 34

        Where Does the Input Come From? 35

        How the Software Gets the Input 36

        Types of Output 36

        GIGO: Garbage In, Garbage Out 37

        State 38

        Add State to Kittenbook 39

    Memory and Variables 41

        Variables 41

        Variable Storage 42

        A Finite Resource 44

        Memory Leaks 44

    Summing Up 45

3 Getting to Know Your Computer 47

    Your Computer Is Stupid 47

    Your Computer Is Magic 48

        Standing on the Shoulders of Giants 48

    Computer Guts 48

        Processor 48

        Short-Term Memory 49

        Long-Term Memory 49

    Using Your Computer 50

        The File System 50

        The Command Line: Take Control 52

    Summing Up 62

4 Build Tools 63

    Automate (Almost) Everything 63

        Install Node 64

        Install Grunt 66

        Software That Helps You Create Software 69

        Avoid Mistakes 70

        Work Faster 70

    Tasks to Automate 70

        Compile 71

        Test 71

        Package 72

        Deploy 72

    Build Your Own Build 72

        Gruntfile.js 73

        Use Grunt Plug-ins 73

        Load Grunt Plug-ins 76

        Register Tasks 76

    Watch This! 78

    Summing Up 80

5 Data (Types), Data (Structures), Data(bases) 83

    Data Types 83

        Why Different Data Types Exist 84

        Primitive Data Types 84

        Composite Data Types 89

        Dynamically and Statically Typed Languages 96

    Data Structures 96

        Set 99

        Stack 99

        Tree 100

        Graph 101

        How to Choose an Effective Data Structure 104

    Databases 104

        Long-Term (Persistent) Storage 104

        Relational Databases 104

        A Brief Introduction to SQL 106

    Summing Up 107

6 Regular Expressions 109

    Ctrl+F on Steroids: Looking for Patterns 109

    Using Regular Expressions in JavaScript 110

    Repetition 111

        ? 111

        + 111

        * 112

        Special Characters and Escaping 112

        {1,10}: Make Your Own Super Powers 113

        Match Anything, Period 113

        Don’t Be Greedy 114

    Understanding Brackets from [A-Za-z] 115

        Lists of Characters 115

        Ranges 115

        Negation 116

    A Pattern for Phone Numbers 116

    I Need My \s 119

        Shortcuts for Brackets 119

        Limitations 121

        Capture the Tag 124

        Advanced Find and Replace 125

        The Beginning and the End (of a Line) 126

    Flags 126

        Global 126

        Ignore Case 126

        Multiline 127

    When Will You Ever Use Regex? 127

        grep 127

        Code Refactoring 127

        Validation 128

        Data Extraction 128

    Summing Up 129

7 if, for, while, and When 131

    Operators 131

        Comparison Operators 131

        Logical Operators 132

        Unary Operators 134

        Binary Operators 134

        Ternary Operators 136

        “Truthy” and “Falsy” 139

        “Syntactic Sugar” 140

        Looping Through an Array 142

        Looping Through Images 142

        Nested Loops 143

        You Need a Break 143

        Infinite Loops 145

        Take Another Break 146

        When You Don’t Know When to Stop 146

    When 147

        Events 147

        Listeners 147

        Cron Jobs 148

        Timeouts 149

        Catch When Things Go Wrong 150

        Writing Robust Code 151

    Summing Up 151

8 Functions and Methods 153

    Function Structure 153

        Definition 154

        Invocation 154

        Arguments 155

        Call Stack 157

    Code Encapsulation 158

        Do One Thing Well 158

        Divide and Conquer 159

        A Place for Everything and Everything in Its Place 162

    Code Reuse 163

        Solve the General Problem 163

        Do More with Less 163

        Don’t Repeat Yourself (DRY) 165

    Scope 166

        Global 167

        Local 168

        How Variable Lookups Happen 168

    Summing Up 171

9 Programming Standards 173

    Coding Conventions 173

        Setting Standards 174

        To Hack or Not to Hack 174

        Pay Now or Pay Later 175

        Writing Maintainable Code 175

    Code Formatting 176

        Keep It Consistent 177

        Whitespace 178

    It Doesn’t Happen on Its Own: Make Rules 178

    Using the Work of Others 180

        Build Faster 180

        Open Source Software 181

        Built by the Community 181

        When to Build It Yourself 182

    Best Practices 182

        Documentation 182

        Planning 183

        Testing 183

    Summing Up 183

10 Documentation 185

    Document Intentions 186

        Self-Documenting Code 187

        Don’t Document the Obvious 189

        The Danger of Outdated Documentation 190

        Find Bugs Using Documentation 191

    Document for Yourself 191

        How Good Is Your Memory? 191

        Document to Learn 192

        Documentation Beyond Comments 192

    Document for Others 196

        Document Your Decisions 196

        Document Your Resources 197

        Document to Teach 197

    Summing Up 198

11 Planning 199

    Think Before You Build 199

    Create a Specification 200

    Design an Architecture 200

        Draw Diagrams 201

        Try to Break Your System 202

    Iterative Planning 203

    Design for Extensibility 203

    What Are Your Priorities? 204

        User Experience 204

        Performance 204

        Security 205

        Scalability 205

        Deadlines 205

    The Balancing Act 206

        Identify and Create Constraints 206

        Know What You Can and Can’t Do 206

    Summing Up 207

12 Testing and Debugging 209

    Manual Testing 209

        Test As You Work 210

        Try Something Crazy 210

        Eat Your Own Dog Food 211

    Automated Testing 211

        Unit Tests 212

        Set Up Tests for Kittenbook 215

        Epic Fail! 218

        Spies Like Us (and We Like Spies) 219

    Integration Tests 221

        Catch Problems Early 222

    Debugging 222

        Errors 223

        Logs 224

        Breakpoints 224

        Inspecting, Watching, and the Console 228

        Stepping Through the Code 229

        Call Stack 231

        Find the Root Cause 231

        Code, Test, Debug, Repeat 232

    Summing Up 232

13 Learning to Fish: How to Acquire a Lifetime of Programming Knowledge 233

    How to Search 234

        Finding the Right Terms 235

        Working Backward 236

        Identifying Quality Resources 236

        Personal Blogs: Hidden Gems 237

    Where, When, and How to Ask Programming Questions 237

        Where 237

        When 240

        How 241

        Learn by Teaching 241

    Summing Up 242

14 Building Your Skills 243

    Make kittenbook Your Own 243

        Restyle Facebook 243

        Add New Functionality 244

        Share Your Version of Kittenbook 245

    Find Your Own Project 246

        Solve Your Own Problem 246

        Be Ambitious 246

        Get Help, Give Help 247

    Open Source Projects 247

        GitHub 247

        Finding a Project 248

        Different Ways to Contribute 248

        Create Your Own 249

    Free Online Education 249

        Project Euler 249

        Udacity 250

        Coursera 250

        codecademy 251

        Khan Academy 251

        Tutorials 251

    Paid Education 252

        Read a Book 252

        Udacity and Coursera 252

        Treehouse 253

    Summing Up 253

15 Advanced Topics 255

    Version Control 255

        Why Use Version Control? 256

        Working with a Team 257

        Subversion 260

        Git 260

    OOP (Object-Oriented Programming) 265

        Classes 266

        Inheritance 266

        Instances 267

    Design Patterns 268

        Pub Sub 268

        Mediator 269

        Singleton 270

    Summing Up 270

Glossary 273

TOC, 9780789753397, 10/13/2014

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020