The beauty of software design - Designers Challenge
public class GrindTest
{
@Test
public void grindMelons() throws Exception
{
int noOfMelons = 2;
List<Fruit> melons = Fruits.nFruits(
noOfMelons,
Fruits.newFruit(Seed.MELON) );
Grinder<Fruit> newGrinder = Grinders.newGrinder(melons);
/*
* Let's do some grinding
*/
Iterable<Seed> seeds = newGrinder
.grind( Blades.FRUIT )
.items();
Assert.assertEquals(
noOfMelons * Seed.MELON.noOfSeeds(),
Iterables.size(seeds));
}
@Test
public void grindBoxes() throws Exception
{
int noOfLoquats = 10;
int noOfBoxes = 2;
List<Fruit> loquats = Fruits.nFruits(
noOfLoquats,
Fruits.newFruit(Seed.LOQUAT) );
List<Box> boxes = Boxes.of( loquats ).times(noOfBoxes);
Grinder<Box> newGrinder = Grinders.newGrinder(boxes);
/*
* Grinding till we get the seeds
*/
Iterable<Seed> seeds = newGrinder
.grind( Blades.BOX )
.grind( Blades.FRUIT )
.items();
Assert.assertEquals(
noOfBoxes * noOfLoquats * Seed.LOQUAT.noOfSeeds(),
Iterables.size(seeds));
}
}
It seems that designers draw all the attention in the forrst. Can’t blame them, their designs are pleasant to the eyes. They show emotion. They have soul. Code listings look really borring, lacking any enthusiasm or creativity.
This post won’t bother you with principles on how to think of object oriented code. It’s about the art of software design.
Challenging designers to come up with a design that visualises the code above and reflects its quality and win a postcard from Edinburgh.
Calling all developers to come up with code that’s fun to use, tells a story and elevates software design.