SlideShare una empresa de Scribd logo
1 de 14
Code
Documentation
Adegoke Obasa
Programs must be written for people
to read, and for machines to
execute.
Why Comment
- They are part of programming
Python - #, C# - // /** */, Lisp - ;;
- Helps explain what unintuitive part of code is
doing.
- Code tells you what, comments tells why.
??
public class FriendlyApp {
public static void main(String[] args) {
String name = "";
if (args.length > 0) {
name = args[0];
}
/* print hello on the screen. */
System.out.println("Hello " + name);
}
}
When to
- When doing processing
- API Documentation
- To Track Changes
- To Tag
This is better
/* sort the bucket in ascending order. */
while (true) {
while ((bucket[++leftPtr] < bucket[pivot]));
while ((bucket[--rightPtr] > bucket[pivot])
&& (rightPtr > leftPtr));
if (leftPtr < rightPtr) {
/* swap pair found. */
swap(bucket, leftPtr, rightPtr);
} else {
/* no more swap pairs. partition complete. */
swap(bucket, leftPtr, pivot);
break;
}...
Using Keywords
- //TODO:
- //FIXME:
- //XXX:
- You can add custom more.
Using Keywords
public class TechTalks {
public void sayHello(){
//TODO: Print Hello
}
}
Bad Comments
/* This code will get the anagrams of "word".
* To find the anagrams of the word, we have to convert it to lowercase and get rid of
* all trailing whitespaces - this is the format in which we use to store the words
* in the dictionary. We also need to sort
* the characters of the word because we use the sorted characters as a key for the
* anagrams set (All anagrams of a word and the word appear the same when the
* characters have been sorted.) We also
* remove the word from the anagrams set because we do not want it being returned
* with the set as an anagram of itself.
*/
public Set getAnagrams(String word) {
}
Commented Code
public static void main(String[] args) throws IOException
{
// while (c != -1) {
// System.out.print((char) c);
// c = in.read();
// }
System.out.println(“Tech Talks”);
}
API Documentation
- Not Just REST APIs
- PHPDoc, javadoc etc.
- Use Standard Templates
Q & A
Further Reading
http://blog.codinghorror.com/code-tells-you-
how-comments-tell-you-why/
..on Software
<http://bodtoki.blogspot.com/2011/02/3-good-
comments-good-code-series.html>
Thanks :D
Adegoke Obasa
@goke_epapa

Más contenido relacionado

La actualidad más candente

WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD? WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD? reactima
 
Autotools
Autotools Autotools
Autotools easychen
 
Voxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with JavassistVoxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with JavassistAnton Arhipov
 
PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13julien pauli
 
Ida python intro
Ida python introIda python intro
Ida python intro小静 安
 
NYPHP March 2009 Presentation
NYPHP March 2009 PresentationNYPHP March 2009 Presentation
NYPHP March 2009 Presentationbrian_dailey
 
Codegeneration With Xtend
Codegeneration With XtendCodegeneration With Xtend
Codegeneration With XtendSven Efftinge
 
RubyConf Bangladesh 2017 - Craft beautiful code with Ruby DSL
RubyConf Bangladesh 2017 - Craft beautiful code with Ruby DSLRubyConf Bangladesh 2017 - Craft beautiful code with Ruby DSL
RubyConf Bangladesh 2017 - Craft beautiful code with Ruby DSLRuby Bangladesh
 
Testing JS with Jasmine
Testing JS with JasmineTesting JS with Jasmine
Testing JS with JasmineEvgeny Gurin
 
Preparing for the next PHP version (5.6)
Preparing for the next PHP version (5.6)Preparing for the next PHP version (5.6)
Preparing for the next PHP version (5.6)Damien Seguy
 
Create a web-app with Cgi Appplication
Create a web-app with Cgi AppplicationCreate a web-app with Cgi Appplication
Create a web-app with Cgi Appplicationolegmmiller
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to JavascriptAmit Tyagi
 
Hack in the Box Keynote 2006
Hack in the Box Keynote 2006Hack in the Box Keynote 2006
Hack in the Box Keynote 2006Mark Curphey
 

La actualidad más candente (20)

WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD? WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
 
AutoComplete
AutoCompleteAutoComplete
AutoComplete
 
PHP 7
PHP 7PHP 7
PHP 7
 
Autotools
Autotools Autotools
Autotools
 
Voxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with JavassistVoxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with Javassist
 
PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13
 
Ida python intro
Ida python introIda python intro
Ida python intro
 
NYPHP March 2009 Presentation
NYPHP March 2009 PresentationNYPHP March 2009 Presentation
NYPHP March 2009 Presentation
 
Codegeneration With Xtend
Codegeneration With XtendCodegeneration With Xtend
Codegeneration With Xtend
 
PL/SQL Unit Testing Can Be Fun!
PL/SQL Unit Testing Can Be Fun!PL/SQL Unit Testing Can Be Fun!
PL/SQL Unit Testing Can Be Fun!
 
Jasmine BDD for Javascript
Jasmine BDD for JavascriptJasmine BDD for Javascript
Jasmine BDD for Javascript
 
RubyConf Bangladesh 2017 - Craft beautiful code with Ruby DSL
RubyConf Bangladesh 2017 - Craft beautiful code with Ruby DSLRubyConf Bangladesh 2017 - Craft beautiful code with Ruby DSL
RubyConf Bangladesh 2017 - Craft beautiful code with Ruby DSL
 
Testing JS with Jasmine
Testing JS with JasmineTesting JS with Jasmine
Testing JS with Jasmine
 
Nevermore Unit Testing
Nevermore Unit TestingNevermore Unit Testing
Nevermore Unit Testing
 
Preparing for the next PHP version (5.6)
Preparing for the next PHP version (5.6)Preparing for the next PHP version (5.6)
Preparing for the next PHP version (5.6)
 
Create a web-app with Cgi Appplication
Create a web-app with Cgi AppplicationCreate a web-app with Cgi Appplication
Create a web-app with Cgi Appplication
 
Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
Hack in the Box Keynote 2006
Hack in the Box Keynote 2006Hack in the Box Keynote 2006
Hack in the Box Keynote 2006
 
Basics of ANT
Basics of ANTBasics of ANT
Basics of ANT
 

Similar a Code documentation

AWS Hadoop and PIG and overview
AWS Hadoop and PIG and overviewAWS Hadoop and PIG and overview
AWS Hadoop and PIG and overviewDan Morrill
 
Domain Specific Languages In Scala Duse3
Domain Specific Languages In Scala Duse3Domain Specific Languages In Scala Duse3
Domain Specific Languages In Scala Duse3Peter Maas
 
JCConf 2022 - New Features in Java 18 & 19
JCConf 2022 - New Features in Java 18 & 19JCConf 2022 - New Features in Java 18 & 19
JCConf 2022 - New Features in Java 18 & 19Joseph Kuo
 
Aspect-oriented programming in Perl
Aspect-oriented programming in PerlAspect-oriented programming in Perl
Aspect-oriented programming in Perlmegakott
 
Coding standards for java
Coding standards for javaCoding standards for java
Coding standards for javamaheshm1206
 
Boston Computing Review - Java Server Pages
Boston Computing Review - Java Server PagesBoston Computing Review - Java Server Pages
Boston Computing Review - Java Server PagesJohn Brunswick
 
Introduction To Ant
Introduction To AntIntroduction To Ant
Introduction To AntRajesh Kumar
 
Internet Technology and its Applications
Internet Technology and its ApplicationsInternet Technology and its Applications
Internet Technology and its Applicationsamichoksi
 
Xml Java
Xml JavaXml Java
Xml Javacbee48
 
Don't Be Afraid of Abstract Syntax Trees
Don't Be Afraid of Abstract Syntax TreesDon't Be Afraid of Abstract Syntax Trees
Don't Be Afraid of Abstract Syntax TreesJamund Ferguson
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Guillaume Laforge
 
NyaruDBにゃるものを使ってみた話 (+Realm比較)
NyaruDBにゃるものを使ってみた話 (+Realm比較)NyaruDBにゃるものを使ってみた話 (+Realm比較)
NyaruDBにゃるものを使ってみた話 (+Realm比較)Masaki Oshikawa
 
How Xslate Works
How Xslate WorksHow Xslate Works
How Xslate WorksGoro Fuji
 

Similar a Code documentation (20)

Sax Dom Tutorial
Sax Dom TutorialSax Dom Tutorial
Sax Dom Tutorial
 
Processing XML with Java
Processing XML with JavaProcessing XML with Java
Processing XML with Java
 
AWS Hadoop and PIG and overview
AWS Hadoop and PIG and overviewAWS Hadoop and PIG and overview
AWS Hadoop and PIG and overview
 
Domain Specific Languages In Scala Duse3
Domain Specific Languages In Scala Duse3Domain Specific Languages In Scala Duse3
Domain Specific Languages In Scala Duse3
 
JCConf 2022 - New Features in Java 18 & 19
JCConf 2022 - New Features in Java 18 & 19JCConf 2022 - New Features in Java 18 & 19
JCConf 2022 - New Features in Java 18 & 19
 
Aspect-oriented programming in Perl
Aspect-oriented programming in PerlAspect-oriented programming in Perl
Aspect-oriented programming in Perl
 
Coding standards for java
Coding standards for javaCoding standards for java
Coding standards for java
 
Demystifying Maven
Demystifying MavenDemystifying Maven
Demystifying Maven
 
I Feel Pretty
I Feel PrettyI Feel Pretty
I Feel Pretty
 
Boston Computing Review - Java Server Pages
Boston Computing Review - Java Server PagesBoston Computing Review - Java Server Pages
Boston Computing Review - Java Server Pages
 
Introduction To Ant
Introduction To AntIntroduction To Ant
Introduction To Ant
 
Internet Technology and its Applications
Internet Technology and its ApplicationsInternet Technology and its Applications
Internet Technology and its Applications
 
Xml Java
Xml JavaXml Java
Xml Java
 
Don't Be Afraid of Abstract Syntax Trees
Don't Be Afraid of Abstract Syntax TreesDon't Be Afraid of Abstract Syntax Trees
Don't Be Afraid of Abstract Syntax Trees
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008
 
NyaruDBにゃるものを使ってみた話 (+Realm比較)
NyaruDBにゃるものを使ってみた話 (+Realm比較)NyaruDBにゃるものを使ってみた話 (+Realm比較)
NyaruDBにゃるものを使ってみた話 (+Realm比較)
 
How Xslate Works
How Xslate WorksHow Xslate Works
How Xslate Works
 
Java XML Parsing
Java XML ParsingJava XML Parsing
Java XML Parsing
 
latest slide
latest slidelatest slide
latest slide
 
testing add
testing addtesting add
testing add
 

Code documentation