This is a quick guide for people who don’t feel confident with OOP concepts yet, but want to make first steps towards improving their code using OOP principles.
If you don’t know where to start, try to look for the following patterns and apply provided recipes. Here are some problem you can find and possible solutions:
Problem | Recipes |
---|---|
Code repetition: literals (numbers, string) that you use more than once | Use power of constants: remove code repetition (less literals in code), reduce typing errors, get better IDE support. Bonus: document your code by giving meaningful names to values. |
Code repetition: expressions | Look for repeated patterns and put them into functions. Same bonuses with documenting your code. |