4 ms·
I have a question for Googlers: I keep hearing about refactoring all across the repo. How does that work with dynamic call sites (reflection, REST), etc.? I me
by oblio 10y ago
I have a question for Googlers: I keep hearing about refactoring all across the repo. How does that work with dynamic call sites (reflection, REST), etc.?
I mean, there's no way to prove something is actually used in those cases except for actually running the thing.
Do you just rely (and hope) on tests across all projects?
- deleted 10y ago[deleted]
- ZoidbergWill 10y agoThe Google build tool, blaze (which is what their open source Bazel is based on), does analysis of what could break from code changes, so it only needs to run tests related to that. I assume it's easier with RPC.
- nostrademons 10y agoThe automated refactoring tools are largely for C++/Java/Go. Reflection etc. are fairly rarely used in those languages at Google. They present a number of problems at Google scale, both in terms of run-time overhead and in terms of code obfuscation for new engineers reading the code. When they are used, it's often internal to some other library/minilanguage (eg. Guice or Protobufs) with well-defined semantics, and then the tools just special-case that code and rely upon tools exposed by it to track call sites.
- vjeux 10y agoThere is a good talk from a Facebook engineer about this for JavaScript: https://www.youtube.com/watch?v=d0pOgY8__JM https://www.youtube.com/watch?v=d0pOgY8__JM It usually goes like this: - You make your API backward compatible. - You use grep to try and find all the ways people are using it. - You write and run a codemod to convert 70-90% of the call sites mechanically. - You manually fix the remaining ones. This is usually a good opportunity to throw a hackathon-style event where a bunch of people sit in a room for few hours and drive it down. - You remove support for the previous version.
- domlebo70 10y agoOh I don't miss Javascript/poorly typed languages.
- gefh 10y agoNearly all js at google is typed to some degree with closure compiler annotations.
- ionforce 10y ago> You use grep to try and find all the ways people are using it. The mere thought of this makes me think of the dark ages and a time in my career that I'd rather forget. All hail statically typed languages. Or languages that can easily be tooled against.
- _asummers 10y agoIf Facebook uses Flow internally, tooling could be written against that. Hell, just removing the old function and seeing the compile errors would expose all the call sites if their whole code base is Flow typed.
- asuffield 10y agoAs somebody who has done this a few times: you run all the tests of all the projects on your change, and you don't feel bad if somebody has code that breaks and doesn't have a test that caught it.
- packetslave 10y agoHyrum Wright (the king of large-scale refactoring at Google) did a talk at CPPCon about it. https://www.youtube.com/watch?v=ZpvvmvITOrk https://www.youtube.com/watch?v=ZpvvmvITOrk