SEB AB interview question

when would I consider abstracting code to its own method/pattern