એન્ટી-પેટર્નસ એ પુનરાવર્તિત સમસ્યાઓનો સામાન્ય પરંતુ નબળો ઉકેલ છે — આવતા અભિગમ જે સમજણીય લાગે છે પરંતુ ખરાબ પરિણામો તરફ દોરી જાય છે (જાળવણી કરવું મુશ્કેલ, ખામીયુક્ત અથવા કઠોર કોડ). તેમને ઓળખવાથી તમને સામાન્ય ભૂલો ટાળવામાં મદદ મળે છે.
એન્ટી-પેટર્નસ શું છે
ANTI-PATTERNS = commonly-used but COUNTERPRODUCTIVE solutions:
→ they seem like a solution but cause MORE problems (technical debt, bugs, rigidity)
→ the OPPOSITE of design patterns (proven good solutions)
→ recognizing them helps you AVOID common pitfalls
સામાન્ય કોડ/ડિઝાઇન એન્ટી-પેટર્નસ
GOD OBJECT/CLASS → one class doing too much (huge, knows everything) → hard to maintain;
violates single responsibility
SPAGHETTI CODE → tangled, unstructured code with no clear flow → hard to follow/change
COPY-PASTE programming → duplicated code (violates DRY) → bugs/changes must be fixed everywhere
MAGIC NUMBERS/STRINGS → unexplained literal values → unclear, error-prone
PREMATURE OPTIMIZATION → optimizing before it's needed → wasted effort, complexity
GOLDEN HAMMER → over-using one familiar tool/pattern for everything ("when you have a hammer...")
HARDCODING → values that should be configurable baked into code
