Tuesday, June 28, 2011

Developing software is a lot like solving a Rubik's Cube. I know that software --> Rubik's Cube analogies are overused, but allow me to make my case:


Ripley Rubik is a customer who approaches your company, Cubits Solutions, and explains he has a problem. His company, Rubik's Polychromatic Six-Sided Wooden Enjoyment Cubes, uses a wooden block as part of their manufacturing process. Each side of the block is comprised of 6 colors: green, red, yellow, blue, white, and orange; with one side having a seemingly random mix of all 6 colors. He explains to you that his employees currently have to search all over the block to find all the blue parts, then all the red parts, and so forth until all parts of each color have been found. The problem is, this takes a lot of time and employees, and he's looking for a way to speed up the manufacturing process and cut down on costs. You think you can help Ripley out, so you schedule a meeting with your chief architect, lead developer, interface designer, and project manager.

During the meeting, everyone decides that having more of the colors grouped together would definitely speed up the process. Since a cube has 6 sides and there are 6 colors, it's decided that having no more than 3 colors on each side would significantly reduce the time spent searching for all the colors. Ingrid, the interface designer, creates some drawings based on this, and you show them to Ripley.

Ripley immediately rejects this idea and tells you that, while he likes the idea of grouping together the colors, your design won't work because the center portion of each side can only be one color, and each side has to have a different color at the center. You return to the drawing board, and the team comes up with a new design: each side would have a single color at the center, and the 4 corners of a side would also be the same color as the center.

Ripley likes this idea, but he's concerned that it will still take too much time to search for all the colors. Ingrid suggests that there could be only one color per side, and everyone loves the idea. She creates another set of mockups and shows them to Ripley. Unfortunately, Ripley says this won't work because the layout is all wrong - his process requires that white be on the front of the cube, with red on the left side, orange on the right side, green on the top, blue on the bottom, and yellow on the back. You suggest that, instead of a cube, you create a suite of squares, one of each color, so that Ripley could orient them however he likes. He rejects this idea because he knows his budget would never allow for the maintenance of six separate tools, and he'd really prefer a single cube so that a single employee could use it if necessary.

With these new requirements in mind, the team goes to work on writing a requirements specification. Ripley signs off on the design, which says something to the effect of "The product must be a wooden block with six sides (a cube). Six colors must be represented on the cube: green, red, yellow, blue, white, and orange. There can only be one color per side, and each side must be a different color. The colors must be oriented as follows: white on the front-facing side, red on the side to the left of white, orange on the side to the right of white, green on the topmost side (above white), blue on the bottommost side (below white), and yellow on the rear side (opposite of white)."

Now that the requirements have been specified, Archie, your chief architect, goes to work on the technical design. His first suggestion is to build a new layer on top of the current design (the random assortment of colors) - he could paint a solid color onto each side rather than build the entire project from scratch. However, Lenny, the lead developer, points out that this solution would end up leading to more problems down the road because the underlying colors could still cause problems if they bleed through to the top layer. Percival, the project manager, agrees this could be a problem, and he also asks Ripley if his budget allows for a complete rebuild, or if he'd rather they adapt his current wooden block.

Ripley decides it would be too costly to build an entirely new block, so the team will have to build upon the current design. Since the requirements have changed again, Percival amends the requirements specification to read "The product must build upon Rubik's Polychromatic Six-Sided Wooden Enjoyment Cubes' current wooden block."

Archie goes back to work on the architecture, and comes up with a plan to divide the cube into smaller squares. Each square would contain a single color, and these squares could then be moved around to their proper side. In order to facilitate the movement of the squares, he comes up with a system based around a central core, where each square would be able to pivot around on screws and springs. He first divides each side of the cube into 5x5x5 squares, but decides this is too complex and reduces it to 3x3x3.

Lenny likes this idea, but he's concerned that the wood will be very difficult to affix screws and springs to (in addition to being difficult to maintain later down the road), and suggests they look into a new technology called plastic. Percival brings this idea to Ripley, who decides that the initial cost of remaking his cube out of plastic is indeed worth saving maintenance costs later on. Percival amends the requirements again to replace all instances of "wooden" with "plastic", and Cubits Solutions hires a new developer who's an expert in plastics.

Lenny and Archie design a system of rotations to put the blocks into place. They come up with some algorithms for moving the squares around, and decide that they will only rotate one side at a time. They decide to call the sides L, R, U, D, F, and B, for left, right, up, down, front, and back, respectively. They create a new framework called Solve which specifies individual operations which can be performed on a section of squares: CW and CCW, for clockwise and counter-clockwise rotations. In order to perform an operation, a developer would write "LCW" to indicate that the left side should be rotated clockwise.

With the new cube fully designed and planned out, development can begin. Percival plans out a workflow for the developers, and it's decided that 6 developers will each work on an individual color/side. With the guidance of Lenny and Archie, he decides that each developer will first align the corners of their side, and then move on to the other squares. Developers will spend the day writing down the steps needed to align their colors (FCCW, UCW, RCW, etc), and at the start of the next day, they'll take turns rotating parts of the cube and spend the rest of the day writing down new instructions. The developers write down the first day's instructions and then go home.

At the start of the second day, Bluto, the developer assigned to blue, performs all of his rotations and aligns the corners. However, once Rory, the developer for red, performs his first rotation, it's immediately clear there's a problem - blue's side is no longer aligned! Percival sits down with Lenny, Archie, and the developers, and they start to come up with a new plan. They decide to only operate on certain sections of the cube at a time, and Solve's algorithms are refined to allow more complex operations which preserve the structure of other parts of the cube. A new development plan is written that allows developers to take turns performing operations instead of doing a large set of operations at once.

Furthermore, they implement a test plan to be used after each operation: each side would be checked to ensure that no pieces were moved unexpectedly. Additionally, once a corner or section was put into place, developers would verify that the colors were still aligned correctly.

Percival continues to oversee development while keeping Ripley updated on the project's progress. After two weeks, all sides of the cube have been aligned to a single color, and the team checks this against the requirements to ensure that everything is as it should be. Ripley is pleased with the product and happily writes a check to Cubits Solutions. Success!


So there you have it: an unnecessarily long story which both attempts to explain software development in terms of a Rubik's Cube while also demonstrating my ignorance about how solving algorithms actually work =)

Saturday, June 11, 2011

ABC, 123, Lucky Me

For no reason in particular, I decided to go to google and enter each letter of the alphabet (lowercase a,b,c,...,z) and each single digit (0,1,2,...,9) and hit the "I'm Feeling Lucky™" button. In case you don't know:
The "I'm Feeling LuckyTM" button automatically takes you to the first web page returned for your query.

An "I'm Feeling Lucky" search means less time searching for web pages and more time looking at them.


As expected, many of the pages returned were wikipedia entries, especially for the numbers. There were a few surprises, including a non- Oprah result for 'o', and a relatively new google service for '1'. If there's any interest in this little experiment, I may go back through and list the first non-Wikipedia results.

Here are the results for each search:


a

A - Wikipedia
http://en.wikipedia.org/wiki/A

b

B - Wikipedia
http://en.wikipedia.org/wiki/B

c

Citigroup, Inc. New Common Stock - Yahoo! Finance
http://finance.yahoo.com/q?s=C

d

Intro - D Programming Language 2.0 - Digital Mars
http://www.digitalmars.com/d/

e

E! Online
http://www.eonline.com/

f

Ford Motor Company Common Stock - Yahoo! Finance
http://finance.yahoo.com/q?s=F

g

Gmail
https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl&bsv=llya694le36z&scc=1<mpl=default<mplcache=2&from=login

h

Hydrogen - Wikipedia
http://en.wikipedia.org/wiki/Hydrogen

i

I - Wikipedia
http://en.wikipedia.org/wiki/I

j

J.Crew
http://www.jcrew.com/index.jsp

k

K - Wikipedia
http://en.wikipedia.org/wiki/K

l

L - Wikipedia
http://en.wikipedia.org/wiki/L

m

M (1931) - imdb
http://www.imdb.com/title/tt0022100/

n

N - Free Online Action Games from AddictingGames
http://www.addictinggames.com/action-games/ngame.jsp

o

"O" - Cirque du Soleil
http://www.cirquedusoleil.com/en/shows/o/default.aspx

p

P paragraph HTML 4.01 strict
http://www.december.com/html/4/element/p.html

q

Q (Star Trek) - Wikipedia
http://en.wikipedia.org/wiki/Q_%28Star_Trek%29

r

The R Project for Statistical Computing
http://www.r-project.org/

s

Sprint Nextel Corporation Comm - Yahoo! Finance
http://finance.yahoo.com/q?s=S

t

Massachusetts Bay Transportation Authority
http://www.mbta.com/

u

U - Wikipedia
http://en.wikipedia.org/wiki/U

v

V - ABC.com
http://abc.go.com/shows/v

w

W. (2008) - imdb
http://www.imdb.com/title/tt1175491/

x

-X- the band official website
http://www.xtheband.com/

y

the Y: Find Your Y (YMCA)
http://www.ymca.net/find-your-y/

z

Z (1969) - imdb
http://www.imdb.com/title/tt0065234/



0

0 (number) - Wikipedia
http://en.wikipedia.org/wiki/0_%28number%29

1

Google +1 Button
http://www.google.com/+1/button/

2

2 (number) - Wikipedia
http://en.wikipedia.org/wiki/2_%28number%29

3

Theband3.com - Official Site of 3
http://www.theband3.com/

4

4 (number) - Wikipedia
http://en.wikipedia.org/wiki/4_%28number%29

5

5 (number) - Wikipedia
http://en.wikipedia.org/wiki/5_%28number%29

6

6 (number) - Wikipedia
http://en.wikipedia.org/wiki/4_%28number%29

7

7 (number) - Wikipedia
http://en.wikipedia.org/wiki/4_%28number%29

8

8 (number) - Wikipedia
http://en.wikipedia.org/wiki/4_%28number%29

9

9 (2009) - imdb
http://www.imdb.com/title/tt0472033/