Posts

Refactoring - Replace Temp with Query

Motivation:  You are using a temporary variable to hold the result of an expression. public double GetDiscountedPrice() { double basePrice = _quantity * _itemPrice; double discountFactor; if (basePrice > 1000) discountFactor = 0.95; else discountFactor = 0.98; return basePrice * discountFactor; } Refactor as: public double GetDiscountedPrice() { return BasePrice() * DiscountFactor(); } private double BasePrice() { return _quantity * _itemPrice; } private double DiscountFactor() { if (BasePrice() > 1000) return 0.95; else return 0.98; }

Refactoring - Inline Temp

Motivation:  You have a temp that is assigned to once with a simple expression, and the temp is getting in the way of other refactorings. float dvdPrice = MovieDVD.Price(); return dvdPrice; Refactor as: return MovieDVD.Price();

Refactoring - Inline Method

Motivation:  A method's body is just as clear as its name. public float GetMovieRanking(float rating, int totalVotes, int minVotesRequired, float meanVotes) { return CalculateMovieRanking(rating, totalVotes, minVotesRequired, meanVotes); } private static float CalculateMovieRanking(float rating, int totalVotes, int minVotesRequired, float meanVotes) { float movieRanking = (rating * totalVotes + minVotesRequired * meanVotes) / (totalVotes + minVotesRequired); return movieRanking; } Refactor as: public float GetMovieRanking(float rating, int totalVotes, int minVotesRequired, float meanVotes) { float movieRanking = (rating * totalVotes + minVotesRequired * meanVotes) / (totalVotes + minVotesRequired); return movieRanking; }

Refactoring - Extract Method

Motivation:  Producing methods that efficiently communicate what they do and how they do what they do. It consists of calls to well-named methods that are all at the same level of detail. public float CalculateMovieRanking(float rating, int totalVotes, int minVotesRequired, float meanVotes) { if (rating > 10 && rating < 0) throw new Exception("The rating should be in range of 0 and 10"); if (minVotesRequired < 3000) throw new Exception("Minimum votes required for the calculation is 3000"); if (totalVotes < minVotesRequired) throw new Exception("The total votes can not be less than minimum votes required"); if (meanVotes > 10 && meanVotes < 0) throw new Exception("The mean votes should be in range of 0 and 10"); float movieRanking = (rating*totalVotes + minVotesRequired*meanVotes) / (totalVotes + minVotesRequired); return movieRanking; } Ref

My Bookmarks

My Bookmarks Test Automation Tool Independent Automation Framework Manual Testing Combinatorial Testing Unit Testing Reference on Design Patterns, Antipatterns, UML, Refactoring Agile Testing Explanation on Product Backlog and Items Test Metrics Dashboards (Agile) Implementing Automated Software Testing - Continuously Track Progress and Adjust Accordingly BI / DW Testing BI Testing Process DW Testing Strategies for Testing Data Warehouse Applications Performance Analysis Performance Troubleshooting using the PAL tool Get a Handle on Windows Performance Analysis Performance Analysis of Logs Performance Testing Tools PAL Tool Relog - filter the perf logs Empirix Hammer - IVR kind of application Test Automation Tools Open Source MBT Tool Choosing Test Automation Framework Testing Forums Software Testing Club

Refactoring - Chain Constructors

Motivation:  Chain the constructors together to minimize the duplicate code without having to resort to initialization method.  Initialization method is troublesome because only constructor can modify read only members. public class Movie { private readonly string title; private readonly string genre; private readonly string director; public Movie(string title, string genre) { this.title = title; this.genre = genre; } public Movie(string title, string genre, string director) { this.title = title; this.genre = genre; this.director = director; } } Refactor as: public class Movie { private readonly string title; private readonly string genre; private readonly string director; public Movie(string title, string genre) { this.title = title; this.genre = genre; } public Movie2(string title, string genre, string director):this(title, genre) {

Typical System Level Testing Tasks

Analyze products’ features and functions based on the risk of their failure – a function of importance, likelihood and impact of failures.  The risks can be associated with business, operational, technology or external. Development of testing strategy, which includes selection of relevant testing techniques and prioritizing of testing activities. Preparation of test plan Designing tests by selecting key test ideas Setting up the test environment if not available here Execution of test cases Reporting of defects Reporting of test execution results to stakeholders Preparation of the traceability matrix Management of test artifacts and testware environment Designing and development of regression tests