Caleb Cushing's Blog

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 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. Read more →

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. Read more →

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

Business::CyberSource (BC) has been going through API changes for a while now. If you’re using it you’ve probably noticed this and wondered why? The reason behind it was when I first made it I wanted it to be extremely simple to use, and I was realistically a Junior programmer. Over the past year I learned a lot about API design and Object Oriented Programming, as well as payment gateways and credit card transaction processing. Read more →

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. Read more →

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. Read more →

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: 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. We should have interfaces too, but they aren’t really required just to support Role’s. Read more →

New Module: MooseX::RemoteHelper (RFC)

BackgroundI have spent much of the last year writing and refining Remote Facades. At this point I’ve worked with SOAP, REST/JSON, and RPC url-form-encoded API’s. One of the hardest parts I’ve found is dealing with the serialization of a Data Transfer Object with a Perl interface into whatever the remote is expecting. When I started I didn’t know of these patterns, or really anything about these patterns. I highly recommend reading Patterns of Enterprise Application Architecture) if you want to know more about these patterns or things like Active Record and MVC. Read more →

Perl Core Syntax Wishlist: Class support

I would like to see the class keyword 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 utf8 Read more →

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. Read more →

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). Read more →