Replace conditional with polymorphism – nice in theory but not practical

You’re right – “the conditionals are getting pushed up to the top of the chain” – but there’s no “just” about it. It’s very powerful. As @thkala says, you just make the choice once; from there on out, the object knows how to go about its business. The approach you describe – BaseAction, ViewAction, and … Read more

Massively refactor – how to add final keyword to Java method argument

You can use IntelliJ’s inspections mechanism for this: Navigate to Analyze->Run Inspection by Name Search for the “Local variable or parameter can be final” warning Make sure that “Report method parameters” is the only option checked. Select the root of the tree (it should read Local variable or parameter can be final” Click ALT+ENTER and … Read more

Additional Refactoring for Eclipse CDT

Most of the refactoring features in Eclipse CDT are developed by people working and studying at the HSR Hochschule für Technik in Rapperswil Switzerland. There are students working on new refactorings and enhancements. After they had been reviewed they will be integrated into the official CDT. For more information of the ongoing development get in … Read more

How to convert a list with properties to a another list the java 8 way?

you will have to use something like below : List<ProductManager> B = A.stream() .map(developer -> new ProductManager(developer.getName(), developer.getAge())) .collect(Collectors.toList()); // for large # of properties assuming the attributes have similar names //other wise with different names refer this List<ProductManager> B = A.stream().map(developer -> { ProductManager productManager = new ProductManager(); try { PropertyUtils.copyProperties(productManager, developer); } catch … Read more

What’s the difference between Remove and Exclude when refactoring with PyCharm?

Final effect is the same – entry which was Removed or Excluded won’t be refactored, the difference is in presentation. After selecting Exclude you keep entry in the Refactoring Preview, but Remove deletes it from that window. I think that Remove could be useful when you deal with quite large refactoring and marking everything as … Read more

Number of parameters for a constructor

12 parameters definitely sound too many to me. Options to reduce their numbers are: Introduce Parameter Object by grouping logically related parameters into an object and passing that object instead of the individual parameters. Introduce a Builder (optionally with method chaining). This does not reduce the actual parameter list but it makes the code more … Read more

Refactoring if/else logic

You should use Strategies, possibly implemented within an enum, e.g.: enum UserType { ADMIN() { public void doStuff() { // do stuff the Admin way } }, STUDENT { public void doStuff() { // do stuff the Student way } }; public abstract void doStuff(); } As the code structure within each outermost if branch … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)