Hacker News new | past | comments | ask | show | jobs | submit login

> I maintain a large set of codebases right now...

Does that mean you have a large set of small-to-medium-size code bases? Because, though that's also a hard problem, it's different than maintaining one huge code base.




The Java codebase is 170k lines. C#, about the same. Lua, about 45k. I don't know if thats a lot of little codebases, but sometimes it feels seriously dystopic moving around the Java stuff.


Well, huge is relative to many things. Thanks for the ballpark numbers though. Pain points change and intensify over different orders of magnitude.


So how do you refactor a method signature to swap argument order in Lua? Please don't answer "manually".


What's wrong with doing it manually, especially if you have good tests?


It's error prone and time consuming. How do you promise that your tests cover every instance of calls to that method? How do you make sure that you are only changing the correct method (especially when it has a common name)?


Umm .. I don't? Seriously, who needs to do this? Never had to do it in Lua. Same with Java, although I could see a case where it might be 'necessary', I still don't agree that its a good thing that the language promotes this activity.

Needing to do this indicates worse problems with the developer than the fact of a codebase being too unwieldy.


The language just promotes that it's easy to parse so that tools can be written to automatically transform source code in certain ways. Eclipse has a lot more refactorings than just reorder method arguments. Lua should theoretically fall into the same bucket of languages, it's just that there probably are fewer tools for refactoring so far.

Compare that to languages like C++ where despite its age and being used to widely there are still very few working refactoring tools.

(All that being said, I usually used method argument reordering when removing or adding arguments to a method by changing what the method is doing and then noticing that a different order makes more sense when reading.)


In 15 years of coding, I've need to do that exactly zero times.

Is this really something people are doing?


It's an extremely common refactoring in modern Java/C# IDE's. Swapping arguments isn't necessarily a big deal (but being able to do it safely and automatically means that there is also no cost). A bigger one is adding/deleting parameters or renaming methods.


I don't understand why it would be necessary to refactor the argument order for methods that are extensively used. Can you provide a productive example for when this might be an appropriate action for a developer to take - I'm having difficulty understanding why on Earth this would be necessary, but I'd be happy to learn ..


"Necessary" might be a hard barrier to get over, but I can think of times when it might be nice. For instance in C# optional parameters must be at the end of the parameter list (that is all required parameters must come before any optional ones).

So for our highly used method we realize that there is actually a reasonable default for the first parameter (maybe because we notice tons of usages of that value). In order to change this from a required to an optional field, we must move it to the back of the list.

Without an automated and safe way to do this, I'm unlikely to make that refactoring, leaving us with a code base that is worse than it could be. Again, is it necessary? No, but if it is trivial my code will get better, if it isn't my code will stay worse.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: