Misa's story
Interviewing at Deloitte Digital
I was a cancer biologist - doing research for Cancer Research UK. I've always been interested in computers. In biology, the outcomes are always so vague and open to different interpretation. I was yearning for a craft that was clear cut, and a career allowed me to be creative. In software, the code either works or it doesn't - that sort of certainty, the immediacy of running code - that was a big pull for me.
Code sample
class Account
attr_reader :balance, :history
def initialize(transaction_class: Transaction)
@transaction_class = transaction_class
@balance = 0
@history = []
end
def withdraw(amount)
update_balance(-amount)
store_transaction_history(-amount, @balance)
end
def deposit(amount)
update_balance(amount)
store_transaction_history(amount, @balance)
end
private
def update_balance(amount)
@balance += amount
end
def store_transaction_history(amount, balance)
@transaction = @transaction_class.new(amount, balance)
@history << @transaction
end
end
I am proud of this code because I use dependency injection to reduce coupling between the Transaction and Account classes. The naming and responsibility of the class is clear.
Want to hire developers like Misa?
Request a call