UrbanPro
true

Learn Advanced Java coaching from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Code Smell and Shotgun Surgery

Shamik Mitra
02/10/2016 0 0

The Code Smells are similar in concept to Development-level Anti-patterns. Sometimes in our code, we introduce code smell unintentionally those makes our design fragile.

 

Definition of Code smell

Code smell, also known as a bad smell, in computer programming code, refers to any symptom in the source code of a program that possibly indicates a deeper problem.

 

Martin fowler says:

 "a code smell is a surface indication that usually corresponds to a deeper problem in the system"

Code smell creates lot of problems while introducing new feature or maintains the codebase,

Often developer has to write repeatable code, breaking encapsulation, breaking abstraction etc.

If code smells are not corrected.

So always refactor code smell while developing.

 

In this article, we discuss one of the popular code smell “SHOTGUN SURGERY”

Shotgun surgery says, to introduce a small new change, a developer has to change many classes and methods, most of the time has to write duplicate codes which violate “Don’tRepeatYourself” principle.

Cause of Shotgun surgery smell:

1.    Due to poor separation of concern.

2.    Fail to understand the responsibility. Often due to misunderstanding (Single responsibility principle)

3.    Not identifying the common behavior or behavior with a slight change.

4.    Fail to introduce proper design pattern.

 

Consequences of Shotgun Surgery:

1.    Lots of duplicates code

2.    Taking more time to develop a small feature.

3.    Unmaintainable code base.

 

 

 

0 Dislike
Follow 0

Please Enter a comment

Submit

Other Lessons for You

Lazy initialization Vs Eager initialization
Memory and resource utilization plays crucial role in current enterprise era developers always need to take care of resource creation, utilization and it's cleanness on correct time to make application...
M

Introduction to Course Content
Video about what we are going to learn throughout the Java Training Session .

Tricks in Java
Find out the compatible and incompatible assignments class Qs1 { public static void main(String arg) { /* PART 1 int a=2.7f; // not ok int b=2.7;...

Create Immutable Class
Snippet of an Immutable Class: package com.stringhr; /*Declare the class as 'final'. This would prevent any other class from extending it and hence from overriding any method from it which could modify...

X

Looking for Advanced Java coaching Classes?

The best tutors for Advanced Java coaching Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Advanced Java coaching with the Best Tutors

The best Tutors for Advanced Java coaching Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more