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

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;...

Learning a new technology
Each and every day new technologies are getting introduced. Its quite clear that to be part of the fast moving professional world you should be upto date with the cutting edge technologies in the market....
S

Saurav Singh

1 0
0


How to create Rest web services in Java
Web services are web application components that lets two different applications to communicate over the network.Let if an application which in written java provides web services can be communicated through...

Callback using Function Pointer (in C), interface (in Java) and EventListener pattern
Note : Read the original document at http://som-itsolutions.blogspot.in/2017/01/blog-post_24.html “In computer programming, a callback is a reference to executable code, or a piece of executable...
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