How to automatically generate function headers for .h file in Clion?

Maybe it’s a little late (about 4 years), but here’s the best way i’ve found (for a c file): cut and paste the contents of the .c in the .h file, and for each function, put the cursor on it’s name and press Alt+Enter, and choose “Split function into declaration and definition”. this will keep … Read more

Why does the extract method command in visual studio create static methods?

Why does Visual Studio by default create a private static method when refactoring code and selecting extract method? It does this only if your method doesn’t access any member variables/methods/properties. This is good because it basically operates on the principle of least assumptions: since you don’t access instance-specific data, might as well make the method … Read more

How can I simplify this set of if statements? (Or, what’s making it feel so awkward?)

One reason it looks like a lot of code is that it is very repetitive. Use variables to store the parts that are repeated, and that will help with the readability: private List<Foo> parseResponse(Response<ByteString> response) { Status status = response.status(); int code = status.code(); boolean payloadAbsent = !response.payload().isPresent(); if (code != Status.OK.code() || payloadAbsent) { … Read more

Renaming packages in Eclipse

By default empty parent packages are hidden in the package explorer, if you modify the Filters… in the Package Explorer to uncheck Empty Parent Packages (third from top in second screenshot) you’ll be able to see the empty packages. (source: eclipse.org) You can then rename the com package and check the Rename subpackages option to … Read more

tech