0% found this document useful (0 votes)
60 views13 pages

Clean Code Principle: Muhammad Ali Zohaib Masood

This document discusses principles of clean code, including: keep it simple and stupid (KISS), don't repeat yourself (DRY), separation of concerns (SOC), and design by contract. KISS advocates solving problems with few lines of code to improve quality and productivity. DRY aims to reduce duplicated information. SOC requires each program element to address a single concern. Design by contract uses pre/post-conditions and invariants to ensure software components meet expectations.

Uploaded by

Muhammad Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views13 pages

Clean Code Principle: Muhammad Ali Zohaib Masood

This document discusses principles of clean code, including: keep it simple and stupid (KISS), don't repeat yourself (DRY), separation of concerns (SOC), and design by contract. KISS advocates solving problems with few lines of code to improve quality and productivity. DRY aims to reduce duplicated information. SOC requires each program element to address a single concern. Design by contract uses pre/post-conditions and invariants to ensure software components meet expectations.

Uploaded by

Muhammad Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Clean Code Principle

Muhammad Ali
Muhammad Ali and Zohaib Masood
Zohaib Masood
Overview
 Why Clean Code?
 Principles of Clean Code
 DRY
 KISS
 SOC
 Design by Contract

Muhammad Ali and Zohaib Masood


Clean Code
 Code should be easily readable

 Code should be easily understandable

 Code should be easily modified by anyone

Muhammad Ali and Zohaib Masood


Keep It Simple and Stupid
Whenever we want to implement
a method to do all things

Muhammad Ali and Zohaib Masood


Keep It Simple and Stupid
 Solve more problems, faster.

 Code complex problems in few lines of code

 Produce higher quality code

 Achieve more than you imagined

 Work in large development groups and large projects


since all the code is stupid simple

Muhammad Ali and Zohaib Masood


Don’t Repeat Yourself
A principle of software development, aimed at reducing
repetition of information of all kinds.

• Applicable whenever we Copy / paste


a piece of code
• Just use a method or a class

Muhammad Ali and Zohaib Masood


Don’t Repeat Yourself
 Very simple and not worth exploring too much.

 Don't write the same stuff in multiple places, or you

will have to keep them synchronized at every change.

 Simply don't repeat yourself.

Muhammad Ali and Zohaib Masood


Separation Of Concern
Design principle which states that each element of a
program should address a single concern

 Core concern represents a single


and primary functionality
 Cross cutting concern is
applicable throughout the system

Muhammad Ali and Zohaib Masood


Separation Of Concern
Functional Concerns
 Quality of service
 Policy
 System
 Organization

Muhammad Ali and Zohaib Masood


Separation Of Concern
A class should have a specific purpose and it should
be used for that purpose only.

It should be easy to extend and update whenever


required, and designed in such a way that testing do
not affect it.

Each functionality should be considered as a


separate concern and should not affect each other.
Muhammad Ali and Zohaib Masood
Design by Contract
Design by Contract (DBC) is a software correctness
technique that ensures high-quality software
systems by guaranteeing that every component of
the system lives up to its expectations.

Muhammad Ali and Zohaib Masood


Design by Contract
Pre-conditions: conditions that should exist before
a method can execute.
Post-conditions: conditions that should hold after a
method completes.
Invariants: predicates that should hold at certain
points in the execution of a program.
Muhammad Ali and Zohaib Masood
Thank You

Muhammad Ali and Zohaib Masood

You might also like