@Test public void testProcessItemsEqualsBlockSize() throws Exception { TestBlockProcessor bp100 = new TestBlockProcessor( 100 ); bp100.process( 100 ); assertTrue( blocksDone == 1 ); assertTrue( itemsDone == 100 ); }
public void process( int number ) { for ( int i = 0; i < number; i++) { everyTime( i ); if ( i % blockSize == blockSize - 1 || i == number - 1 ) { everyBlock( i ); } } blocksComplete(); }
BlockProcessor { public void process( int number ) { for ( int i = 0; i < number; i++) { everyTime( i ); if ( i % blockSize == blockSize - 1 || i == number - 1 ) { everyBlock( i ); } } blocksComplete(); } }
BlockProcessor { public void process( int number ) { for ( int i = 0; i < number; i++) { everyTime( i ); if ( i % blockSize == blockSize - 1 || i == number - 1 ) { everyBlock( i ); } } blocksComplete(); } BlockProcessor( int blockSize ); }
BlockProcessor { public void process( int number ) { for ( int i = 0; i < number; i++) { everyTime( i ); if ( i % blockSize == blockSize - 1 || i == number - 1 ) { everyBlock( i ); } } blocksComplete(); } BlockProcessor( int blockSize ); void process( int number ); abstract void everyTime( int count ); abstract void everyBlock( int count ); void blocksComplete(); }
BlockProcessor { public void process( int number ) { for ( int i = 0; i < number; i++) { everyTime( i ); if ( i % blockSize == blockSize - 1 || i == number - 1 ) { everyBlock( i ); } } blocksComplete(); } BlockProcessor( int blockSize ); void process( int number ); abstract void everyTime( int count ); abstract void everyBlock( int count ); void blocksComplete();  }