SEB AB Interview Question

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