Category: Refactoring

Code Smell – Bad Smell in Code : Understanding Lazy Class 0

Code Smell – Bad Smell in Code : Understanding Lazy Class

The Java runtime has built-in lazy instantiation for classes. Classes load into memory only when they’re first referenced. (They also may be loaded from a Web server via HTTP first.) Lazy class loading is...

Code Smell – Bad Smell in Code : Understanding Temporary Field 0

Code Smell – Bad Smell in Code : Understanding Temporary Field

Some of the TEMPORARY FIELDS to clarify the algorithm like as below public DayDate getNearestDayOfWeek(final Day targetDay) { int offsetToThisWeeksTarget = targetDay.index – getDayOfWeek().index; int offsetToFutureTarget = (offsetToThisWeeksTarget + 7) % 7; int offsetToPreviousTarget...

Code Smell – Bad Smell in Code : Understanding Switch Statements 0

Code Smell – Bad Smell in Code : Understanding Switch Statements

It’s hard to make a small switch statement. And, of course, I include if/else chains in this. Even a switch statement with only two cases is larger than I’d like a single block or...

Code Smell – Bad Smell in Code : Understanding Primitive Obsession 0

Code Smell – Bad Smell in Code : Understanding Primitive Obsession

-Use of primitives instead of small objects for simple tasks (such as currency, ranges, special strings for phone numbers, etc.) -Use of string constants as field names for use in data arrays. -Use of...

Code Smell – Bad Smell in Code : Understanding Data Clumps 0

Code Smell – Bad Smell in Code : Understanding Data Clumps

The most obvious form of duplication is when you have clumps of identical code that look like some programmers went wild with the mouse, pasting the same code over and over again. These should...

Code Smell – Bad Smell in Code : Understanding Feature Envy 0

Code Smell – Bad Smell in Code : Understanding Feature Envy

This is one of Martin Fowler’s code smells. The methods of a class should be interested in the variables and functions of the class they belong to, and not the variables and functions of...

Code Smell – Bad Smell in Code : Understanding Shotgun Surgery 0

Code Smell – Bad Smell in Code : Understanding Shotgun Surgery

You can insert calls to wait(), sleep(), yield(), and priority() in your code by hand. It might be just the thing to do when you’re testing a particularly thorny piece of code. Here is...

Code Smell – Bad Smell in Code : Understanding Comments 0

Code Smell – Bad Smell in Code : Understanding Comments

“Don’t comment bad code – rewrite it.” — Brian W. Kernighan and P. J. Plaugher If our programming languages were expressive enough, or if we had the talent to subtly wield those languages to...

Code Smell – Bad Smell in Code :: Understanding Long Parameter 0

Code Smell – Bad Smell in Code :: Understanding Long Parameter

The ideal number of arguments for a function is zero (niladic). Next comes one (monadic), followed closely by two (dyadic). Three arguments (triadic) should be avoided where possible. More than three (polyadic) requires very...

Code Smell – Bad Smell in Code :: understand Long Classes 0

Code Smell – Bad Smell in Code :: understand Long Classes

Understand Long Classes. Its like a Big BOM or Big Class. In an effort to make our classes and methods small, we might create too many tiny classes and methods. So this rule suggests...