Feedback wanted: Code formatting and usages of fluent interfaces APIs

I just opened up a new feature request http://www.jetbrains.net/jira/browse/IDEA-14088 with the title: "Make it possible to disable code formatting rules for usages of fluent interface APIs (such as JMock)"

I would like to get everybody's opinion on the subject.

Do you have experiences about using a fluent API and how did you manage code formatting? What would be the best way to continue using IDEA's automatic code formatting for other parts of the code, without messing up the manually formatted code? Could this be accomplished with external annotations, as I proposed in my feature request?

2 comments
Comment actions Permalink

I've had similar experiences with some home-brewed fluent interfaces, and it is frustrating. I feel it's probably better to annotate the call site as "do not reformat" rather than the API. Less chance for the API user to be badly surprised ("What do you mean that damn library designer turned off my formatting!!!!"). A pair of magic "disable reformatting" and "reenable reformatting" comments would be pretty handy in those situations.

--Dave Griffith

0
Comment actions Permalink

"What do you mean that damn library designer turned off my
formatting!!!!"


True, true. An annotation might be too dangerous, unless it could be forced to work only as an external annotation. What if the configuration would be in the project or developer level, maybe in the same place where IDEA's code style settings are?

I don't like having to put annotation or other markers on the call side. You would need to repeat it everywhere the API is used, which violates the DRY principle and adds unnecessary clutter all over the code.

0

Please sign in to leave a comment.