Let's organise (... what I want programmers to know ...)

Ovid publiustemp-londonpm at yahoo.com
Mon Feb 19 10:27:57 GMT 2007


--- Tim Sweetman <ti at lemonia.org> wrote:

> What aspects of Perl require teaching? (Deliberately open-ended
> question)

That depends upon what the goal is.  Speaking for myself, here's what
I'd really like to see, as I have the "joy" of working with old code
that could easily be improved if programmers understood the following
(note that many of these should be taught as programming language
"basics", but don't seem to be).

Note that my needs are driven by wanting developers to understand
what's involved in writing "scalable" code.

* PROM

Packages, references, objects, modules.  Duh.

* Loose coupling

Example: when you have a chain of functions, all of which must be
called in succession from an outside module, then the outside module is
tightly coupled to the code it's calling and it makes refactoring tough
(see also: the Law of Demeter)

* Cohesive functions

Why the hell is your login routine also fetching the latest CNN
headlines?  (200 line subroutines are a great "code smell" for this
problem).

* Basic testing

I know that I speak for more than one programmer when I say that this
is the single most important thing which has made me a better
programmer (for some unknown value of "better").

* Context

Very Perl specific.  It's almost a given that you want the latter of
these two lines, but unless you understand context, the reasons for
this are very strange.

  my $data   = $line =~ /($some_regex)/;
  my ($data) = $line =~ /($some_regex)/;

Context can also explain why this:

  return;

Is usually preferable to this:

  return 0;

When you want to indicate why a function failed.

* Separation of concerns

Closely related to cohesive functions, I want people to understand why
their SQL, HTML and Perl shouldn't all be bundled up into a single
module, much less a function call.

* Encapsulation

Closely related to loosely coupled functions, understanding why and how
interface and data encapsulation should work is very important to
building scalable systems.

* OO programming with decent examples

I still remember in Java classes designing a class for a 'Dog', which
subclassed from 'Mammal'.  I've never written such a class for
business.  If any OO concepts are taught, it would be helpful if they
modeled "real world" problems the programmers are likely to face.

Cheers,
Ovid

--

Buy the book -- http://www.oreilly.com/catalog/perlhks/
Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/


More information about the london.pm mailing list