All Questions
Tagged with code-smell clean-code
15 questions
2
votes
3
answers
217
views
Is it still "feature envy" if the state to make decision or the action to take after asking the state involves other classes to participate?
According to https://softwareengineering.stackexchange.com/a/212130/432039, if a class asks another class for the state, and then call methods of that class, it is called "feature envy", eg:
...
106
votes
11
answers
26k
views
Is putting general-use functions in a "helpers" file an anti-pattern or code smell?
Is it an anti-pattern or code smell to put "general use" functions (examples below) into a catch-all file named "helpers" or "utils"?
It's a pattern I've seen quite a lot ...
0
votes
1
answer
143
views
Is a "concrete function" over "generic function" a good implementation?
I want to know others opinion about this approach that I use in a lot of projects, for example, I can show the last time that I use it:
public class DataStorageService {
private enum Keys {
...
0
votes
1
answer
576
views
use always get and set methods is a bad practique, is call directly an attribute class a bad practique in OOP?
I have a doubt about if there are some recommendations for call directly an attribute in a class
I think that in OOP you always should call an attribute by the get method.
For example:
On set
...
10
votes
4
answers
3k
views
is this way of calling a function a bad practice?
I have the following code:
public void moveCameraTo(Location location){
moveCameraTo(location.getLatitude(), location.getLongitude());
}
public void moveCameraTo(double latitude, double ...
0
votes
5
answers
3k
views
Is using the Pair class a sign of primitive obsession code smell?
Let's say I use a Pair in this way:
Pair<Long, Date> signup = getSignup();
System.out.println("User with ID " + signup.getLeft() + " signed up on " + signup.getRight());
Is it a form of ...
3
votes
1
answer
1k
views
How do I use polymorphism instead of instanceof?
I'm trying to make an abstract board game. In the game, a player can choose to make multiple actions within one turn such as placing, moving, or rotating a piece. I'm not sure if whether or not my ...
4
votes
4
answers
2k
views
code smell: passing through variables [closed]
Consider this simple example:
def a(val_x, val_y):
return 5 + b(val_x, val_y)
def b(val_x, val_y):
return 1 + c(val_x, val_y)
def c(val_x, val_y):
return val_x * val_y
Passing the ...
1
vote
1
answer
151
views
Refactoring code dependent on external class
I have a class similar to ServletFilter which has multiple validation on the input request
class TokenHandler implements SomeHandler{
Response handle(Request request){
if(paramXMissing(request))...
0
votes
3
answers
2k
views
Does this code have only one level of abstraction?
I'm trying to apply some good practices from Clean Code in my code, but I'm stuck trying to figure out if my code has a [G34] code smell, which tells that functions should descend only one level of ...
2
votes
3
answers
443
views
Refactoring Atrocious Java Code [duplicate]
So I recently started a new job for a small software company. They've got some old technology which I was aware of during the interview process.
However, I've been digging into their code-base, and I'...
1
vote
2
answers
2k
views
How to avoid spaghetti code when I have a lot of conditions? [duplicate]
I have the following problem:
An user can withdraw money from 2 payment systems (but the number of payment systems can change anytime in the future).
If user has a trusted account on either of these ...
10
votes
3
answers
3k
views
Clean Code and Hybrid Objects and Feature Envy
So I recently made some major refactorings to my code. One of the main things I tried to do was split out my classes into data objects and worker objects. This was inspired, among other things, by ...
75
votes
2
answers
36k
views
What is a" feature envy" code and why is it considered a code smell?
This question on SO talks about correcting what the OP thought is feature envy code. Another example where I saw this nifty phrase being quoted is in a recently given answer here in programmers.SE. ...
6
votes
6
answers
416
views
Is code maintenance typically a special project, or is it considered part of daily work?
Earlier, I asked to find out which tools are commonly used to monitor methods and code bases, to find out whether the methods have been getting too long.
Most of the responses there suggested that, ...