Jul. 12th, 2011

juan_gandhi: (Default)
presheaf.com now maintains history of your renderings... in a cookie, so there. Gotta go to sleep.
juan_gandhi: (Default)
"consistent indentation style was one of the most statistically significant indicators of low bug density."

(Martin, Robert C. (2008-08-01). Clean Code: A Handbook of Agile Software Craftsmanship . Prentice Hall. Kindle Edition. )
juan_gandhi: (Default)
Just wrote a couple of methods in my main mock class.

public void failingOn(String regex) {
  this.failureCondition = regex;
}

public void maybeFail(Object...objects) throws HBaseException {
  if (failureCondition != null) {
            String s = Arrays.asList(objects).toString();
    if (s.matches(failureCondition)) {
      throw new HBaseException("Congratulations, you hit the jackpot today: " + s);
    }
  }
}



and most of the methods look like this:

@Override
public void bulkDelete(String tableName, Collection rowKeys, String columnFamily) throws HBaseException {
  maybeFail("bulkDelete", tableName, rowKeys, columnFamily);
  table(tableName).family(columnFamily).delete(rowKeys);
}


Now in the test I write stuff like this:
@Test    
public void testPut_replicating_withErrors() throws Exception {
  MockHBaseOperations cluster2 = new MockHBaseOperations();
  cluster2.failingOn("\\[sendToCluster, BadTable,.*");
  ...
}


... do you need explanations on how it works?

What I personally enjoy here is the leisure JavaScript coding style, where you just join the arguments, not giving a fuck about their types.
juan_gandhi: (Default)
Bjarne Stroustrup, inventor of C++ and author of The C++ Programming Language:

"I like my code to be elegant and efficient. The logic should be straightforward to make it hard for bugs to hide, the dependencies minimal to ease maintenance, error handling complete according to an articulated strategy, and performance close to optimal so as not to tempt people to make the code messy with unprincipled optimizations. Clean code does one thing well."

(Martin, Robert C. (2008-08-01). Clean Code: A Handbook of Agile Software Craftsmanship (p. 7). Prentice Hall. Kindle Edition. )

(and yes, I do quotes using kindle on my windows laptop)

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

August 2025

S M T W T F S
      12
3456789
10 11 12 13141516
171819 20212223
24252627282930
31      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 22nd, 2025 04:25 am
Powered by Dreamwidth Studios