Headline

Code that need to be repeated in many places with virtually no modifications, to the point where its creation can be automated.

Illustration

As an example, take writing a class in Language:Perl:

package Company; # class declaration
use strict;
use warnings;

# constructor needs to be written manually
sub new {
    my $class = shift;
    # creating hash with default arguments
    my $mess  = {
        children => [],
        @_
    };
    # checking for required arguments
    die 'No name given' if not $mess->{name};
    # creating an object
    return bless $mess => $class;
}

# accessors need to be written manually
sub name {
    my ($self, $new_name) = @_;
    if ($new_name) {
        return $self->{name} = $new_name;
    } else {
        return $self->{name};
    }
}

sub children {
    my ($self, $new_children) = @_;
    if ($new_children) {
        return $self->{children} = $new_children;
    } else {
        return $self->{children};
    }
}

Since no sane person would do this for every class and every accessor, there are ways to automate this process. In fact, the system is designed to be automated.

For example, using Technology:Moops:

use Moops;

class Company {
    has 'name'     => (is => 'rw', required => 1         );
    has 'children' => (is => 'rw', default  => sub { [] });
}

These few lines remove the need of all the boilerplate seen above.


There are no revisions for this page.

User contributions

    This user never has never made submissions.

    User edits

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.