Surrounding with Double Quotes in IntelliJ

IntellIJ has a feature where you can surround a String with double quotes by simply pressing “. Here’s how:

  1. Select the text you want in quotes
  2. Press “

There’s a video showing the feature.

However, this may appear not to work on your machine. There are two possible causes

Cause #1: The feature is off

Go into your IDE settings and choose

  1. Editor
  2. General
  3. Smart Keys
  4. Check “Surround selection on typing quote or brace”

Cause #2: Keyboard mapping

I’m on a Mac and the feature worked for single quotes and not double quotes. How odd. It’s clearly not cause #1 since it works for single quotes.

I then tried on my laptop keyboard and it worked with double quotes. So clearly the problem was my keyboard! Somehow it was being treated as an international keyboard instead of US. I remapped by going to “Keyboard” on Mac system settings and choosing “setup keyboard.”

Once I did this, the feature worked consistently on both keyboards.

Makes me wonder how people with non-US keyboards are supposed to use the feature!

EPS files on Mac

It used to be possible to view .eps files in Mac Preview. This was very convenient for viewing a quick image. In Sonoma, that ability was removed to avoid previewing malware.

Ok. But now I need a tool to open .eps files. Preferably a free or cheap one. I know Adobe Illustrator can do it, but that’s not cheap.

What didn’t work

Here’s what I tried that didn’t work

  • GIMP – showed the image with poor resolution for a few seconds than crashed. The. second time, it crashed right away. I tried redownloading and now Gimp says it can’t interpret file.
  • Skim – Didn’t open EPS files
  • Open office – shows just a box, not the image
  • Inkscape – ignores the request to open the file

What did work

I then abandoned trying to actually open the EPS file since I don’ edit them. There was some about converting to PDF. But images preview better. So I went with converting to png.

I found a Stack Overflow post suggesting using ghostscript. I was able to run a one liner and get all of them as .png. Now I can preview again!

find . -type f -name '*.eps' -exec gs -dSAFER -dBATCH -dNOPAUSE -dEPSCrop -sDEVICE=png16m -r600 "-sOutputFile={}.png" {} \;  

[devnexus 2024] refactoring after fowler: some large refactoring patterns

Speakers: Aaron McClennen & M. Jeff Wilson

For more, see the 2024 DevNexus Blog Table of Contents


This talk inspired by books:

  • Fowler’s Refactoring
  • Kerievsky Refactoring to Patterns
  • Gamma (Gang of Four)
  • Feather’s working effectively with legacy code

Refactoring

  • Restructuring code without changing behavior
  • Purpose of computer language is to tell other programmers what to do. The computer uses ones and zeros
  • Make it work, make it right, make it fast
  • If put it off, will never have time
  • Code smallers to remove – showed screen of examples
  • Refactor to reduce WTF/s minute rate in a code review
  • SAFe 11. 4 “refactor to support the new behavior of the code” – one of the built in quality practices
  • Do when need to change code, bug hard to fix, need to reduce tech debt, etc

Staying safe

  • Want high test coverage
  • Start small
  • Proceed incrementally
  • Test after each change. Undo last change if fails
  • Use tools like Veracode and Sonar to find code that needs changing

Simple Example

  • Need to add a flag.
  • Introduce Parameter from Fowler.
  • Showed how adding another flag is trivial

Planning a refactoring

  • Think about like planning a trip.
  • Decide trip is necessary – overcome inertia
  • Scratch refactoring from Feathers – do a refactoring to get familiar with code and revert when done. Helps figure out what to do, Think of as “exploratory refactoring”
  • Select a destination – Understand what would like it to look like
  • High level refactoring plan
  • Refining the route – more details
  • Make it so

Example

  • Showed method with two parameters – a dto and interfaces
  • Showed Template Method Pattern
  • Plan make a base class, turn implementations into subclasses, remove interfaces and stop parameter passing
  • Refine plan: map to concrete steps like drop the interface and stop using the interface. 13 steps to do the four higher level steps

My take

The intro felt very long. Would have been nice to see if audience needed an intro to refactoring. First example at 20 minute mark (for the Fowler example) and 23 minute mark for first mention of planning for large refactorings. I was speaking after and left early to get ready. So I suspect I missed some of the best parts. I was expecting more of it to be about patterns. The part I saw was too easy for me.