The Ecology and Biodiversity of Libraries Chris Mueller Software Libraries Workshop Dagstuhl, Germany March 9, 2005
Chris Mueller Software Libraries Workshop, Dagstuhl Germany2 Ecosystems ( ( Biologists gain knowledge by observing nature… Can we observe libraries in the wild?
March 9, 2005Chris Mueller Software Libraries Workshop, Dagstuhl Germany3 An Expedition into the Strange World of Libraries…
March 9, 2005Chris Mueller Software Libraries Workshop, Dagstuhl Germany4 Network Library #include "winsock2.h" void socket_connect(const char* host, const int port) { WSADATA wsaData; int iResult = WSAStartup( MAKEWORD(2,2), &wsaData ); if ( iResult != NO_ERROR ) // ignore; sockaddr_in clientService; clientService.sin_family = AF_INET; clientService.sin_addr.s_addr = inet_addr( host ); clientService.sin_port = htons( port ); if ( connect( m_socket, (SOCKADDR*) &clientService, sizeof(clientService) ) == SOCKET_ERROR) { WSACleanup(); return; } //... } Type Language neutral, platform neutral protocol library Usage Communicated between applications Components System libraries, Vendor libraries Users Software developers TCP/IP
March 9, 2005Chris Mueller Software Libraries Workshop, Dagstuhl Germany5 Plugin Library # From httpd.conf LoadModule rewrite_module libexec/httpd/mod_rewrite.so Type Application specific plugin library Usage Extend Apache's feature set Components System libraries Language C Users Software developers, Webmasters Apache Modules /* C Interface */ /* the main config structure */ module AP_MODULE_DECLARE_DATA rewrite_module = { STANDARD20_MODULE_STUFF, config_perdir_create, /* create per-dir config structures */ config_perdir_merge, /* merge per-dir config structures */ config_server_create, /* create per-server config structures */ config_server_merge, /* merge per-server config structures */ command_table, /* table of config commands */ register_hooks /* register hooks */ };
March 9, 2005Chris Mueller Software Libraries Workshop, Dagstuhl Germany6 Language Platform import java.util.Date; class HelloWorld { public static void main(String args[]) { Date now = new Date(); System.out.println(now + "Hello world!"); } --> Sat Mar 05 12:54:25 EST 2005: Hello world! Type Platform, library and runtime specifications, library collection Usage Application development Components System libraries Language Java, C Users Software developers J2SE
March 9, 2005Chris Mueller Software Libraries Workshop, Dagstuhl Germany7 Specifications Type Domain specific library specification Usage Enterprise application development, service and protocol abstraction Components J2SE, system libraries, vendor libraries Language Java Users Software developers J2EE Type Platform specific protocol abstraction Usage Directory lookup Components J2SE, J2EE, system libraries, vendor libraries Users Software developers JNDI import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import java.util.Hashtable; class Lookup { Object Lookup(String name) { // Identify service provider to use Hashtable env = new Hashtable(11); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory"); Object result = null; try { Context ctx = new InitialContext(env); Object obj = ctx.lookup(name); ctx.close(); } catch (NamingException e) { } return result; } (
March 9, 2005Chris Mueller Software Libraries Workshop, Dagstuhl Germany8 Script Library #!/bin/bash # Add the count of new log entries to the log stats file if [ -z "$1" ]; then echo usage: $0 log-file log-stats-file exit fi if [ -z "$2" ]; then echo usage: $0 log-file log-stats-file exit fi echo `date` `wc -l $1` >> $2 % log-counter library-examples.txt log.dat % cat log.dat Sat Mar 5 13:05:51 EST library-examples.txt Sat Mar 5 13:06:23 EST library-examples.txt Type System commands Usage System administration, monitoring, reporting Components System commands, language libraries Language Bash, csh, Perl, Python, etc… Users Sysadmins, software developers Log Monitor
March 9, 2005Chris Mueller Software Libraries Workshop, Dagstuhl Germany9 Data Access Libraries package com.mail.ejb.eventlog; import java.util.*; import javax.ejb.*; import javax.naming.*; import java.rmi.RemoteException; // Table Abstraction public abstract class UserLogBean implements EntityBean { // Access methods for relationship fields public abstract Collection getReadEvents(); public abstract void setReadEvents(Collection events); // Business methods public void addReadEvent(int eventId) { try { Collection events = getReadEvents(); events.add(eventId); } catch (Exception ex) { throw new EJBException(ex.getMessage()); } //... } // Query Abstraction public class EventLogControllerBean implements SessionBean { private LocalLogHome logHome public void logUserReadMail(String userId, String messageId) { LocalUserLog log = logHome.findByPrimaryKey(userId); log.addMailReadEvent(messageId); } Type OO relational database abstraction Usage Access database tables Components J2SE, J2EE Language Java, SQL Users Software developers, UI designers Enterprise JavaBeans Type Data source library and abstaction layer Usage Abstract vendor protocols and data sources Components Vendor libraries, language libraries Language Java, SQL Users Software developers, DBAs, DB developers ODBC
March 9, 2005Chris Mueller Software Libraries Workshop, Dagstuhl Germany10 Database Libraries -- Function that counts a users mail messages create or replace function count_messages ( user integer ) return integer as begin return select count(*) into temp_count from message where user_id = user; end; Type Procedural database access Usage Create SQL functions, database triggers Components SQL, DB libraries Language PL/SQL, Java, C/C++, Perl Users DBAs, DB developers Stored Procedures Type Database extension libraries Usage Extend database operations Components DB libraries, language libraries Language C/C++, Java Users Software developers, DB developers Database Cartridges/Packages -- Apply multidimensional scaling on to the data -- and return the result in a new temporary table select MDS(user, time, event, duration) from mail_events; |Row | X | Y | | 1 |.4 |.5 | | 2 |.2 |.9 | … /* Possible C signature */ db_table* MDS(db_table *queryResult, db_query_info *info) {... }
March 9, 2005Chris Mueller Software Libraries Workshop, Dagstuhl Germany11 Application Frameworks and Business Libraries package com.mail.applogic; import javax.servlet.*; import javax.servlet.http.*; import com.mail.businesslogic.*; // Process user mail requests class MailServlet extends HttpServlet { private String user; private String message; private int messageId; //... public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.user = request.getParameter("user"); String event = request.getParameter("event"); if(event.equals("showMessage")) { this.messageId = request.getParameter("messageId"); this.handleShowMessage(); } //... } void handleShowMessage() { Mailbox mb = Mailbox(this.user); this.message = mb.GetMessage(this.messageId); } Type Application framework Usage Application logic for Web applications Components J2SE, J2EE, business libraries Language Java Users Software developers Servlet API Type Domain library Usage Abstract mail data types and operations Components J2SE, j2EE, business libraries Language C/C++, Java Users Software developers, DB developers Mail Library
March 9, 2005Chris Mueller Software Libraries Workshop, Dagstuhl Germany12 Tag Libraries taglib prefix="mailapp” uri=" Libraries Libraries are so cool! I can't wait to go to Germany and talk about... Type User interface, data access Usage Data layout, presentation Components J2EE, business libraries Language XML, Java (JSP) Users UI designers, software developers Mail Tag Library
March 9, 2005Chris Mueller Software Libraries Workshop, Dagstuhl Germany13 Style Libraries Type Data structure manipulation Usage Transform data to other formats Components Language libraries Transformation Libraries Language XSLT, Perl, Python, Bash, csh Users UI designers, software developers, “branders”, translators Device Transform (mail-to-html.xsl) From: Subject: Libraries Libraries are so cool! I can't wait to go to Germany... Brand Transform (osl-brand.xsl) OSL Mail From: Subject: Libraries Libraries are so cool! I can't wait to go to Germany... You will obey Andy I18N Transform (translate.pl) OSL Post Von: Thema: Libraries Libraries are so cool! I can't wait to go to Germany... Sie befolgen Andy
March 9, 2005Chris Mueller Software Libraries Workshop, Dagstuhl Germany14 Component Libraries # COM in Python: from win32com.client import Dispatch xl = Dispatch("Excel.Application") xl.Visible = 1 xl.Workbooks.Add() xl.ActiveSheet.Cells(1,1).Value = ’Libraries rule!' xl.ActiveSheet.Cells(2,1).Value = ’Dagstuhl rules!' xl.ActiveWorkbook.Close(SaveChanges=0) xl.Quit() Type Language neutral software components, platform Usage Expose language-specific libraries to other languages and applications Components Language libraries Language All Users Everyone COM
March 9, 2005Chris Mueller Software Libraries Workshop, Dagstuhl Germany15 Quick Observations Types of Libraries Protocol libraries Plugin libraries Platforms Frameworks Specifications System commands Database libraries Style libraries Component libraries Users of Libraries Software developers DB developers System administrators UI designers DBAs End users Ways to Access Libraries Programming languages Shells Menus Config files
March 9, 2005Chris Mueller Software Libraries Workshop, Dagstuhl Germany16 Library Research Libraries are plentiful Libraries can be observed in their natural habitat Every library user has a story Library research should follow the traditional sciences and have a strong empirical component.