Skip to topic
|
Skip to bottom
Jump:
TModeling
TModeling Web
TModeling Web Home
Changes
Notify
Index
Search
Webs
BioGeometry
Main
TModeling
TWiki
Edit
Attach
Printable
TModeling.BadExample
r1.1 - 16 Jun 2008 - 04:11 - Main.guest
topic end
Start of topic |
Skip to actions
*Bad Example* --- Here is an example of bad style written in Java <verbatim> for(i=2;i<=num;i++){ meetsCriteria[i]=true; } for(i=-2;i<=num/2;i++){ j=i+i; while(j<=num){ meetsCriteria[j]=false; j=j+1; } } for(i=1;i<=num;i++){ if(meetsCriteria[i]){ System.out.println(i+" meets criteria." ); } } </verbatim> *Problems:* * The lack of white space makes it hard to read * The lack of indentation makes it hard to infer logical structure * The lack of good variable names makes it hard to figure out what the code does * The too generic array name _meetsCriteria_ could be anything * In short, it's hard to figure out the purpose of this snippet of code -- Main.ShawnDB - 16 Jun 2008
to top
End of topic
Skip to action links
|
Back to top
Edit
|
Attach image or document
|
Printable version
|
Raw text
|
More topic actions
Revisions: | r1.1
|
Total page history
|
Backlinks
You are here:
TModeling
>
BadExample
to top
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback