Headline

Moops stands for "Moops Object Oriented Programming Sugar". Helps make OO programming in Language:Perl easier and more concise by adding Syntactic sugar and reducing Boilerplate code.

Illustration

A class written in pure 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};
    }
}

The same functionality written with the help of Moops:

use Moops;

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

Ralf Lämmel edited this article at Wed, 03 May 2017 23:06:14 +0200
Compare revisions Compare revisions

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.