• Post Reply Bookmark Topic Watch Topic
  • New Topic

[99,58] error: no suitable constructor found for WEMCostBean  RSS feed

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to add an additional field (called client). When I try to do this, I get the "no suitable constructor found" error. I don't understand what I am doing wrong or where else to look.


 
Bartender
Posts: 1840
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, thats an object with a lot of properties.

What were the steps you took to add this property?
If you have added a parameter to the Constructor, then you will get this error message place in your code where you were creating this object, because none of those places will be passing a client (which you have to now)
 
Michael Piaser
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the issue - there was another java file which referenced this class and I had to change that too.
 
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That constructor on line 123 is horrific

See http://c2.com/cgi/wiki?TooManyParameters - this page says "and clearly 16 parameters would be too many"
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael Piaser wrote:I found the issue - there was another java file which referenced this class and I had to change that too.

you should use your IDE to refactor. Doing these things manually is very error prone. Are you sure you got all the references that need to change?

And again, that constructor...
 
Michael Piaser
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've inherited this code. This is a pretty big system with 9,000 files.

I'm not sure what you mean by "refactor". I am doing searches in Eclipse and trying to deal with each hit in the search.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Know thy IDE. If you're changing a method signature, Eclipse has a refactoring for that. Find "Refactor..." in your context menu (the menu you get when you right-click on the part of the code you want to change). Eclipse will do the work of finding all the references for you -- it will do the heavy lifting.
 
Sheriff
Posts: 22845
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've worked with systems of that size and while there's a lot to complain about in that class (String variables for obvious numeric values? Exactly 10 cost centers?) it doesn't look outrageous to me. Refactoring might be a good idea but in a system of that size you need a strategy.

As for Eclipse, I find that when you change something it automatically flags everything which became an error because of that change. No searching should be required, that's why you have the IDE. Perhaps it's set to not rebuild after every change? That wouldn't be surprising for a large code base. If you rebuild the project then you'll see all the errors you have to fix.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know, that many parameters in a constructor is pretty outrageous to me. And they are all Strings for crying out loud. Granted, I've seen worse code than this but still...

And this:

"Chargeses" ... really?! "ChargesList" never crossed someone's mind here? It's not a typo either. Somebody actually went like, "Well, I already have a 'charges' variable, so what do I name this list of them...? Let's go with 'Chargeses' ..." Sorry but for me there's really no excuse for that.
 
Michael Piaser
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
like I said - I inherited this code. There are multiple places where a word is intentionally spelled wrong. Probably doesn't help that the initial authors were from Bolivia.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't take my comments the wrong way. It's just that these kinds of things are among my pet peeves, and I have a few that I just can't help but comment about when I see them. Good names are very important to me and actually refactoring them in code like this takes very little effort. If I can think of a better name for something, I seldom hesitate to change it. Highlight, then Alt-Shift-R in Eclipse is all it takes.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael Piaser wrote:Probably doesn't help that the initial authors were from Bolivia.

Are you sure they weren't Elbonians?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!