Introduction to Programming Concepts via jQuery

Learning more after today

Want to learn more code after today? Yay! Here are the two things that people tell me, over and over, are the most important things:

  • Projects. If you're trying to do a real thing you care about, you'll be more motivated to stick with it, and you'll have more fun. It doesn't matter if it's a work project or a personal one, or something you build from scratch vs. something you modify — it just needs to be a real thing. Need ideas? I wrote a whole Library Technology Report about short programs librarians have written to get real-world things done.
  • Mentors. It's good to have people who can answer questions if you get stuck, or show you better ways of doing things that you didn't know existed.

In terms of specific learning resources, you know your own learning style, so you know what's likely to work for you. But here's my take on some widely available options:

  • This course! You can come back to this site for review whenever. There's also a link to the source code for this site at the bottom of every page, so you can read the exact code I wrote to make all the effects happen.
  • Local user groups vary in how newbie-friendly you are, but if you have a good one, they can be very helpful. Check to see if there's a group near you for a language (Python, Ruby, Javascript, etc.) or project (e.g. Drupal) you want to learn. My local Python group has a beginners' table at project nights. Some Python and Ruby groups have women-oriented groups which can be very friendly (they generally expect either that you are a woman, or that you sign up with a female friend).
  • O'Reilly books. O'Reilly books are the sine qua non of tech publishing, and your library may already have a Safari subscription, giving you access to their whole ebook library. Look for books in the language of your choice that are geared toward beginners (if you're just getting started) or that have "cookbook" in their title (if you need code samples you can adapt for your projects). Good options if self-directed learning works for you.
  • MOOCs. A popular option, but one I'm skeptical of; course completion rates are low, and there can be big jumps in difficulty and cryptic feedback. The basic content you need is there (and there's at least one library-specific module on Codecademy), but the MOOC route works best if you have a close friend who can answer lots of questions, or if you sign up together with a whole study group.
  • Formal classes. A good option for a lot of people, though maybe only workable if you can get some time at work to do your homework (and maybe some funding to cover tuition). Better support than MOOCs. Often fairly abstract, though, and not specific to library use cases; they'll give you foundations you can apply to lots of things, and make it much easier to self-teach later, but you may be on your own for building the bridge between the class and your real-world applications.

In terms of programming language choice — honestly this should not be your major question. Languages all involve the same core concepts; if you solidly master one, a second will be dramatically easier to learn. People definitely have languages that play more or less to their personal tastes, but for the most part any language is fine. Your choice of where to start should be dictated by the projects you see yourself working on. For instance...

If you want to do text mining, MARC batch processing, or data cleanup, Python is a good choice.

If you're a web design geek, more jQuery and Javascript will be relevant.

Hacking on WordPress and Drupal? Do PHP.

Using, or contributing to, library open source projects like Hydra, Blacklight, Koha, or Evergreen? Do their language.

More practice

Didn't quite get hang of things, and need time to catch up? Think you got it, but want more practice so it sticks? Loved the exercises and want some additional challenge? These are all great, and you're in the right place.

Start at whichever step looks like the right place for you, and feel free to move around the room to sit with other people working on the same steps.

You probably won't finish everything on this page, and that's fine. If I wrote so few that you run out, I messed up ☺.

Step 1: catch up/review

Start here if you didn't get through all the exercises in the previous pages, or if there were some that you don't feel confident about.

  • Finish any exercises from previous sections that you didn't finish.
  • If there were any you finished but didn't understand, get help!

The rest of the exercises on this page will build on those earlier ones, so you'll be happiest if you make sure you have a solid grasp on them.

Step 2: extend the examples

One great way to expand your programming skills is to take something you've already written and make it just a little bit better. What does "better" mean? Could be lots of things! For example:

  • Easier to read (clearer variable and function names; explanatory comments; simpler logic, if possible)
  • Able to handle more edge cases
  • Better at responding to errors
  • More general: able to handle a wider variety of inputs and situations

So, let's extend some work you've already done. Here are some ideas.

From the functions page:

  • Write a function that makes #trigger-1 change the buttons to purple if they're yellow, and then change back to yellow if they're purple. (You can do this with the functions you've already encountered; you might also try writing it with toggleClass(). Check out the jQuery documentation (linked from the bottom of the page) for details.
  • Write a function that makes #trigger-1 change every other button purple. This is the kind of logic that comes up a lot in web development (e.g. where you might want to color every other line of a table). A few things you will need to know for this:
    • You'll need to define a counter variable which you set equal to 0, and then add one to it every time through the loop. (This counter variable idiom is super common in programming, too.)
    • Assuming your counter variable is named counter, then counter % 2 will return 0 if counter is even and 1 if counter is odd. (For those of you who like math: % is the modulus operator, so x % y is x mod y. If you don't like math, don't worry; you don't need to understand this parenthesis for your program to work.)

From the loops page:

  • (not yet written. sadface!)

From the conditionals page:

  • Handle ISBNs a bit better. Don't just flag things missing an "ISBN:"; also flag things that have an ISBN that can't be valid. There are a lot of rules governing ISBN validity (and if you want to really do this right you'll need to learn regular expressions), but one quick-and-dirty rule for now is that ISBN-13s start with 978 or 979.

Step 3: make new stuff!

Here are some new challenges that build on what you've seen before. These problems don't have one right answer, and that's fine! Remember, it's generally easiest to build the smallest thing you can get working first, and expand from there. You'll also be happiest if you write your code in a text editor and copy-paste it into your browser for testing.

  • Below, there's a longer, dirtier set of book data than what we've seen before. Write a program to flag problematic records. (What does "problematic" mean? Read the data and decide for yourself. In the real world, you'd probably have a much larger data set and you'd read a sample of it.)
  • Make my public library's catalog look better. Those <strong> elements serving as headers - wouldn't they be nicer with a different font and a larger font-size? That navigation bar with the languages - can we increased the contrast between the text and the background color for better accessibility? What do you think would help? Some things to know here:
    • Because you can't write a new stylesheet and add it into the page source, you'll need to use jQuery's .css() function to change how elements are styled rather than adding and removing classes.
    • You will have to read the HTML source of the document, or use your developer tools, to figure out which selectors to bind your functions to.
    • This challenge is particularly well-suited to teams whose members have complementary skillsets. If you have one person who's strong in jQuery, another who's good with HTML and CSS, and another with excellent design sense, you can do killer work. (Most real-world tech projects of any size are team projects, in part for this reason.)
    • You can use this technique to make your own catalog look better, even if you can't alter its HTML, as long as you can insert some javascript (and ideally a link to an additional stylesheet) somewhere on the page. Here's a real-world example.
  • Heck — make your catalog look better.


Author: Marcus Sakey; Title: Brilliance; ISBN: 9781611099690

Author: Julia Serano; Title: Whipping Girl: A Transsexual Woman on Sexism and the Scapegoating of Femininity

Author: Alfred Lubrano; Title: Limbo: Blue-Collar Roots, White-Collar Dreams; ISBN: 34870005769746

Author: Alice Goffman; Title: On the Run: Fugitive Life in an American City; ISBN: 9780226136714

Authors: Matthew S. Rotundo, Kam Oi Lee; John P.Murphy; Title: Alembical 3; ISBN 978-0-9887587-5-9

Editors: Andy Oram & Greg Wilson; Title: Beautiful Code; ISBN: 9780226136714

Author: Chimimanda Ngozi Adichie; Title: Americanah; ISBN: 9770307397911

Author: Robert B. Parker; Title: The Widening Gyre; ISBN: 0440195357

Author: Cherie Priest; Title: Boneshaker; ISBN: 978076531841

Author: Alexis de Tocqueville; Title: Democracy in America; ISBN: 0226805328

Author: Jane Jacobs; Title: The Death and Life of Great American Cities; ISBN: 0375508732

Author: Michael Pollan; Title: The Botany of Desire; ISBN: 0375501290

Author: Sudhir ALladi Venkatesh; Title: Off the Books; ISBN: 978-0-674-02355-0

Author: Henry Hazlitt; Title: Economics in One Lesson; ISBN: 05175482322

Author: Naomi Kritzer; Title: Freedom's Sisters; ISBN: 978055356756

Author: Apostolos Doxiasis and Christos H. Papadimitriou; Title: Logicomix; ISBN: 978159914520

Author: Rainbows End; Title: Vernor Vinge; ISBN: 9780812536362

previous next