Archive for the 'Uncategorized' Category



Regex Quantifiers Algebra

Regular expressions or parts of a regular expression can be repeated. I specify the number of repetitions with a type of operator called quantifiers. A quantifier has two attributes:

  1. A lower limit for the number of repetitions is represented by a natural number (i.e. a non-negative integer)
  2. An upper limit for the number of repetitions is represented either by a natural number or the empty string. The latter means unlimited.

I write the quantifiers inside a pair of braces, with a comma between the lower and upper limit, for example:

  • Zero or one repetition: {0,1}
  • One, two or three repetitions: {1,3}
  • Fourteen or fifteen repetitions: {14,15}
  • Two or more repetitions: {2,}

The quantifier {1,1} is an identity operator:

  • a{1,1} equals a

Quantifiers are unary, left associative, and has high precedence. Concatenation as well as Alternation have lower precedence. That gives the following rules:

  • Concatination: ab{1,2} equals a(b{1,2})
  • Concatination: a{1,2}b equals (a{1,2})b
  • Alternation: a|b{1,2} equals a|(b{1,2})
  • Alternation: a{1,2}|b equals (a{1,2})|b

I’ve got a lot of syntactic sugar in my regular expression jar. A single natural number in a quantifier represents both the lower and upper limit:

  • {3} equals {3,3}

I may write Kleene closure — zero or more repetitions — as an asterisk without braces:

  • a* equals a{0,}

I may write Positive closure — one or more repetitions — as a plus sign without braces:

  • a+ equals a{1,}

I may write the Optional operation — zero or one repetition — as a question mark without braces:

  • a? equals a{0,1}

More algebra:

  • (a*)* equals a*
  • (a+)+ equals a+
  • (a?)? equals a?
  • (a*)+ equals (a+)* equals a*
  • (a*)? equals (a?)* equals a*
  • (a+)? equals (a?)+ equals a*
  • Kleene closure is Positive closure or nothing: a* equals (a+|)
  • Optional a is a or nothing: a? equals (a|)? equals (a|)
  • Kleene closure of a or nothing is Kleene closure of a: (a|)* equals a*
  • Positive closure of a is a concatenated with Kleene closure of a: a+ equals aa*

Pomodoro Technique Illustrated -- New book from The Pragmatic Programmers, LLC

Advertisements

Samurai and Rock Star

To be invited to speak at conferences around the world has many advantages. One is that you meet other authors. Ed Burns and Jonathan Rasmusson are two of them.

I Agile Smuraimet Jonathan Rasmusson in Chicago last summer at Agile2009. He was then struggling with his upcoming book. I asked curiously when he expected the book to be released. Hopefully within a few months, he answered. A few months happened to be almost a year, but now it’s released. The title is “The Agile Samurai — How Agile Masters Deliver Great Software” which describes exactly what it is. There are many Agile books out there, but this one is different. Firstly, even though it’s published by Pragmatic Bookshelf it has a style similar to O’Reilly’s Head First series . Pictures and text are mixed in a way that make learning easy. Secondly, this is more of an in-his-own-words book than the usual Agile book. The book describes Agile ideas instead of defining the Scrum terminology. If you’re interested in Agile, on whatever level, you should read this book.

Last Rock Star Programmersmonth I met Ed Burns in Poland at the GeeCON2010 Java conference. He recently released a new version of his JSF book. But, what caught my attention was another book from 2008. During one of his sessions at GeeCON he replayed interviews with people like Rod Johnson, James Gosling and Andy Hunt. Those interviews were originally recorded for the book “Riding the Crest — Secrets of the Rockstar Programmers.” It’s a book were thought leaders from our own industry shares what they think about entrepreneurs, what makes them productive and how their career affected their private life? The answers go in all directions.

Pomodoro Technique Illustrated -- New book from The Pragmatic Programmers, LLC

The Reptile Within Us

Dinosaur brain manager with tie

Dinosaur brain manager with tie?

You have struggled the whole weekend to get a report done. On Monday morning your boss throws a quick glance at the result and says, “It’s not good enough, you have to start over from scratch.” You know he is wrong and your instincts tell you to immediately explain yourself. Then your boss will probably understand you and even commend your work. Or maybe not?

In 1989 Dr.Albert Bernstein published the book Dinosaur Brains: Dealing with All Those Impossible People at Work. With dinosaur brain as a metaphor for a whole range of our instinctive reactions, Bernstein teaches us how we can manage our employees and fellow workers. He enumerates the rules of the Lizard Logic:

  • FIGHT, FLIGHT OR Fright – When the dinosaur feels attacked, then he either fights back, runs away or becomes paralyzed with fear. Don’t be fooled when it looks as if he explains something – he’s actually attacking or running away.
  • GET IT NOW – The dinosaur never makes a plan. His actions happen automatically and immediately. The most exciting thing to do replaces the most important one. You recognize it when he talks about competitions and defeating others.
  • BE DOMINANT – To the dinosaur, any social contact is a part of a contest. The winner will be at the top of the hierarchy and is allowed to mock those who are further down. That’s why he so often speaks about the rules for the people at the top.
  • DEFENDER THE TERRITORY – Sharing is a sign of weakness. The dinosaur indicates that it is his office, his project and his paperclip. It doesn’t matter if it’s something important or trivial – he will always defend his personal interests.
  • IF IT HURTS, HISS – Whoever holds the Old Maid at the end of the game is the loser. Slightest indication that something may go wrong causes the dinosaur to throw accusations at people. It solves no problems, but the dinosaur’s goal is to get someone singled out as guilty of this problem.
  • LIKE ME GOOD, NOT LIKE ME BAD – His ultimate dichotomy is us-against-them. Those who are on the dinosaur’s side are good and everyone else is evil. He expresses this often and in emotional sermons.

Yes, we have inherited the part of the brain called the brain stem from the ancestors of today’s reptiles. But our brains have evolved since then. Layers have been added that make the human brain unique. The most sophisticated of the new parts is the frontal lobe. With it we can work together, imagine, plan and even change our mind. To do that we need to stop and think, instead of immediately follow our instincts.

Exercise:

  1. Which seven people do you meet most often at work? Write their names below; one name above each circle. Inside the circle, draw a stick man with the right hairstyle, beard, device or something else indicative of each of the seven work mates.
  2. Do this step rather quickly: rank the seven persons. Who do you imagine feels most comfortable in your company? Write ‘1’ next to the circle. Write ‘2 ‘next to the second best. Continue until all seven are ranked.
  3. In Step 2 you used your reptilian brain. Now you must use your creative brain instead. What would you be able to—individually—help these people with? Start with the lowest ranked, i.e. number seven. What knowledge or proficiency do you have, that this person would benefit from? You may have some information that would help her with her duties? Maybe you’re an expert on a tool that she uses? Write one thing that you can share below each circle.
Exercise

Exercise

Daily noon nap improves your performance

It is possible to reduce the daily need for sleep with several hours. Research shows that the body then retains the same amount of non REM sleep, and instead cut down on REM sleep. The outcome is that the muscles get their rest, but the brain doesn’t get time to sort. The important post-learn-work will not happen. Things you thought were important are soon forgotten.

Sara Mednick of the University of California, San Diego, says that we would even benefit from taking an extra nap in the middle of the day: “Imagine a product that increases alertness, boosts creativity, reduces stress, improves perception, stamina, motor skills, and accuracy, enhances your sex life, helps you make better decisions, keeps you looking younger, aids in weight loss, reduces the risk of heart attack, elevates your mood, and strengthens memory. Now imagine that this product is nontoxic, has no dangerous side effects, and, best of all, is absolutely free. This miracle drug is, in fact, nothing more than the ‘nap’: the right nap at the right time.”

Matthew Walker of the University of California, Berkeley describes how memories are transferred from the hippocampus to the cortex. In a research project, he trained two groups of people in memory exercises. One group took a nap at noon. And they improved their performance in the afternoon. The second group had worse results.