11/8/14

Getting Acquainted With Classes

I spent the last couple of hours writing a Book class with methods that assign a title, find the most common words, break up pages, replace all instances of a word with another, etc. Ran into some issues with runtime since the input (a whole book) was rather large. Eventually improved runtime from n^2 to nlog(n), which made a big difference.

I’m really starting to see the value that classes bring. I’d never used them with C or Scheme, and only a very limited amount with Javascript - so maybe now I can start to reap their benefits.

Lessons Learned:
  1. Uses for class variables
  2. The basics of Regular Expressions
  3. Using Procs to avoid recalculations

See link to github file here.

No comments:

Post a Comment