Sunday, May 20, 2012

Hamcrest Matchers in JUnit tests

Normal assertions in JUnit would look like this:

Assert.assertEquals(expectedValue, actualValue); for example Assert.assertEquals(3, bean.getValue());

With hamcrest matchers, we can make the tests much more expressive and with recent versions of JUnit, core hamcrest matchers are bundled with JUnit and so there is no need to download and add hamcrest to our classpath explicitly.

JUnit has this new static method in org.junit.Assert called assertThat which has signature like this:

assertThat(actual, Matcher);

Using this, we can make the tests very expressive. First add some of the static imports:

import static;
import static org.hamcrest.core.IsNot.not;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.hamcrest.core.IsNull.nullValue;
import static org.junit.Assert.assertThat;

Then, assertions can look like this:

      assertThat(bean.getValue(), is(equalTo(3)));
      assertThat(bean.toString(), is("XYZ"));
      assertThat(bean.getNewValue(), is(nullValue());
      assertThat(bean.getType(), is(not(nullValue()));

This shows how readable these tests are when compared to the regular assertions. Also, we can see that matchers can be nested. In the above block, is and not, is and equalTo, is and nullValue() are chained to make it more readable.

There are more matchers available in org.hamcrest.core package inside junit jar. In Eclipse, you can open up the junit jar under referenced libraries and navigate to this particular folder in package explorer to see other available matchers.

Only drawback that I found is, I cannot use assertThat for comparing double values with tolerance. Other than that, I tend to assertThat for most of my assertions. It certainly makes my tests much more readable and expressive!

Sunday, April 8, 2012

PMP Cheat Sheet

This PMP cheat sheet is a follow up to my earlier post on PMP formulas cheat sheet. I've gathered these as I've prepared for the exam and posting it here so that others preparing can benefit from it.

  1. What is a project?
  2. What is a program? 
  3. What is a portfolio?
  4. Who are stakeholders?
  5. Define stakeholder characteristics?
  6. What is contingency reserve?
  7. What is management reserve?
  8. What is last step in project closing?
  9. How will you choose a project given NPV of many projects?
  10. What is value engineering?
  11. Who issues project charter?
  12. What type of contract is purchase order?
  13. Sensitivity analysis is a technique in which process?
  14. Name some techniques in Perform Quality Assurance?
  15. What is Kaizen approach?
  16. Quality is management problem is mentioned by?
  17. Zero defects/Do it first time is mentioned by?
  18. Components of decision tree?
  19. What is critical chain?
  20. What is constructive change?
  21. What is code of accounts?
  22. Difference between precision and accuracy?
  23. Difference between quality and grade?
  24. Difference between agreement and contract?
  25. Difference between product scope and project scope?
  26. What is free float?
  27. What is total float?
  28. What is project scope statement?
  29. How to interpret control chart?
  30. What is staffing management plan?
  31. What is resource histogram?
  32. What is pareto chart?
  33. What is workaround?
  34. What is control account?
  35. What are types of contracts?
  36. List some information gathering techniques used in identifying risk?
  37. Define Time and Material contracts?
  38. What are seven basic tools of quality?
  39. What are different types of conflict management techniques?
  40. What are ways to handle negative risks?
  41. What are ways to handle positive risks?
  42. What are different stages of team development?
  43. What is Maslow's hierarchy of needs (from bottom to top)?
  44. List different types of power?
  45. Which power is very effective?
  46. Mention some sources of conflicts?
  47. What is procurement audit?
  48. What is gold plating?
  49. What is point of total assumption?
  50. What is war room?
  51. What is the sequence of actions that should happen when an issue happens?
  52. What is scope baseline?
  53. What is marginal analysis?
  54. What is zero sum reward system?
  55. What is murder board?
  56. What is oligopoly?
  57. What is Ethnocentrism?
  58. What is force majeure?
  59. What is typical duration range for WBS activity?
  60. What are responsibilities of risk owner?

  1. Project is temporary endeavor undertaken to create unique product, service or result (has defined start and end date)
  2. Program is group of related projects
  3. Portfolio is group of projects or programs (may or may not be dependent). They are grouped together for effective management.
  4. Stakeholders are persons or organizations whose interests may be positively or negatively affected by the performance or completion of the project. Stakeholders include project team as well. 
  5. The stakeholders of a project typically have conflicting objectives. They have maximum influence during initial stages of the project.
  6. Contingency Reserve is to cover known unknowns (known risks)
  7. Management Reserve to cover unknown unknowns (unknown risks)
  8. Last step in project closing is gather lessons learned and archive project info (Organization Process Assets updates) for future use
  9. Choose project with high NPV (i.e high net present value)
  10. Value engineering is less costly method to deliver same scope without performance degradation
  11. Project sponsor issues project charter
  12. Purchase order is fixed price type contract
  13. Sensitivity analysis is a technique in Quantitative Risk Analysis
  14. Quality audits, process analysis (includes root cause analysis) are some techniques in Perform Quality Assurance
  15. Kaizen approach is Continuous improvement
  16. Quality is management problem is mentioned by Deming
  17. Zero defects/Do it first time is mentioned by CrosbySquare - Decision node, Circle- Chance node, Triangle - end of branch.
  18. Decision tree components are square - decision node, circle- chance node and triangle - end of branch.
  19. Resource constrained critical path is critical chain.
  20. Undocumented change to contract is constructive change.
  21. Code of accounts is numbering system used to uniquely identify each component of the Work Breakdown Structure (WBS).
  22. Precision is values of repeated measurements are clustered and have little cluster. Accuracy is measured value is close to true value.
  23. Quality is degree to which a set of inherent characteristics fulfill requirements. Grade is category assigned to products or services that have the same functional use but different technical characteristics. Low quality is not acceptable, but low grade may be acceptable.
  24. Agreement is not legally binding but a contract is legally binding.
  25. Product scope means the features and functions of the product or service being built. Project scope means the work that's needed to build the product. 
  26. Free float is time that an activity can be delayed from it's early start date without delaying early start of any immediately following schedule activities.
  27. Total float is time that an activity can be delayed from it's early start date without delaying the project finish date.
  28. Project scope statement contains deliverables and also the work required to create those deliverables.
  29. Process is considered out of control when a data point in control chart exceeds control limit or if seven consecutive points in control chart are above or below (i.e on one side) of the mean.
  30. Staffing management plan adds time (schedule) component to Human Resource (HR) plan. It also includes rewards and recognitions, training requirements and release criteria.
  31. Resource histogram is part of staffing management plan. It describes the type and quantity of resources needed over a period of time.
  32. Pareto chart is type of histogram ordered by frequency of occurrence. It shows how many defects were generated by type of category of identified cause.
  33. Workaround is response to negative risk event. Differs from contingency plan in that workaround is not planned in advance.
  34. Control account is management control point where scope, cost and schedule are integrated and compared to the earned value for performance measurement.
  35. Different types of contracts are Fixed Price, Cost-Reimbursable, Time and material.
  36. Information gathering techniques used in identifying risk are Brainstorming, Interviewing, Delphi technique and root cause analysis.
  37. T&M contracts are hybrid type of contractual agreements that could contain aspects of both cost-reimbursable and fixed-price type arrangements.
  38. Seven basic tools of quality are Cause and Effect (Fishbone or Ishikawa) Diagrams, Control Chart, Flowcharting, Histogram, Pareto Chart, Run chart and Scatter Diagram.
  39. Conflict management techniques are Withdrawing/Avoiding, Compromising, Smoothing, Forcing, Collaborating and Confronting/Problem Solving,
  40. Ways to handle negative risks are Avoid, Transfer, Mitigate and Accept.
  41. Ways to handle positive risks are Exploit, Share, Enhance and Accept.
  42. Different stages of team development are Forming, Storming, Norming, Performing and Adjourning.
  43. Maslow's hierarchy of needs from bottom to top are Physiological needs, safety needs, social needs, self esteem needs and self actualization needs.
  44. Different types of power are Reward power, Coercive (penalty) power, Legitimate power, Referent power and Expert power.
  45. Most effective power is Expert power.
  46. Resources, schedules and priorities cause 50% of project problems and conflicts. Schedule is the biggest source of conflict.
  47. Once you've closed out a procurement, it's important to conduct a procurement audit. This is where you go over everything that happened on the project to figure out the lessons learned, and look for anything that went right or wrong. 
  48. Gold plating is when the team adds more work to the project that was not requested by the sponsor or client. It is not scope creep.
  49. The point of total assumption is the point at which the seller assumes the costs. In a firm fixed price contract, this is the point where the costs have gotten so large that the seller basically runs out of money from the contract and has to start paying the costs.
  50. The room the co-located team meets in is called a war room.
  51. When an issue happens, analyze impact of issue -> submit change request -> if approved, update schedule and scope baselines -> implement the change.
  52. The scope baseline is made up of Project Scope Statement, WBS and the WBS Dictionary.
  53. Marginal analysis - The best level of the quality is reached at the point where the incremental revenue being gained from improvements equals the incremental cost being spent to secure it.
  54. A Zero Sum reward system is a win-lose recognition program. For example, with an employee of the month program their will only be one or two team members who will win the award each month. Reward programs should be more win-win.
  55. Murder board is a process where a committee asks questions from project representatives as part of the project selection process. 
  56. Oligopoly - There are few sellers and action of one seller will have impact on other sellers prizes.
  57. Ethnocentrism refers to belief that ones culture is superior to other cultures.
  58. Force majeure is a powerful and unexpected event, such as hurricane or other disaster.
  59. WBS activity should be between 8 and 80 hours.
  60. Every risk should have a risk owner listed in the register. That person is responsible for keeping the response plan up to date and make sure the right actions are taken if the risk does occur.

Saturday, April 7, 2012

PMP Formulas Cheat Sheet

Recently, I took PMP certification. I'm posting the formulas that I had gathered during preparation in my personal cheat sheet, so that others preparing can benefit from it.

Three point estimate (PERT) = (to + 4tm + tp) / 6 (This applies for both cost and time) (to is optimistic estimate, tm is median estimate and tp is pessimistic estimate)
Standard deviation = (p-o)/6 (p is pessimistic and o is optimistic)
Total standard deviation (given other std deviations) is sqrt of the sum of the individual variances (variance is square of deviation)

Schedule variance: SV = EV - PV (EV is Earned Value, PV is Planned Value)
(Note that SV is always 0 at the end of the project (if the project is completed))
Cost variance: CV = EV - AC (AC is Actual Cost)
(CV at the end of the project is AC - BAC) (BAC is Budget At Completion)
(Both SV and CV should be positive. Negative schedule and cost variance means project is behind schedule and over budget respectively)
Schedule Performance Index: SPI = EV/PV
Cost Performance Index: CPI= EV/AC
(Both SPI and CPI should be greater than 1. Schedule and cost performance index less than 1 means project is behind schedule and over budget respectively)
Burn rate = AC / EV = 1/CPI

Forecasting: (Estimate at completion - EAC)
EAC = AC + bottom up ETC (ETC is Estimate To Complete)
EAC = AC + (BAC - EV) - This is applicable if remaining work is estimate to continue at budgeted rate
EAC = BAC / CPI - This is applicable if remaining work continues at current cost
EAC = AC + ((BAC - EV)/ (CPI x SPI)) - This is considering both SPI and CPI

Variance at completion: VAC = BAC - EAC 

Total Cost to Performance Index (TCPI):
TCPI based on BAC = (BAC - EV)/(BAC - AC)
TCPI based on EAC = (BAC - EV)/(EAC - AC) (Ratio of remaining work to funds remaining)

Expected Monetary Value: EMV = Probability X Impact (Cost)
Present Value: PV = FV / ((1+r) to the power of n) (FV is future value)