Programování Expert Claude

Refactoring legacy kódu

Systematický refactoring s zachováním funkcionality a přidáním testů.

Prompt text

Délka: Střední
Pomož mi refactorovat tento legacy kód:

**Současný kód:**
```[JAZYK]
[LEGACY KÓD]
```

**Problémy:**
[KNOWN ISSUES - např. nested if/else, long functions, duplications]

**Requirements:**
1. Zachovat funkčnost (100% backwards compatible)
2. Zlepšit readability
3. Aplikovat [DESIGN PATTERN] pokud vhodný
4. Přidat unit testy
5. Zdokumentovat změny

**Constraints:**
- Nemůžu změnit: [CO ZŮSTÁVÁ]
- Framework: [FRAMEWORK]
- Coding standards: [STANDARDS - např. PEP 8, Airbnb]

**Output:**
1. Refactored kód
2. Migration guide
3. Test suite
4. Before/after comparison
Interaktivní tvůrce

Příklad použití

Vstup:

Refactoruj: 300-line JavaScript function s 8 úrovněmi nested if/else. Problémy: nečitelné, no error handling, no tests. Framework: vanilla JS. Standards: Airbnb. [vloží legacy kód]

Výstup:

Refactored code: Split do 6 smaller functions (max 50 lines each), extracted helper functions, replaced nested ifs s early returns + guard clauses, added proper error handling with custom exceptions, implemented strategy pattern pro conditional logic. Test suite: 15 unit tests covering happy path + edge cases. Migration guide: no breaking changes, drop-in replacement. Before/after: cyclomatic complexity from 28 → 6.

Kde použít tento prompt?

Najděte vhodné AI nástroje pro použití tohoto promptu a maximalizujte jeho efektivitu.

Objevte další AI prompty

Prozkoumejte naši sbírku Programování promptů a najděte ty, které vám pomohou dosáhnout lepších výsledků.