Teaching: General case first or special cases first?

A common dilemma while teaching (I’m not only talking about teaching in a school or university; talks and workshops are also teaching), is whether it’s better to first teach some easy special cases and then generalize, or first the general case and then present special cases as merely shortcuts.

I’ve been revisiting this dilemma recently, while preparing the slides for my upcoming regular expressions talks. For example: Regex quantifiers.

1. General rule first, shortcuts after

You can use {m,n} to control how many times the preceding group can repeat (m = minimum, n = maximum). If you omit n (like {m,}) it’s implied to be infinity (=”at least m times”, with no upper bound).

  • {m, m} can also be written as {m}
  • {0,1} can also be written as ?
  • {0,} can also be written as *
  • {1,} can also be written as +

Advantages & disadvantages of this approach

  • Harder to understand the general rule, so the student might lose interest before moving on to the shortcuts
  • After understanding the general rule, all the shortcuts are then trivial.
  • If they only remember one thing, it will be the general rule. That’s good.

2. Special cases first, general rule after

  • You can add ? after a group to make it optional (it can appear, but it may also not).
  • If you don’t care about how many times something appears (if at all), you can use *.
  • If you want something to appear at least once, you can use +
  • If you want something to be repeated exactly n times, you can use {n}
  • If you want to set specific upper and lower bounds, you can use {m,n}. Omit the n for no upper bound.

Advantages & disadvantages of this approach

  • Easy to understand the simpler special cases, building up student interest
  • More total effort required, as every shortcut seems like a separate new thing until you get to the general rule
  • Special cases make it easier to understand the general rule when you get to it

What usually happens

In most cases, educators seem to favor the second approach. In the example of regex quantifiers, pretty much every regex book or talk explains the shortcuts first and the general rule afterwards. In other disciplines, such as Mathematics, I think both approaches are used just as often.

What do you think? Which approach do you find easier to understand? Which approach do you usually employ while teaching?

  • +1 for the general rule approach

    i started w/ the general rule and, while i didn’t “grok” other existing expressions i encountered as quickly, i eventually picked up a better understanding and learned very good habits using my “inner REPL” when reading other’s expressions.

  • Disqus screwed up the long comment I wrote, so here’s the gist – I think the second method is preferable. More useful to the audience in a real-world sense, and it makes more sense (to me at least) to have the shortcuts presented then backed up with explanation of the logic & rules.

    Also, I’m having similar trouble with my talk. It’s a tough one!

    • Hey Dan,

      Could you please describe your actions before we screwed up your comment? This site is using Disqus 2012 and we’re still working through some quirks.

      Feel free to just reply here or write to anton@disqus.com. Whichever method is more convenient.


  • Dave

    Ugh, Disqus tried to post my comment for about 5 minutes before I decided to just refresh and repost :-(, here it is:
    I think the General rules should be taught, or at least explained, first, and then once they have the grasp or are wanting to move on, you can show them the shortcuts. Otherwise I tend to find people listen to what the shortcuts are, and then disengage their brains for the general rules and more in-depth part, leading to problems later down the line (mainly due to lack of understanding).

    It kind of relates to the post you did (can’t remember the exact title), but it was about writing a few lines of code apposed to using a library to do it (which would of be 17k lines). I think this relates to that, without understand the general rules, and only knowing the shortcuts, how can we expect people to be more self-reliant instead of referring to these shortcuts all the time? (In relation to regex, this argument I just supplied isn’t that valid, but for other ‘shortcut’ and general rules I think it does apply).

  • “pretty much every regex book or talk explains the shortcuts first and the general rule afterwards”

    Perhaps of interest: In Regular Expressions Cookbook, Jan and I (well, actually Jan wrote this section) explain {n} first, then {n,m}, then {n,}, then +, *, and finally ?. This is similar to your description of “general rule first, shortcuts after”. It also allows for a conceptually simple/intuitive progression of concepts: fixed repetition, variable repetition, infinite repetition, then finally making things optional.

    For that matter, we don’t even get to quantifiers until after a heap of other features that are conventionally described later.

    So yes, I think you’re doing the right thing by questioning everything about how people normally go about explaining regexes. 🙂

    • That’s exactly what I decided to do in my talk! Although I get into quantifiers much earlier (right after literals and the dot metacharacter), as it’s almost impossible to present any kind of practical example without them 🙁

  • Gaelan

    No upside-down question marks! 🙂 But you should put them in spans so we can turn them off with our user agent styles.

  • When i teach the trainee, i usually try to explain general rule first. Because they are general =). And in your examples the first one is far simpler to learn for me. But the question is not as simple in real life. Question “how to teach?” is the most complicated and most interesting in a job of web-developer.
    There are many disciplines that teach special case first, for example is Chemistry and Physics which start to explain general things by explaining small special things.
    There are many subjects in discipline that makes it better to explain by special cases:
    for example in the article of John Resig ( http://ejohn.org/blog/javascript-as-a-first-language/ ) he starting teaching functions declarations by the creating anonymous functions and assigning them to a variable:

    // Don’t do this:
    function getData() { }
    // Do this instead:
    var getData = function() { };

    And this case is good because the method assigning to variable has many advantages,
    (unfortunately the speed is not one of them).

  • Anonymous

    I like to learn the special case first then the general case. Then again, as a physics student that’s how professors (almost) always choose to teach anyway, so I’m used to it. Get to see several cases then when you learn the general case it just clicks, like an “Aha!” moment.

  • That’s also called the inductive and deductive approach, respectively. In my experience, there is no general rule which is better: it depends on your audience. A rough rule of thumb might be that the more formal science education people have gone through, the more they tend to be deductive types, but I know CS graduates that work best inductively.

    So, in the ideal world you provide both (and also keep in mind other learning-type models, such as audio vs visual learners …). That is hard to do so you have to comprimise. You might want to give a small example (and motivation!) first, then the general definition/rule, then more involved examples.

  • Larry Botha

    When I taught mathematics I generally stuck to forming a solid understanding of the general rules. I would then refer to the general case frequently while explaining the special cases, so that there was no mystery as to what was going on. I found the response to an illustrated contrast between the general case and special case good.

    I find that being thrown into the deep end with special cases is frustrating. I get a, “where the hell did this come from?” feeling, followed by, “why wasn’t the basis for the special case explained thoroughly beforehand?” instead of a simple, “ah, that works nicely.”

    I’d expect a ‘special case first’ methodology to result in people having to deconstruct, and rebuild ideas, which is tiring. Starting from nothing, and providing the building blocks from the bottom up worked well for my students.

  • Qwertj

    in this case, i’d prefere the second approach, but generally the first

  • Dan Uhl

    General first, it gives the student confidence and understanding when using the shortcut.

  • Andre Mikulec

    Special case
    The student learns a RULE for a GIVEN SITUATION
    General rule
    The student becomes aware of MANY SITUATIONS. The teacher tells the student a GENERAL RULE to handle MANY situtuations. The student already knows the RULE and now easily knows the GENERAL RULE. The student feels that the learning process is progressive and growth ( expansive-like ) orientated. The student is happy.
    Andre Mikulec

  • I wouldn’t use either approach. I’d start with common regex tasks that students would commonly encounter like finding a web address in a string, validating a form field for an e-mail address, or seeing if a password matches a set of requirements. You could use each of those tasks to demonstrate general regex rules, starting with a task that requires a simple regex and then build up from there. Grounding the instruction in real-world examples, is, in my experience, the best way to teach a complex topic like regex.

  • Mobile application development

    Very useful post I really appreciate it…keep up the good
    work. Thanks!

  • David Rodriguez Souto

    My rule is: teach first whatever is easier to grasp and covers 70% – 80% of the cases in real life :-). Then, if time and interest is still there, you can slowly try to climb up to the 100%.

  • gbert sediarin

    I introduced first the general approached then afterwards, the shortcut which my students makes enjoy in learning math

  • This is a helpful information for those people who wanted to know on which is the best thing that they should teach first in order for them to fulfill their desires in learning.

  • Pingback: angara fahise()

  • Pingback: Daftar Agen Bola Terpercaya()

  • Pingback: opulence for life()

  • Pingback: best online steroid supplier()

  • Pingback: Life Insurance()

  • Pingback: order steroids legally()

  • Pingback: blogspot.com()

  • Pingback: subways surfers()

  • Pingback: unblocked games http:/www.frivgames.top/category/unblockedgames()

  • Pingback: sattamatka()

  • Pingback: letrozol()

  • Pingback: buy npp()

  • Pingback: Verification SMS()