Skip to content

mconbere/baseball-design

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

The Baseball Design Pattern

C++ is known as an expansive, difficult language with many corner cases that trip up beginners and experts alike. The Baseball Design Pattern is a method of reducing the scope of the language, making it easier to learn and reason about.

There is one rule

  1. You may not return. You may only catch and throw.

Praise given to The Baseball Design Pattern

It causes immediate reations:

My eyes... the burning...

It provokes emotions:

Aaaaaah noooo

It is found to be useful:

This approach would be useful when the problem was that your code was running too fast.

It is challenging:

I dare you to use it in a coding interview

Try The Baseball Design Pattern today! Remember, you may only catch and throw.

Examples

Factorial

void factorial(int n, int accum = 1) {
  if (n == 0) throw accum;
  factorial(n - 1, n * accum);
}

More Examples

A full working example can be found in the src/ directory.

About

You may only catch and throw.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published