Caleb Cushing's Blog Also known as XenoTerraCide
Posts with the tag perl:

Moose Interface Pattern with parameter enforcement

Moose interfaces are problematic, for 2 reasons. They are compile time, but runtime features such as attribute delegation could provide the interface (role ordering is the real problem here) They don’t ensure anything other than the method name. I think this problem can be solved better by using around instead of requires 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 package Interface::Create; use Moose::Role; use Type::Params qw( compile ); use Types::Standard qw( slurpy HashRef); around create => sub { my $orig = shift; my $self = shift; state $check = compile( slurpy HashRef ); my ( $obj_args ) = $check->( @_ ); return $self->$orig( $obj_args ); }; 1; Ordering of course still matters here as you can have multiple around modifiers on a method.

Inversion of Control Principle

If you’re not familiar with the term “Inversion of Control”( IoC ) or “Dependency Injection” ( DI )you may wish to start with Martin Fowler’s post on the subject. If you’re looking for a way to do it with Perl, Bread::Board is the way to go. This post however is about the theory behind it, and a path to grokitude if you’re finding the concepts challenging. I should advise that I am not yet a buddha on implementation.

Business::CyberSource API is stabilizing as of 0.7.x

Interface Driven Design

What is Interface Driven Design? Interface Driven Design simply means that you should design your software around a flexible, easy to use, easy to understand interface. This is easy to achieve if your objects are of SOLID design. There is a simple table and reference link if you’re not familiar with the principles. My Work is SOLID already Then you’re on the right track but it’s not enough if you don’t fully marry the concept to best practices.

Where's 5.16.1?

Per the 5.12 release announcement This release cycle marks a change to a time-based release process. Beginning with version 5.11.0, we make a new development release of Perl available on the 20th of each month. Each spring, we will release a new stable version of Perl. One month later, we will make a minor update to deal with any issues discovered after the initial “.0” release. Future releases in the stable series will follow quarterly.

Perl Core Syntax Wishlist: Role Support

I want to see Role’s added, even PHP got Traits before Perl. It doesn’t have to be a huge thing, in fact all I want is the composition aspect. Let me do this: 1 2 3 4 5 6 7 8 9 package MyRole { sub foo { return 'test' } } package MyClass { with 'MyRole'; ... } MyClass->new->foo; I don’t really want or need anything else right now, just that would be fine.

New Module: MooseX::RemoteHelper (RFC)

Perl Core Syntax Wishlist: Class support

I would like to see the classkeyword become part of Perl, but unlike some I don’t want it simply because it’s nicer syntax. I’d like it to behave differently from package. I’d basically like to see this class MyClass {method foo { return $self->{foo} }method info { return load_class(‘Class::Info’)->new }}to be the equivalent of {use strict;use warnings;use utf8; # so our class can be named with utf8package MyClass {use namespace::autoclean;use Scalar::Util qw( blessed );# use Class::Load qw( load_class );# or similar for a feature that I’m hoping will be in Class::Load in the future# for now I’ll show with requiresub new { # or something better, point is that there’s a default simple constructormy $class = shift;my $self = ref $[0] eq ‘HASH’ ?

Better Exceptions with Exception::Base

So I’ve done some complaining and explaining about what I’d like to see in regards to Exceptions in Perl. I Mostly explained what I wanted for catching Exceptions, and a little on throwing Exception objects, but not really how those objects should behave. I’ve looked at and tried various exception modules, including croak, confess, and Throwable. I basically spent time one day reading the manuals of most of the exception objects on CPAN.

Perl Core Syntax Wishlist: die should die

I hate die it is, in my humble opinion, one of the worst parts of perl. I really wish it would be deprecated, and removed, or at least replaced with something that would tell you were the code that was die-ing was being called. Replace its implementation with that of Carp’s croak or confess and I’d be happy. Better yet, let’s just get real exception support and deprecate die (even if that’s never removed deprecation just make that real big on its pod).