# Readability of formatted code

**URL:** <https://forums.toadworld.com/t/readability-of-formatted-code/39996>\
**Category:** Toad for Oracle - Beta\
**Created:** [September 15, 2017, 3:31am UTC](https://forums.toadworld.com/t/readability-of-formatted-code/39996 "2017-09-15T03:31:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![kornelis.abe](https://avatars.discourse-cdn.com/v4/letter/k/59ef9b/32.png) [@kornelis.abe](https://forums.toadworld.com/u/kornelis.abe)\
**Post date:** [September 15, 2017, 3:31am UTC](https://forums.toadworld.com/t/readability-of-formatted-code/39996/1 "2017-09-15T03:31:31Z")

</div>

All,

A simple question of readability and maintainability of code.  
This is an example of a call to our exception handler as formatted in 12.11 and up with Dynamic arrangement:  
exception  
when others  
then – log the error and re-raise exception to inform caller  
utl\_krg.msg\_log.standard\_exception\_handler(  
p\_schema =\>  
g\_my\_schema  
, p\_package =\>  
g\_my\_package  
, p\_routine =\>  
l\_my\_routine  
, p\_action =\>  
l\_action  
, p\_msg\_code =\>  
sqlcode  
, p\_local\_msg\_prefix =\>  
g\_my\_msg\_prefix  
, p\_message =\>  
'On ’  
|| ora\_database\_name  
|| ‘: ’  
|| sqlerrm  
|| ’ - p\_item\_name=’  
|| coalesce(p\_item\_name, ‘\<\*Null\>’)  
|| ‘, p\_item\_key=’  
|| coalesce(p\_item\_key, ‘\<\*Null\>’)  
|| ‘, p\_timestamp=’  
|| coalesce(trim(to\_char(p\_timestamp, ‘yyyy-mm-dd hh24:mi:ss.ff’)), ‘\<\*Null\>’)  
, p\_row\_count =\>  
l\_row\_count  
);

The same code by the 12.10 formatter:  
exception  
when others  
then – log the error and re-raise exception to inform caller  
utl\_krg.msg\_log.standard\_exception\_handler(  
p\_schema =\> g\_my\_schema  
, p\_package =\> g\_my\_package  
, p\_routine =\> l\_my\_routine  
, p\_action =\> l\_action  
, p\_msg\_code =\> sqlcode  
, p\_local\_msg\_prefix =\> g\_my\_msg\_prefix  
, p\_message =\> 'On ’  
|| ora\_database\_name  
|| ‘: ’  
|| sqlerrm  
|| ’ - p\_item\_name=’  
|| coalesce(p\_item\_name, ‘\<\*Null\>’)  
|| ‘, p\_item\_key=’  
|| coalesce(p\_item\_key, ‘\<\*Null\>’)  
|| ‘, p\_timestamp=’  
|| coalesce(trim(to\_char(p\_timestamp, ‘yyyy-mm-dd hh24:mi:ss.ff’)), ‘\<\*Null\>’)  
, p\_row\_count =\> l\_row\_count  
);

The latter is - at least to my mind and eyes - much better readable.

1. is has a clear distinction between parmnames area and parmvalues area
2. is uses far fewer lines, which helps in maintaining a view of the statement within its context. (screens are always too small)

My issue with the new formatter is not that it uses parmname area for holding parmvalues when a parameter value specification is very long, but I do object to reusing the parmname area for _all_ parmvalues as soon as any one of them uses it. It causes visual clutter on the left-hand side, leaves available space at the right-hand side unused and unnecessarily stretches the block of code vertically.

Just my opinion. Please be invited to share your thoughts.

# Kind regards, Abe Kornelis

---

<div class="post-metadata">

**Author:** ![avergison](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/avergison/32/66_2.png) [@avergison](https://forums.toadworld.com/u/avergison)\
**Post date:** [September 15, 2017, 7:22am UTC](https://forums.toadworld.com/t/readability-of-formatted-code/39996/2 "2017-09-15T07:22:11Z")

</div>

Hello Abe,

I fully agree with you. Latest formatter doesn’t seem to listen to the Parameter settings, so this looks like a bug. I’ll look into this asap.

Thanks,  
Andre

---

<div class="post-metadata">

**Author:** ![avergison](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/avergison/32/66_2.png) [@avergison](https://forums.toadworld.com/u/avergison)\
**Post date:** [September 15, 2017, 12:19pm UTC](https://forums.toadworld.com/t/readability-of-formatted-code/39996/3 "2017-09-15T12:19:57Z")

</div>

Abe,

Actually it turns out that the overly long p\_message parameter puts the whole parameter list in “wrapped” mode, and none of the parameter settings don’t work anymore.

How about doing that wrapping for only those parameters which exceed the right margin? In your code below I added a copy of a few parameters after the p\_message, to better illustrate the effect:

exception  
when others  
then – log the error and re-raise exception to inform caller  
utl\_krg.msg\_log.standard\_exception\_handler (  
p\_schema =\> g\_my\_schema,  
p\_package =\> g\_my\_package,  
p\_routine =\> l\_my\_routine,  
p\_action =\> l\_action,  
p\_msg\_code =\> SQLCODE,  
p\_local\_msg\_prefix =\> g\_my\_msg\_prefix,  
p\_row\_count =\> l\_row\_count,  
p\_message =\>  
'On ’  
|| ora\_database\_name  
|| ‘: ’  
|| SQLERRM  
|| ’ - p\_item\_name=’  
|| COALESCE (p\_item\_name, ‘\<\*Null\>’)  
|| ‘, p\_item\_key=’  
|| COALESCE (p\_item\_key, ‘\<\*Null\>’)  
|| ‘, p\_timestamp=’  
|| COALESCE (  
TRIM (TO\_CHAR (p\_timestamp, ‘yyyy-mm-dd hh24:mi:ss.ff’)),  
‘\<\*Null\>’),  
p\_action2 =\> l\_action,  
p\_msg\_code2 =\> SQLCODE,  
p\_local\_msg\_prefix2 =\> g\_my\_msg\_prefix);  
end;

Andre

---

<div class="post-metadata">

**Author:** ![kornelis.abe](https://avatars.discourse-cdn.com/v4/letter/k/59ef9b/32.png) [@kornelis.abe](https://forums.toadworld.com/u/kornelis.abe)\
**Post date:** [September 17, 2017, 10:41pm UTC](https://forums.toadworld.com/t/readability-of-formatted-code/39996/4 "2017-09-17T22:41:11Z")

</div>

Andre,

that would be Great!

# Thanks in advance, Abe

---

<div class="post-metadata">

**Author:** ![avergison](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/avergison/32/66_2.png) [@avergison](https://forums.toadworld.com/u/avergison)\
**Post date:** [September 22, 2017, 12:13pm UTC](https://forums.toadworld.com/t/readability-of-formatted-code/39996/5 "2017-09-22T12:13:06Z")

</div>

(this also answers everything in:

- [https://www.toadworld.com/products/toad-for-oracle/toad\_for\_oracle\_beta\_program/f/86/t/32152](https://www.toadworld.com/products/toad-for-oracle/toad_for_oracle_beta_program/f/86/t/32152)
- [http://www.toadworld.com/products/toad-for-oracle/toad\_for\_oracle\_beta\_program/f/86/p/32500/65617#65617](http://www.toadworld.com/products/toad-for-oracle/toad_for_oracle_beta_program/f/86/p/32500/65617#65617)
- [http://www.toadworld.com/products/toad-for-oracle/toad\_for\_oracle\_beta\_program/f/86/t/32604](http://www.toadworld.com/products/toad-for-oracle/toad_for_oracle_beta_program/f/86/t/32604) )

QP-2344

For now no extra formatter option, just a change in behavior described above in this thread. This will appear in QP5 version 5.319 next week.

I attached a small video showing output while decreasing the margin from around 250 down to about 60. You can see how the code starts folding as the margin narrows. Sorry the actual margin is not shown, but the video should give an idea. You may want to select resolution 720 to read text.

Thanks,  
Andre

---

<div class="post-metadata">

**Author:** ![avergison](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/avergison/32/66_2.png) [@avergison](https://forums.toadworld.com/u/avergison)\
**Post date:** [September 22, 2017, 12:35pm UTC](https://forums.toadworld.com/t/readability-of-formatted-code/39996/6 "2017-09-22T12:35:06Z")

</div>

Link embedding (for video) may not work, so here’s the link:

[www.youtube.com/watch](https://www.youtube.com/watch?v=l6B1oaWQbLM)

---

<div class="post-metadata">

**Author:** ![kornelis.abe](https://avatars.discourse-cdn.com/v4/letter/k/59ef9b/32.png) [@kornelis.abe](https://forums.toadworld.com/u/kornelis.abe)\
**Post date:** [September 24, 2017, 10:50pm UTC](https://forums.toadworld.com/t/readability-of-formatted-code/39996/7 "2017-09-24T22:50:37Z")

</div>

Andre,

thanks for the video.  
Looks good to me.

# Kind regards, Abe

---

<div class="post-metadata">

**Author:** ![avergison](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/avergison/32/66_2.png) [@avergison](https://forums.toadworld.com/u/avergison)\
**Post date:** [September 28, 2017, 2:51pm UTC](https://forums.toadworld.com/t/readability-of-formatted-code/39996/8 "2017-09-28T14:51:49Z")

</div>

Fixed in component QP5 version 5.319.
