Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Code folding
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Hiding boilerplate code=== Some languages or libraries require extensive [[boilerplate code]]. This results in extremely long code, which can obscure the main point. Further, substantive code can be lost in the boilerplate. For example, in Java a single private field with a getter and setter requires at least 3 lines, if each is on a separate line: <syntaxhighlight lang=java> private String name = null; public String getName() { return name; } public void setName(String name) { this.name = name; } </syntaxhighlight> This expands to 10 lines with conventional function line breaks and spacing between functions (including trailing newline): <syntaxhighlight lang=java> private String name = null; public String getName() { return name; } public void setName(String name) { this.name = name; } </syntaxhighlight> Documentation with Javadoc expands this to 20 lines: <syntaxhighlight lang=java> /** * Property <code>name</code> readable/writable. */ private String name = null; /** * Getter for property <code>name</code> */ public String getName() { return name; } /** * Setter for property <code>name</code>. * @param name */ public void setName(String name) { this.name = name; } </syntaxhighlight> If there are many such fields, the result can easily be hundreds of lines of code with very little "interesting" content β code folding can reduce this to a single line per field, or even to a single line for all fields. Further, if all routine fields are folded, but non-routine fields (where getter or setter is not just returning or assigning a private field) are not folded, it becomes easier to see the substantive code.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)