-
Notifications
You must be signed in to change notification settings - Fork 28
Code smells
As a software engineer, sometimes you see something in the code that feels like a code smell (something that doesn't quite "smell right").
A code smell is defined as:
any characteristic in the source code of a program that possibly indicates a deeper problem.
One of the most common code smells is "duplicated code" - this is code that is repeated in a very similar way in multiple places and can result in errors being introduced when you are trying to keep multiple similar copies up-to-date in different places whenever something changes or needs fixing.
The solution is through code refactoring:
restructuring existing computer code—changing the factoring—without changing its external behavior.
For example, we may be able to take a block of code that is repeated in multiple forms and write it as a single function or method that only exists is one place (and then only needs to be updated in a single place in the future).
This principal (also known as don't repeat yourself) is one of the main aims behind the use of reusable user controls.