ਡਿਜ਼ਾਈਨ ਪੈਟਰਨ ਅਕਸਰ refactoring ਰਾਹੀਂ ਉਭਰਦੇ ਹਨ ਬਜਾਏ ਅੱਗੇ ਨੂੰ ਡਿਜ਼ਾਈਨ ਕੀਤੇ ਜਾਣ ਦੇ — ਜਿਵੇਂ ਕੋਡ ਵੱਧਦਾ ਹੈ ਅਤੇ ਇਸ ਦੀਆਂ ਲੋੜਾਂ ਸਪੱਸ਼ਟ ਹੋ ਜਾਂਦੀਆਂ ਹਨ, refactoring ਪੈਟਰਨ ਵੱਲ ਡਿਜ਼ਾਈਨ ਨੂੰ ਬਿਹਤਰ ਬਣਾਉਂਦਾ ਹੈ। ਇਹ ਪੈਟਰਨ ਲਾਗੂ ਕਰਨ ਦੇ ਸਿਧਾਂਤ ਨੂੰ ਪ੍ਰਤੀਬਿੰਬਿਤ ਕਰਦਾ ਹੈ ਜਦੋਂ ਅਸਲ ਵਿੱਚ ਲੋੜ ਹੋ, ਅੰਦਾਜ਼ਾਜਨਕ ਤੌਰ 'ਤੇ ਨਹੀਂ।
ਪੈਟਰਨ refactoring ਰਾਹੀਂ ਉਭਰਦੇ ਹਨ
Rather than designing patterns in UPFRONT (often premature/speculative), patterns often
emerge as you REFACTOR existing code:
→ start SIMPLE → as needs become clear (real complexity, real duplication, real change
points), REFACTOR toward a pattern that addresses them
→ "refactor TO a pattern" when the code would genuinely benefit
→ patterns as a destination of refactoring, not a starting blueprint
