FANDOM


A document is a file of some sort that cantains a collection of information. It can exist as an HTML, Word, Plain text, or an oodle of other file types.

Document (verb) Edit

To document something in perl, you usually add a #comment that explains what you just did with your code like this:

@Months30=('Apr','Jun','Sep','Nov');
#30 day months

The text after the # is commented out and ignored by the perl interpretor, but you've explained to others looking at your code that @Months30 represents the months that have thirty days.

Sample code and documentation Edit

You can similarly document a block of code like:

if ($leapyear) {$MonthDaysFeb=29}
else {$MonthDaysFeb=28}

@Months30=('Apr','Jun','Sep','Nov');
@Months=('Jan'..'Dec');

foreach $month (@Months) {
 chomp $month;
  unless ($month=='Feb') {
   unless (@Month30) {
    %MonthDays=($month=>(1..31)}
   else %MonthDays=($month=>(1..30)}
  else %MonthDays=($month=>(1..28)}
 %Year=(@Months=>%MonthDays)}

Now the coder can explain at least what he or she is trying to do with some plain old documentation called pod text which appears to humans reading the code bit not to the compiler:

=pod

 The code above is for putting
 together a calendar year with 
 three-letter $month names and
 a hash for the numbered days of
 each month, allowing for leap
 year 'Feb's and @Months30,
 which have only 30 days.

 %Year should now contain all
 365 or 366 days placed within
 their respective @Months.

 I don't know if this is the
 right way to do it or not but,
 hey. I'm trying!

=cut

Why document your code? Edit

Failing to document your code is somewhere between ignorant naivety and lazy arrogance. Learning to document code is as important as learning to write and debug it. In software development, documentation starts at even the most primative levels.

Expert coders who document their code in a thoughtful manner, stand a better chance of getting quality feedback from their less-experienced peers. By the same token, novice coders stand a better chance of getting help from the experts if they put forth an effort to explain what they are attempting.

Document types Edit

DOCTYPE

Documentation Edit

See Category:Documentation

Master Documents Edit

See Category:Master documents

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.