Hacker News new | past | comments | ask | show | jobs | submit login

not sure about "the best way", but besides the obvious cases ( factory, singleton ) i apply the Kerievsky's Refactoring To Patterns method.

    “Instead of thinking about a design that would work for every nuance of a system, 
    test-first programming enabled me to make a primitive piece of behavior work correctly 
    before evolving it to the next necessary level of sophistication.” 
    Kerievsky (2002)

If a piece of code survives long enough to deserve some refactoring, then i take a closer look at the patterns.

Applications are open for YC Winter 2022

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact