Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Perl application programming toolkit http://badgerpower.com/
Fetching latest commit…
Cannot retrieve the latest commit at this time.
|Failed to load latest commit information.|
NAME Badger - Perl Application Programming Toolkit SYNOPSIS use Badger; # 1) have more fun # 2) get the job done quicker # 3) make your code skimpier # 4) finish work early # 5) go skateboarding # 6) enjoy life DESCRIPTION The Badger toolkit is a collection of Perl modules designed to simplify the process of building object-oriented Perl applications. It provides a set of foundation classes upon which you can quickly build robust and reliable systems that are simple, skimpy and scalable. Badger was hewn from the living rock of the Template Toolkit. It represents all the generic bits of TT that aren't directly related to template processing. They're also the same kind of generic modules that have appeared in pretty much every non-trivial Perl application I've written over the past 10 years or so. So Badger is essentially a restrospective generalisation of what I've learnt over that time about the right way (or more accurately, some of the less wrong ways) to build Perl applications. Badger is designed to be lightweight, fast, and as simple as it can be without being too simple. It offers convenience, convention and consistency in an attempt to improve the Kwalitee of your code and make it more Skimpy™ (which is my artistic interpretation of what Michael Schwern refers to as skimmable code - that is, code that is easy to read and also easy to skim over). Badger isn't just another object system. Although it does include functionality to simplify the process of building objects in Perl 5, that is really just a consequence of the larger goal. That is, to provide a self-contained set of OO modules that work together in a harmonious way to implement a basic platform upon which applications like TT can easily be built. If you want a comprehensive, highly extensible, postmodern object system then Moose should almost certainly be at the top of your list. The parts of Badger that deal with object construction are in some ways similar to the functionality provided by Moose, not to mention various other object toolkits available from CPAN. However, Badger only goes as far as doing what it needs to in terms of object construction in order to get the rest of the job done. That is, providing a set of objects that do useful things. Furthermore, the choice between Badger, Moose, or something else isn't an either-or decision. There are lots of things that Moose does, that Badger doesn't, and vice-versa. If you need a really powerful object system then Moose is probably the way forward. But that doesn't mean you can't use Badger's file handling tools, codecs, and other useful bits and pieces alongside your Moose classes. Metaphorically speaking, Badger and Moose are best friends and they play nicely together. Anyone for tennis? CONTENTS Let's take a quick frolic through the feature list forest to get an idea what Badger is all about. Foundation classes for OO programming Badger includes base classes for creating regular objects (Badger::Base), mixin objects (Badger::Mixin), prototypes/singletons (Badger::Prototype), factory classes (Badger::Factory) and central resource hubs (Badger::Hub). Class Metaprogramming The Badger::Class module employs metaprogramming techniques to simplify the process of defining object classes. It provides methods to automate many of the annoying trivial tasks required to "bootstrap" an object class: specifying base classes, version numbers, exportable symbols, defining constants, loading utility functions from external modules, creating accessor and mutator methods, and so on. There are also methods that simplify the process of accessing class data (e.g. package variables) to save all that mucking about in symbols tables. Some of these methods will also account for inheritance between related classes, making it much easier to share default configuration values between related classed, for example. A key feature of Badger::Class is that it does this by a process of "hygienic class construction". What this means in practice is that your object classes don't get polluted with methods that are only used to construct the class (e.g. a method that constructs accessor methods). Badger::Class can itself be subclassed, allowing you to build your own metaprogramming modules tailored to your particular needs. Error handling and debugging Base classes and mixin modules provide functionality for both hard errors in the form of exception-based error handling and soft errors for declining requests (e.g. to fetch a resource that doesn't exist) that aren't failures but require special handling. Methods for debugging (see Badger::Debug) and raising general warnings are also provided. Generic hooks are provided for receiving notification of, or implementing custom handling for errors, warnings and declines. Running alongside this is a generic message formatting system that allow you to define all error/warning/debug messages in one place where they can easily be localised (e.g. to a different spoken language) or customised (e.g. to generate HTML format instead of plain text). Symbol Exporter Badger implements an object oriented version of the Exporter module in the form of Badger::Exporter. It works correctly with respect to class inheritance (that is, a subclass automatically inherits the exportable symbols from its base classes) and provides a number of additional features to simplify the process of defining exportable symbols and adding custom import hooks. Standard utilities and constants. The Badger::Utils module provides a number of simple utility functions. It also acts as a delegate to various other standard utility modules (Scalar::Util, List::Util, List::MoreUtils, Hash::Util and Digest::MD5). Badger::Constants defines various constants used by the Badger modules and also of general use. Both these modules are designed to be subclassed so that you can create your own collections of utility functions, constants, and so on. Filesystem modules The Badger::Filesystem module and friends provide an object-oriented interface to a filesystem. Files and directories are represented as Badger::Filesystem::File and Badger::Filesystem::Directory objects respectively. As well as being useful for general filesystem manipulation (in this respect, they are very much like the Path::Class modules), the same modules can also be used to represent virtual filesystems via the Badger::Filesystem::Virtual module. This allows you to "mount" a virtual file system under a particular directory (useful when you're dealing with web sites to map page URLs, e.g. /example/page.html, to the source files, e.g. /path/to/example/page.html). You can also create a virtual file system that is a composite of several root directories (if you're familiar with the Template Toolkit then think of the way the "INCLUDE_PATH" works). Codec modules Going hand-in-hand with many basic filesystem operations, the codec modules provide a simple object interface for encoding and decoding data to and from any particular format. The underlying functionality is provided by existing Perl modules (e.g. MIME::Base64, Storable, YAML, etc). The codec modules are wrappers that provide a standard interface to these various different modules. It provides both functional and object oriented interfaces, regardless of how the underlying module works. It also provides the relevant hooks that allow codec objects to be composed into pipeline sequences. Free Badger is Open Source and "free" in both "free beer" and "free speech" senses of the word. It's 100% pure Perl and has no external dependencies on any modules that aren't part of the Perl core. Badger is the base platform for version 3 of the Template Toolkit (coming RSN) and has portability and ease of installation as primary goals. Non-core Badger add-on modules can make as much use of CPAN as they like (something that is usually to be encouraged) but the Badger core will always be dependency-free to keep it upload-to-your-ISP friendly. FURTHER INFORMATION See the documentation included with the Badger modules, starting with Badger.pm. Or look online: http://badgerpower.com/ AUTHOR Andy Wardley firstname.lastname@example.org http://wardley.org/ COPYRIGHT Copyright (C) 1996-2016 Andy Wardley. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.