Printer Friendly
The Free Library
19,595,259 articles and books
Member login
User name  
Password 
 
Join us Forgot password?

Code folding--a solution looking for a problem.


Years ago, when I was programming in GFA Basic GFA BASIC is a dialect of the BASIC programming language, by Frank Ostrowski. The first version was completed in 1986. In the mid and late 80's, it proved very popular for the Atari ST homecomputer range (since the ST BASIC shipped with them turned out to be pretty useless).  on my untrusty old Atari ST (computer) Atari ST - A personal computer released by Atari in 1985. The "ST" stands for "Sixteen/Thirty-two", from the Motorola 68000's 16-bit external bus and 32-bit processor.  (GFA Basic was one of the 'modern" BASICs that *gasp* didn't use line numbers, and seemed more like Pascal), I used to love the editor's code folding Code folding is a feature of some text editors, source code editors and IDEs that allows the user to selectively hide and display sections of a currently-edited file as a part of routine edit operations.  ability. Sometimes my procedural programs would get very large, so code folding was a great way to hide away the method bodies and just see a program as a series of high- level "DoThis, DoThat" statements. I'd never seen anything quite like it, and haven't seen the same ability since, until in recent IDE releases for both Java and .Net. The thing is, looking at code folding now, I find it annoying at best. So, naturally, I avoid it. Why the change of heart?

Code folding back in the Atari ST/GFA Basic days was a godsend god·send  
n.
Something wanted or needed that comes or happens unexpectedly.



[Alteration of Middle English goddes sand, God's message : goddes, genitive of God, God
 because BASIC didn't have even a hint of any object-oriented constructs. So I couldn't break code into different classes, encapsulate en·cap·su·late
v.
1. To form a capsule or sheath around.

2. To become encapsulated.



en·cap
 away the details and just operate on the interfaces. Code folding allowed me to break the code down in a different way, so that I could see the wood for the trees.

What I only realised afterwards af·ter·ward   also af·ter·wards
adv.
At a later time; subsequently.


afterwards or afterward
Adverb

later [Old English æfterweard]

Adv. 1.
 was that code folding was encouraging me to write bigger and bigger methods, and not bother to break them up into smaller bite-sized methods. The result was that I too often ended up with "write-once-maintain-never" programs with big monolithic methods. Code folding has begun to reappear reappear
Verb

to come back into view

reappearance n

Verb 1. reappear - appear again; "The sores reappeared on her body"; "Her husband reappeared after having left her years ago"
 in modern IDEs--Visual Studio, .Net, Eclipse, and now NetBeans 3.6. This is odd, because the problems that code folding originally addressed have since been eradicated in other, much neater, less transient ways--namely, object-oriented design Transforming an object-oriented model into the specifications required to create the system. Moving from object-oriented analysis to object-oriented design is accomplished by expanding the model into more and more detail. .

If you're staring at your program and can't see the wood for the trees, code folding is the wrong answer. The answer is to structure your program better; encapsulate the details into different classes, use interfaces, small methods, and so on. The other thing about code folding is that you end up wasting a lot of time folding methods, unfolding them, when this isn't really getting you anywhere. It feels like you're doing work because you're actively clicking away; but you're not actually making any progress. It's like trying to rearrange re·ar·range  
tr.v. re·ar·ranged, re·ar·rang·ing, re·ar·rang·es
To change the arrangement of.



re
 the contents of a cupboard by constantly opening and closing the cupboard doors.

So if code folding can promote bad coding habits (even at a subconscious subconscious: see unconscious.  level), should it be included? It's a bit like reinstating the goto statement. Plenty of people love "goto" and insist that it never made them write badly structured code, but still....?..

One area where code folding is useful is in hiding Adv. 1. in hiding - quietly in concealment; "he lay doggo"
doggo, out of sight
 Javadoc. Whether you're writing an API (Application Programming Interface) A language and message format used by an application program to communicate with the operating system or some other control program such as a database management system (DBMS) or communications protocol.  that needs pages of Javadoc above each class and method, or using XDoclet which makes heavy use of Javadoc tags, it can be useful to just hide all this stuff away.

Another area is, of course, when looking at someone else's code. If there's a bad coder on your team, you might want to use code folding to cut their big monolithic classes down to size while trying to work out what the hell the code is doing. Thinking long-term though, this is propagating the problem. If you're working in a team it might become easier to just fold their code away (sweep it under the carpet) than to tackle the issue head-on, i.e. that someone sitting next to you is putting badly written code into the project. So the problem propagates because there's a "quick & easy" short-term fix. A hack, even.!

Technote

Null values A value in a field or variable that indicates nothing was ever derived and stored in it. For example, in a decimal-based amount field, a null value might be all binary 0s (null characters), but not a decimal 0.  in Database Systems

The nullability of a column determines if the rows in the table can contain a null value for that column. A null value, or NULL, is not the same as zero (0), blank, or a zero-length character string such as...."; NULL means that no entry has been made.

A value of NULL indicates the value is unknown. A value of NULL is different from an empty or zero value. No two null values are equal. Comparisons between two null values, or between a NULL and any other value, return unknown because the value of each NULL is unknown. In general, avoid permitting null values because they incur more complexity in queries and updates and because there are other column options, such as PRIMARY KEY constraints, that cannot be used with nullable columns. If it is possible that null values may be stored in your data, it is a good idea to create queries and data-modification statements that either eliminate NULLs or transform NULLs into some other value (if you do not want null values appearing in your data).

If a row is inserted but no value is included for a column that allows null values, the database engine supplies the value NULL (unless a DEFAULT definition or object exists). A column defined with the keyword NULL also accepts an explicit entry of NULL from the user, no matter what data type it is, or if it has a default associated with it. The value NULL should not be placed within quotation marks quotation marks
Noun, pl

the punctuation marks used to begin and end a quotation, either `` and '' or ` and '

quotation marks nplcomillas fpl

 because it will be interpreted as the character string 'NULL', rather than the null value.

Specifying a column as not permitting null values can help maintain data integrity by ensuring that a column in a row always contains data. If null values are not allowed, the user entering data in the table must enter a value in the column or the table row cannot be accepted into the database. Note: Columns defined with a PRIMARY KEY constraint or IDENTITY property cannot allow null values.
COPYRIGHT 2005 A.P. Publications Ltd.
No portion of this article can be reproduced without the express written permission from the copyright holder.
Copyright 2005, Gale Group. All rights reserved. Gale Group is a Thomson Corporation Company.

 Reader Opinion

Title:

Comment:



 

Article Details
Printer friendly Cite/link Email Feedback
Title Annotation:DATABASE INTELLIGENCE
Author:Stevens, Matt
Publication:Database and Network Journal
Geographic Code:1USA
Date:Feb 1, 2005
Words:926
Previous Article:Eliminating the uncertainty of IT projects.
Next Article:What are Mock Objects?
Topics:



Related Articles
FAULTY SQL CODE CAN CAUSE DATABASE PERFORMANCE PROBLEMS.
IBM WORKS WITH VA SOFTWARE TO PROVIDE LINUX BASED SOLUTIONS.
Data integrity guidelines: what they are and why you need them. (Tech Tool Kit).
Cognos licenses database drivers from DataDirect Technologies.
MAXM Database Advisor for IMS.
TERATEXT UNVIELS COMBINATION TEXT DATABASE AND SEARCH ENGINE.
GENOME TEST ENABLES RECONSTRUCTION OF PHYSICAL PROFILE.
Army trying to get better grasp on war zone intelligence.
SAS sets new standards on 64-bit BI support.
Kamatoz.Computing announces PassMonster 2.25.

Terms of use | Copyright © 2012 Farlex, Inc. | Feedback | For webmasters | Submit articles