Programming search strategies for novices

Tips and pitfalls

How you search makes a difference in the quality of your results

We all know this from, well, life in the 21st century.

But how can we make it better?

Know your content

Search using the canonical names for what you need to know.

Know your source

Know what kind of document you are searching within. Each will produce a different type of content.

Use natural language over code when possible.

When searching with code, strip out anything local. Example: just search for the function name and take out the variables.

Bookmark sources you know speak to what you need to know.

You will often need to use multiple sources.

Let's break these apart

Know your content

Focus on vocabulary

Every community has a vocabulary

Practice being able to describe code in natural language. Seek feedback.

Try searching with natural language.

Functions and code are used in examples, but discussions will be in natural language.

Search for the minimum

Search just for the function or keyword in question. Take out anything local.

Know what your 'action' is.

Know your sources

Every user manual its user.

Every documentation source speaks to something specific.

Know what you are searching for!

Essential questions to ask about a source:

Is this reference or guidance?

What domain or tool is this written for?

Has this source helped me in the past?

Where is this information coming from?

An example

>>> import random
>>> nums = range(10)
>>> randonums = random.shuffle(nums)
>>> print nums
[0, 8, 2, 7, 4, 1, 6, 5, 9, 3]
>>> print randonums
None

What went wrong?

Semantic errors are hard.

>>> import random
>>> nums = range(10)
>>> randonums = random.shuffle(nums)
>>> print nums
[0, 8, 2, 7, 4, 1, 6, 5, 9, 3]
>>> print randonums
None

Unexpectedly empty.

Unexpectedly changed.

Where is our main action occuring?

Action!


>>> randonums = random.shuffle(nums)

If this is our action sentence, where is our verb?

Yo!

What is our question?

Why did it shuffle nums?

Why is randonums empty?

How does random.shuffle() work?

Which do you think will give us the best search results?

What kind of question is this?

Reference or guidance?

You could make arguments for both, but...

Reference == documentation

Need to find a function in the docs?  Google it.

The solution?

Inside the doc page...

The real solution is deep copying...

but that's for another day.

tl;dl summary

  • When you need to search for something in your code:
  • Identify your action statement
    • Find the verb
    • Search for just the function/verb in question
  • Create your query
    • Take out all local names
    • Use natural language over code
  • Identify appropriate sources to search
    • Start with your bookmarks
    • Do multiple searches as needed

References

Dorn, B., Stankiewicz, A., & Roggi, C. (2013, November).  Lost while Searching: Difficulties in Information Seeking among End-User Programmers.  Paper presented at ASIS&T 2013, Montreal, Canada.

Made with Slides.com