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

JSP Interview Questions
Explain JSP Technology. JSP is a standard extension of Java and is defined on top of Servlet extensions. Its goal is to simplify management and creation of dynamic web pages. It is platform-independent,...

Design Pattern
Prototype Design Pattern: Ø Prototype pattern refers to creating duplicate object while keeping performance in mind. Ø This pattern involves implementing a prototype interface which tells...

Importance of Constructor's Visibility.
While developing program or implementing Singleton pattern we have learnt to mention constructor as private and known reason is -> to blocked its direct call from outside of class. But did we think...
M

Tips of learning Java Language/Other Programming Languages
1.You should know the basic concept: If we talk about programming languages so basic concept are same in all the high level languages. So you should know the basic concept firstly then you can easily understand...
I

ICreative Solution

0 0
0

What Is Applet & Its Life Cycle?
What is Applet & its life cycle?Applet is a Java programme that can be embedded into HTML page.Java Applet runs on the java enables web browsers such as Mozilla & Internet Explorer.Applets are...
I

ICreative Solution

0 0
0
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