In the p5p discussions of Dave Rolsky's new Perl OO tutorial and OO recommendations, Johan Vromans and others have mentioned
that in good OO programming, one should not violate encapsulation by directly accessing an
objects underlying data structure.
$self->{foo} = "Look Ma! No encapsulation"; # don't do this, they say
In general that is true, but not always, We should avoid absolutist language, especially in tutorials. I'll come to an example of that.
For Nama, I generally use a setter with this syntax:
$self->set(foo => "bar");
The set method (inherited from a parent class based
on Object::Tiny) makes sure the key is a legal one.
Because it looks distinct, I'm not likely
to use it unless I want really write access to that attribute.
This simple approach allows me to manage object attributes culturally, i.e.
without specifying them as read-only or read-write.
In an app of 13k lines, the 'set' method appears just 110 times.
В следующем выпуске YAPP наших слушателей ожидает интервью с Андреем Шитовым - Perl программистом, автором perl6.ru, организатором Московской группы Perl программистов (Moscow.PM), организатором всевозможных Perl мероприятий в нашей стране и за ее пределами.
Мы поговорим с Андреем о будущем языка Perl и его шестой реинкарнация, о перспективах языка, о месте perl-программистов в обществе, о проектах Андрея, его увлечениях, обо все что покажется нам интересным. Если и у вас есть какие-то вопросы к Андрею Шитову, то отправляйте их нам и мы постараемся задать их во время нашего интервью.
Свои вопросы Вы можете писать в twitter: twitter.com/yapp_ru, по почте: yapp_ru@gmail.com, в jabber: yapp@demond.org или в комментариях к данному анонсу на blogs.perl.org по адресу: https://blogs.perl.org/users/perl_demon
The SF Perl Mongers next meeting will be on Tuesday March 22nd, at 7pm. Jonathan Swartz will be introducing Mason 2.0.
Mason is a Perl-based templating framework for generating web pages and other dynamic content. Over the past decade it has been used to generate thousands of web sites large and small, including Amazon.com, Target.com, Salon.com and del.icio.us.
Version 2.0 of Mason was released last month, twelve years after its initial incarnation. It has been rearchitected and reimplemented from the ground up, to take advantage of modern Perl techniques (Moose, Plack/PSGI) and to add long-desired features and syntax.
Jonathan Swartz, the original author of both Mason 1 and 2, will present Mason 2's new architecture and improvements and show how it fits into the modern Perl web development universe.
Having read commentary about coding practices, meditated,
contemplated, posted a blog entry about my app and begged
for constructive criticism, I found my way into a significant
refactoring.
I haven't seen much about the step-by-step
process of dividing and modularizing code.
Here how I am approching it.
The app already uses OO, but suffers from some 260 global
variables and about 6k lines of code in the main namespace.
I broke that code into about 30 different modules, testing
after creating each new module, with the help of git for
source control, and a couple scripts showing which files and
in which subs each variable appears
Most modules still occupy the same namespace,
however have access to only the minimum necessary subset of
global variables. I did this using a structure like this:
[Audio_engine_setup.pm]
package main;
our ( $sampling_frequency,.... )
sub configure_freq { say "configuring soundcard at $sampling_frequency" }
We have a non-Moose class but want to make a Moose subclass of it. In the first post, "Subclassing Tricky Non-Moose Classes: Don't Do It", we looked at a way to extend non-Moose classes without actually subclassing them. It is pretty straight-forward, and typically will cause less headaches.
Sometimes that method might not meet your needs, and you might really want to make a Moose subclass of a non-Moose class. This tutorial will get you started with a couple modules that will help you do just that: MooseX::NonMoose and MooseX::NonMoose::InsideOut.
The nitty-gritty
If you're looking to get your hands dirty and find out how this really works, your first stop should be
Recipe 11 in the Moose Cookbook. It is optional reading for our purposes, though.
It does a great job explaining how to subclass a common, blessed hash, non-Moose class "by hand," and points us to MooseX::NonMoose which handles those details for us.
I also started the traditional TravelTeams Wiki page, which you can find here. If you're planning to come, please consider adding your travel info to this page. Maybe you can meet up with some fellow Perl hacker at your departing airport, or meet somebody in Riga (and maybe share a cab to the hotel...)
Anyway, I'm very much looking forward to this years YAPC, especially since I missed the last one...
I tweeted something last night knowing full well that few people see my tweets
and most of those that do aren't programmers.
So I decided to post here in case anyone else experienced the same problem.
I installed the new LWP (v6) last night via cpan.
The next time I tried to install a module my cpan client barfed red errors (see below).
CPAN::Reporter was erroring when trying to send test results via Metabase.
I updated all SSL modules (cpan> upgrade /SSL/) and installed Mozilla::CA
as suggested in the LWP Changes
(and a tweet by miyagawa).
No luck.
I noticed something else in the LWP Changes file:
For https://... default to verified connections with require IO::Socket::SSL
and Mozilla::CA modules to be installed. Old behaviour can be requested by
setting the PERL_LWP_SSL_VERIFY_HOSTNAME environment variable to 0. The
LWP::UserAgent got new ssl_opts method to control this as well.
so I added this to my .bashrc and all is well again:
The client reported that the site sometimes took more than a minute to load.
Doesn't respond very slowly to me, and the pager is only primed to ping me if
there is a sustained downtime (hiccups are not something I want to wake up for
every night at 3:00am).
Strangely, load hovered around 7 most of the time, only spiking to 13 every
few minutes. With a 16-core processor, this was well within operating
parameters, if just a little worrisome. Nothing in the log files.
Oops, now I get a slow page load. Takes 30 seconds to load a page. Refresh
again, and the page loads just fine. Clear browser cache, and the page still
loads just fine.
Like I said in my previous blogpost, Module::Build has some serious technical problems. This causes another problem that I didn't discuss previously, but that's maybe the worst thing: no one loves it. MakeMaker also has some crazy internals, but it commands the love of a dedicated group of hackers. It's because of that more than anything else that I'm pretty sure its flame won't extinguish any time soon. Module::Build does not have such a luxury; no one seems motivated anymore to maintain it (if you are, do please take up contact with its current maintainer, David Golden). I fear Module::Build is screwed.
Last weekend I spend a few nice days in the Netherlands, thanks to the
Dutch Perl Workshop 2011. It
took place in Den Haag at the very cool Relevation Space (the pinball machines! the Space Invaders carpet! the
LackRacks!)
There isn't much that I can say about the website. It still lacks a backend (we are editing the database directly) although one is planed, using Dancer::Plugin::SimpleCRUD. Current database access is performed using Dancer::Plugin::Database, emails are being sent with Dancer::Plugin::Email and all templates are Template::Toolkit powered (through the respective plugin).
It is running in Apache fast-cgi (fcgid), and the database is MySQL.
What are the Perl modules you immediately install when you get a new Perl? Jesse Vincent, the Perl 5 pumpking, opened the door, albeit slightly, to possibly considering maybe thinking about provisionally expanding the Standard Library. Is that modally weak enough for you? (Jesse tells me I misread him, so, maybe the door is not open and never was).
Larry designed Perl 5 to be extensible, which is another way of saying that he designed basic Perl 5 to be small. CPAN is great, but we also know that through various social and technical factors, mere mortals struggle with the idea of having to get their wheels, fenders, and mirrors separately once they buy a car. Distributions such as ActivePerl and Strawberry and popular partly because they come with the extra bits. Non-perl people with their fingers in the pie tend to think about those included parts differently than the "third-party" parts.
London Perl Mongers organises technical meetings every two months. The technical meetings are a chance to find out what has been going on in the Perl community, what techniques people are using and how Perl integrates with other software.
The next technical meeting will be on the 10th March 2011 from 7pm to 9pm (you may arrive earlier, please sign in at the reception). You have to sign up to attend, see below. It will be hosted by NET-A-PORTER.COM and held at their offices in Westfield London
Shopping Centre. Many thanks to James Hudson, NET-A-PORTER.COM and everyone involved for allowing us to use this wonderful venue. We have the following wonderful speakers:
Zefram - The new extendability features that are going into Perl 5.14
Dave Hodgkinson - Perl, Hudson and Selenium
Pete Sergeant - Something testy
James Laver - Spark Form
For more information and to sign up, please visit:
I wanted to write up on the February TA.pm meeting we had two weeks ago but kept delaying it. I think it's about time!
As with every TA.pm meeting, we try to mix both beginner and advanced talks, in order to have something for everyone. It's proven very effective so far. We've also started doing lightning talks, which I really wanted to do for a while.
The beginner talk was done by Gabor Szabo, giving an introduction on how to get started contributing to an open source project. There were a lot of laughs and a lot of fun. We also got to see new faces, and that's always great.
Then we had a round of lightning talks, one by Shlomi Fish on how to solve a very specific problem in a ton of different ways, and one by no speaker at all, on how to write a nifty website in under a minute using Dancer.
We've now accepted the second round of talks. Thank you to everyone who has submitted so far! As for the first round, please be aware that just because your talk hasn't been accepted yet, it doesn't necessarily mean that it won't be.
You've got almost three weeks left to submit talks before the deadline on the 24th. We need many more still to fill out the available slots! Don't make us start volunteering people on IRC. ;)
As a bioinformatician and software developer of many years and avid Perl programmer and supporter, one thing I've noticed over the past few years is that Perl has been needlessly losing ground to Python in the major areas of scientific and financial computing, areas where it used to be *the* high-level interpreted language of choice. I am constantly having to correct people on blogs and forums that state incorrect Perl shortcomings when compared to Python or they were shortcomings from many years ago which don't exist anymore in the current language and ecosystem. If they spent two seconds researching Modern Perl and Enlightened Perl they would say WOW look where Perl has come!!!