Tuesday, April 19, 2016

return null vs. throw exception

Its not wise to return null when any business logic is incorrect its best to throw an exception when there's a validation error or a required field missing.
This way you can propagate the error up the stack

Example:

  if(imageTicket == null) {
   throw new ImageTicketNotFoundException("Could not find a image ticket for the id provided");
  }

Regex string to match string that starts with XX and ends with YY

Below matches a string that starts with XX and ends with YY.
Case sensitive but doesnt account for spaces.
/g Global flag enabled

\bXX\S*YY\b

Example: (#1 and #4 are a match)
  1. XXX-asdsd-sdsd-sdsdYY
  2. -XX-asdsdf sdf df dgsdfgs-YYsds
  3. XX-sd fsdg sdfg sdfgsfgh sdfg sdYY
  4. XX-sdfd-sdfsdgb-sdgbsd-gbd-sdYY
Test:
http://www.regexpal.com/?fam=94689

Monday, April 4, 2016

DevOps - It's all about continuous testing !

Phases of Testing:
  • Prior to code integration to trunk, developers pre-flight test their code to make sure it doesn’t blow up the trunk. 
  • During the CI cycle and code commits from multiple developers integration testing is used to verify merges. During the continuous testing phase where nightly and weekend regression runs are automated for trunk and release branches it is testing that does the job of finding problems before the software release.  
  • During the release deployment phase more testing verifies the release packages are ready for release.  

Whether the organization is using a test driven development methodology, behavior based test creation, model-based testing or whatever they use, testing is a vital part of the overall DevOps process — not only to ensure verify code changes work and integrate well — but to ensure the changes do not blow up the product.

Source: http://devops.com/2015/02/02/devops-continuous-testing/