Goal: Focus on breaking your project down into small behavior examples and coding one behavior (also known as a "specification" or "spec") at a time. Make a list of specifications with input and output examples before writing any code. Also, as our projects grow in size, continue to practice good organization by keeping business logic and user interface logic distinctly separate.
Pretend you have an application that counts the number of vowels in a string. This application has specs detailing each behavior it must exhibit. However, they're out of order! Reorder the following list of specs from the simplest possible behavior to the most complex behavior with your partner. Consult with other pairs, if necessary:
Follow along with the leap year lessons to build an application that identifies whether a given year is a leap year. Make each of the specs detailed in the leap year lessons "pass" (ie: your program returns the expected output for the expected input).
All specs should be listed in the project's README.md file.
Write a Pig Latin translator or should we say an "igPay atinLay anslatorTray"? Read all instructions carefully before beginning.
First, here are the rules of Pig Latin:
For words beginning with a vowel, add "way" to the end.
For words beginning with one or more consonants, move all of the first consecutive consonants to the end, and add "ay".
If the first consonants include "qu", move the "u" along with the "q". Don't forget about words like "squeal" where "qu" doesn't come first!
For words beginning with "y", treat "y" as a consonant.
Before writing any code, make a list of specs detailing each behavior your program will have. Start with the simplest possible behavior, and slowly move up in complexity. To get you started, the first two specs are provided below.
Have at least two other pairs check your specs before you begin coding. Ensure that each possible behavior is represented by a spec, and that they are ordered from simplest to most complex.
Place your specs (and their example inputs and outputs) in your project's README.
Create a basic user interface that allows your application to accept user input, and display output. This will allow us to manually test each spec.
Slowly add business logic. Begin by focusing on the behavior outlined in your first, most simple spec. Implement the least amount of logic necessary to create this behavior.
Manually test this behaviour by inputting the example input described by the spec into your application, and confirm you receive the correct output.
Once behavior outlined by the first spec is successfully implemented, repeat steps 5 - 7 for each subsequent spec. Do not move onto the next spec until the previous one passes.
When you get to consonants, don't try to solve it all at once. Instead, start with an example of a word that only has one consonant; then a word with two consonants; then a word with three; and then tackle the exceptions to the rule, like "qu" and "y". Once your application can successfully translate single words, work on translating entire sentences.
Although you're welcome to solve the problem however you'd like, there are a few methods that would be handy:
Take a look at this and other documentation to gather the tools you'll need before you try to fulfill your specs.
To get you started, below are the first two "plain English" specs:
Binary: Write a method to convert numbers from binary to decimal. The input should be a string, and the output an integer. Decimal is the normal system we use for counting. We start at 0, increment until we reach 9, and then reset back to 0 and add another number to the left. In binary, we also start at zero, but we only increment until we reach 1. Then we reset back to zero and add another number to the left.
Here are some example of numbers in decimal and binary:
Decimal Binary 0 0 1 1 2 10 3 11 4 100 ... ...
Trinary: You get where I'm going, right?
Hexadecimal: Here's what happens after 9...
Decimal Hexadecimal ... ... 9 9 10 a 11 b 12 c 13 d 14 e 15 f 16 10 17 11 ... ...
If you get this far, write a method that takes two arguments: the number to be evaluated and the base you would like it to be evaluated in.