The methods getTransactionHash() and getTransactionHashSegwit() in BitcoinUtil are methods that operate on instances of Transaction and therefore should be non-static methods of Transaction in order to adhere to good principles of OO design, viz. encapsulation, whereby operations that work on specific data are bundled together with those data. As discussed in issue #71, Java methods do not incur a per-instance memory overhead. If compatibility is an issue, then BitcoinUtil can be refactored as:
public class BitcoinUtil {
/**
* @deprecated Use transaction.getTransactionHash().
*/
public static byte[] getTransactionHash(BitcoinTransaction transaction) {
return transaction.getTransactionHash();
}
}
The methods
getTransactionHash()
andgetTransactionHashSegwit()
inBitcoinUtil
are methods that operate on instances ofTransaction
and therefore should be non-static methods ofTransaction
in order to adhere to good principles of OO design, viz. encapsulation, whereby operations that work on specific data are bundled together with those data. As discussed in issue #71, Java methods do not incur a per-instance memory overhead. If compatibility is an issue, thenBitcoinUtil
can be refactored as: