Learning to Learn

Spot the problem

Exception in thread "main" java.lang.IndexOutOfBoundsException: 3
        at scala.collection.LinearSeqOps.apply(LinearSeq.scala:117)
        at scala.collection.LinearSeqOps.apply$(LinearSeq.scala:114)
        at scala.collection.immutable.List.apply(List.scala:79)
        at index.App$.lastUserId(App.scala:6)
  def lastUserId(userIds: List[Int]): Int = 
    userIds(userIds.length)

 The collection of user ids is described by the Scala List. This is zero-indexed, so the last user id is found at index N - 1 where N is the length of the list. When an index greater than this number is used, an exception is raised and the program exits.

We're going to think about

  • How to think about problems you've seen
  • How to think about problems you haven't
  • How to learn to solve them
  • How to learn effectively

Abstraction

 The collection of user ids is described by the Scala List. This is zero-indexed, so the last user id is found at index N - 1 where N is the length of the list. When an index greater than this number is used, an exception is raised and the program exits.

Notice we don't mention solid state physics

Concept Map

Notional Machine

     The computer:

  • Finds the length of the list of user ids
  • Gets the user id at the length index
  • Throws an exception
  • Skips the rest of the program

 

  def lastUserId(userIds: List[Int]): Int = 
    userIds(userIds.length)

An abstraction of abstraction

The Problem

Exception in thread "main" java.lang.NoClassDefFoundError: 
  scalacache/CacheConfig$
        at utils.UserIds$.cache(UserIds.scala:12)
        at index.App$.index(App.scala:15)
        at index.index.main(App.scala:13)
Caused by: java.lang.ClassNotFoundException: 
  scalacache.CacheConfig$
        at java.base/jdk.internal.loader...
import utils.UserIds
...
val cache = UserIds.cache[IO]
 

The worst that can happen...

  • It takes several days to resolve the problem.
  • You find something that works, but don't really understand why.
  • Several months later, you see another NoClassDefFoundError.
  • You can't remember how you resolved it before.

Exercise

  • Write your own explanation
  • Draw a concept map to help
    • Use the terms "Scala", "SBT" and "scalacache"

  Scala compiled the program, but fails to run it. Perhaps our Scala compiler didn't compile scalacache properly?

SBT threw an error when running the program. This is a problem with out SBT configuration.
The error originates in scalacache. There's a bug in scalacache, or in the way we're using it.

Explanations

A mental model...

  • is always incomplete
  • may be incorrect
  • is usually good enough

Refining a mental model

  • Draw it on paper
  • Explain it to someone else
  • Cross reference it
    • Read the docs
    • Ask someone more experienced
  • Experiment
  • Review and redraw

Metacognition

Think about your thinking

  • As you solved the problem, what do you spend your day doing?
  • Did your mental model change?
  • Draw concept maps as you go

Review

  • The importance of abstraction
  • Mental models and concept maps
  • How to refine a mental model

Thank you!

Learning to Learn

By Zainab Ali

Learning to Learn

  • 970