Giter Club home page Giter Club logo

phase-0-pac-3-intro's Introduction

Programming as Conversation Part 3: Introduction

Learning Goals

  • Revisit abstraction

Introduction

Before we jump into more code, let's think for a moment about something you encounter pretty much every day when you read a news article or email: the way we organize words to express and clarify meaning. For example, a paragraph is a collection of sentences, introduced by a topic sentence and bundled up or closed by a closing sentence. A paragraph can persuade or offend, direct or explain. A paragraph has a function.

"Code paragraphs" are called, depending on language, "functions," "procedures," "methods," or "subroutines." They bundle up expressions and statements to accomplish a task. Just as "Make a Sandwich" encompasses specific, "atomic" actions like "get slice of bread," "get jelly," etc., executeTransfer encompasses logic like if (accountStatus === "open") or if (accountBalance >= transactionAmount).

To have code that is easy to read, debug, and maintain, we need to bundle collections of atomic activities into "code paragraphs" that do work. JavaScript calls these "functions."

Abstraction

This process of bundling up small atoms into a function is called "abstraction." "Abstraction" comes from the Latin word for "to pull away." When we're further away, many details are hard to see. Only the most relevant shapes are recognizable. For example, when you're on an airplane overlooking a city, the details of the cars below โ€” the mileage, what's in the cup holder, the make or model โ€” are invisible; they're not essential. But what we may be able to see is the vehicle type (car vs. truck) or the color of the car. By abstracting we see what's true at a higher level, or more generally.

Here are a few more "abstractions:"

  • Jerry Seinfeld, Ruth Bader Ginsburg, and Cardi B are atomic individuals, but we can refer to them all collectively by the abstraction (or they can be abstracted into) "famous New Yorkers"
  • Books about a killer dog, a scary alter ego, and a scary clown can be abstracted into the name "horror novels (by Stephen King)"
  • Individuals with strange powers and (usually) strange clothing can be abstracted into "superheroes"

Abstraction is a natural part of learning to converse. When you're first learning to communicate, you don't know enough to start talking about abstractions. You prefer to think about real, visible, tangible things. But as you learn about opposites, how things are similar (and how perhaps one thing is dissimilar) you grow in your ability to abstract.

In fact, the thing that makes most higher learning "higher" is that the discussion, work, and discovery is focused on uncovering general principles that allow us to predict how things will work more-or-less most of the time. Amazingly, this was considered a pretty revolutionary idea at the time when Galileo and Newton started doing it. The moment that natural philosophers started looking for these "general rules of how things work," science as we know it was born.

Next Steps

In Programming as Conversation 3, we'll learn to take our JavaScript expressions and statements and bundle them up into abstractions called functions. Before we get to that, however, we first need to learn a little about testing in JavaScript.

phase-0-pac-3-intro's People

Contributors

alveem avatar bal360 avatar jenmyers avatar jlboba avatar lizbur10 avatar maxwellbenton avatar sgharms avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.