Code Smell Intra Class "Inside a class

Get Started. It's Free
or sign up with your email address
Rocket clouds
Code Smell Intra Class "Inside a class by Mind Map: Code Smell Intra Class  "Inside a class

1. Comment

1.1. Extract method

1.2. Rename method

1.3. Introduce assertation

1.3.1. // should have either expense limit or a primary project => Assert.isTrue (_expenseLimit != NULL_EXPENSE || _primaryProject != null);

2. Long Method

2.1. Extract method

2.1.1. Grouper les method

2.2. Replace temp with querry

2.2.1. if (basePrice() > 1000) return basePrice() * 0.95; else return basePrice() * 0.98; ... double basePrice() { return _quantity * _itemPrice; }

2.3. Introduce param object

2.3.1. You have a group of parameters that naturally go together. Replace them with an object.

2.4. Preserve whole object

2.4.1. You are getting several values from an object and passing these values as parameters in a method call.withinPlan = plan.withinRange(daysTempRange());

2.5. Replace method with object method

2.5.1. You have a long method that uses local variables in such a way that you cannot apply Extract Method

3. Long param List

3.1. Replace Parameter with Method

3.1.1. An object invokes a method, then passes the result as a parameter for a method. The receiver can also invoke this metho

3.2. Preserve Whole Object

3.2.1. withinPlan = plan.withinRange(daysTempRange());

3.3. Introduce Parameter Object

4. Duplicated Code

4.1. Extract Method

4.2. Pull Up field

4.3. Pull Up method

4.4. Form template method

4.4.1. You have two methods in subclasses that perform similar steps in the same order, yet the steps are different. Regroup les method similair en class mere et dans fils on les overide

4.5. Substitute Algorithm

4.5.1. ou want to replace an algorithm with one that is clearer. Replace the body of the method with the new algorithm.

4.5.1.1. String foundPerson(String[] people){ List candidates = Arrays.asList(new String[] {"Don", "John", "Kent"}); for (int i=0; i<people.length; i++) if (candidates.contains(people[i])) return people[i]; return ""; }

5. Name problem

5.1. Rename method

6. Dead Code Unused code or used only in test

6.1. Remove dead code

7. Speculative generality sometimes code is created "just in case" to support anticipated future features that never get implemented. As a result, code becomes hard to understand and support.

7.1. Cases

7.1.1. Abstract class doing nothing

7.1.1.1. Collapse hiarchy

7.1.2. Unused methods?

7.1.2.1. Inline Method

7.1.3. Methods with unused parameters

7.1.3.1. Remove Parameter.

7.1.4. Unused fields

7.1.4.1. Delete

8. Switch Statements

8.1. Replace Conditional with Polymorphism

8.1.1. You have a conditional that performs various actions depending on object type or properties

8.1.2. Create subclasses matching the branches of the conditional.

8.2. Replace Type Code with Subclasses

8.3. Replace Type Code with State/Strategy

8.4. Replace Parameter with Explicit Methods

8.5. Introduce Null Object

9. Temp field

9.1. Extract Class

9.1.1. Splitter la class : Create a new class and move the relevant fields and methods from the old class into the new class

9.2. Introduce Null Object