18
Death of a coder CODER

Death of a coder

Embed Size (px)

Citation preview

Death of a coder

CODER

Why should we talk about it ?

Code smell !“Bad Code Smells are symptoms of poor design or implementation choices”

-Martin Fowler

Symptoms of smelling code• Rigidity• Fragility• Immobility• Viscosity ( Design / Environment )• Needless complexity• Needless repetition• Opacity

Rigidity• The code which is difficult to change.• Cascading of change in the dependent

modules.• Impact of change cannot be predicted.• Thus it can’t be estimated.• Time and cost can’t be quantified.

Fragility• Breaks at many places when changed.• Errors appear in the areas, unrelated to the

changed areas.• Quality is unpredictable.• Loss of credibility of the development team.• Sometime breakage increases with time.

Immobility• Inability to reuse Software Component.• Lack of reusable modules.• Desirable parts of the system depending on

undesirable part.• Thus it can’t be estimated.• Work and risk of extracting greater than cost of

writing it from scratch.

Viscosity ( Design / Environment )• Taking a shortcut and introducing technical debt

requires less effort than doing it right.• Building , testing and other tasks take a long time.

Therefore these activities are not executed properly by everyone and technical debt is introduced.

Needless complexity• Preparing for unknown extensions / Over flexible.• Bad algorithms.• Bad / Out-dated assumptions about system priorities.

Needless repetition• Cut / Copy and Paste - Evil in software industry.• How many places does the same processing occur ?

• That is the number of places that changes / fix must be made.

• The same code with minor change, makes the minor change easy to miss.

Opacity• How clear is the code ?• Code is hard to change.• Any change takes additional time to first understand and

than change.• More defects are introduced, due to not understanding

the side effects.

Clean code• Writing clean code from the start of the project is an investment.• Initial cost of change is a bit higher , but is paid back quite soon.• In clean code bugs cannot hide.• Code becomes easy to understand, and minimizes the risk of

introducing defects.

Principles of clean code• Loose coupling• High cohesion• Change is local.• It is easy to remove.

Loose coupling• Two classes / modules are coupled when at least one of

them uses the other.• The less these items knows about each other , the

loosely they are coupled.• More loosely coupled the items, easier is to replace and

modify them.

High cohesion• Cohesion refers to the degree to which the elements of a

module/class belong together.• It bind all related code together as far as possible. • It has to do with the elements within the module/class.

Change is local• Keeping changes local means, that there are boundary

in the design which changes do not cross.• While maintaining a system, keeping changes local

reduces involved cost and risks.

It is easy to remove• Removing elements is important so that the overall

design can be kept as simple as possible.• When a code block gets complicated, it has to be

removed and replaced with one or more simple blocks.

Thank You !!