old-www/HOWTO/HighQuality-Apps-HOWTO/software.html

894 lines
19 KiB
HTML

<HTML
><HEAD
><TITLE
>The Four Universal Parts of Any Software</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"><LINK
REL="HOME"
TITLE="Designing Integrated High Quality Linux Applications"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE="User Friendly: Guaranteed Success"
HREF="userfriendly.html"><LINK
REL="NEXT"
TITLE="Linux Directory Hierarchy: Oriented to the Software Parts"
HREF="fhs.html"></HEAD
><BODY
CLASS="section"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Designing Integrated High Quality Linux Applications</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="userfriendly.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="fhs.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="software">3. The Four Universal Parts of Any Software</H1
><P
>The file set of any Application Software, graphical, server-side, commercial, open/free, monolithic etc, has allways four universal parts:</P
><A
NAME="software.body"
></A
><H1
CLASS="BRIDGEHEAD"
><A
NAME="AEN180">1<SUP
>st</SUP
> :: The Software on its own: the body</H1
><P
>The executables, libraries, static-data files, examples, manuals and documentation, etc. Regular users must have read-only access to these files. They are changed only when the system administrator makes an upgrade in this Software.</P
><A
NAME="software.soul"
></A
><H1
CLASS="BRIDGEHEAD"
><A
NAME="AEN184">2<SUP
>nd</SUP
> :: Configuration Files: the soul</H1
><P
>These are files that define how the Software will run, how to use the <A
HREF="software.html#software.content"
>Content</A
>, <A
HREF="security.html"
>security</A
>, performance etc. Without them, the <A
HREF="software.html#software.body"
>Software on its own</A
> is usually useless.</P
><P
>Depending on your Software, specific privileged users may change these files, to make the Software behave as they want.</P
><P
>It is important to provide documentation about the configuration files.</P
><A
NAME="software.content"
></A
><H1
CLASS="BRIDGEHEAD"
><A
NAME="AEN193">3<SUP
>rd</SUP
> :: Content</H1
><P
>Is what receives all the user attention. Is what the user delegated to be managed by your Product. Is what makes a user throw away your product and use the competitors', if it gets damaged.</P
><P
>Are the tables of a database system, the documents for a text editor, the images and HTML pages of a web-server, the servlets and EJBs of an Application Server, etc.</P
><A
NAME="software.logs"
></A
><H1
CLASS="BRIDGEHEAD"
><A
NAME="AEN198">4<SUP
>th</SUP
> :: Logs, Dumps etc</H1
><P
>Server Software use to generate access logs, trace files problem determination, temporary files etc. Other types of softwares also use this files, but it is less common.</P
><P
>It is the last class of file, but many times they are the most problem generator for a system administrator, because their volume can surpass even the content size. Due this fact, it is important for you to think in some methodology or facility for this issue, while you are in design time.</P
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="software.example">3.1. Practical Examples</H2
><P
>Let's see how universal is this concept analyzing some types of softwares:</P
><DIV
CLASS="table"
><A
NAME="partstable"><P
><B
>Table 1. Universality of 4 Parts</B
></P
><TABLE
BORDER="1"
WIDTH="100%"
CLASS="CALSTABLE"
><THEAD
><TR
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
>&nbsp;</TH
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
><A
HREF="software.html#software.body"
>Software on its Own</A
></TH
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
><A
HREF="software.html#software.soul"
>Configurations</A
></TH
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
><A
HREF="software.html#software.content"
>Content</A
></TH
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
><A
HREF="software.html#software.logs"
>Logs, Dumps etc</A
></TH
></TR
></THEAD
><TBODY
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><STRONG
>Data Base Server</STRONG
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Binaries, libraries, documentations.</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Files that define the directory of the data files. For this type of Software, the remaining configurations usually are in special tables inside the database.</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Table files, index files, etc. This software use to have whole trees under the same directory. And many times they need several filesystems to guarantee performance. Their local in the system is defined by they <A
HREF="software.html#software.soul"
>Configurations</A
>.</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>For DBs, there are the backup, generated in a daily basis. And the logs are used by the <SPAN
CLASS="acronym"
>DBA</SPAN
> to define indexing strategy. His local on the system is also defined by the <A
HREF="software.html#software.soul"
>Configurations</A
>.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><STRONG
>Text Processor</STRONG
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>The same, templates, modular file format filters, etc</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>As a user-oriented Software, its configurations must be put in each user's <TT
CLASS="envar"
>$HOME</TT
> directory, and are files that defines standard fonts and tabulation, etc.</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>The documents generated by the user, and they go some place in his <TT
CLASS="envar"
>$HOME</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>They show as temporary files that can be huge. User can define their location with a user-friendly dialog (that saves it in some <A
HREF="software.html#software.soul"
>Configuration</A
> file)</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><STRONG
>MP3 generator</STRONG
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Same, audio modular filters</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Each user has a configuration file in his <TT
CLASS="envar"
>$HOME</TT
>, and contains bitrate preferences etc</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Similar to Text Editor</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Similar to Text Editor</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><STRONG
>Web Server</STRONG
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Similar to Data Base</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Files that define the <A
HREF="software.html#software.content"
>Content</A
> directory, network and performance parameters, <A
HREF="security.html"
>security</A
>, etc</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Directories where the webmaster deposits his creativity. Again defined by the <A
HREF="software.html#software.soul"
>Configurations</A
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Preciouses access logs, vital for Marketing Intelligence, that are generated in a location and format defined by <A
HREF="software.html#software.soul"
>Configurations</A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><STRONG
>e-Mail Server</STRONG
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Similar to Database and Web-Server</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Files that define how to access user database, mail routing rules, etc</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>The preciouses users mail boxes. Again defined by the <A
HREF="software.html#software.soul"
>Configurations</A
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Mail transfer log, virus detection log, etc. Again defined by the <A
HREF="software.html#software.soul"
>Configurations</A
></TD
></TR
></TBODY
></TABLE
></DIV
><P
>Pay attention that the <A
HREF="software.html#software.body"
>Software on its Own</A
> contains all your product <EM
>business logic</EM
>, which could be useless if you hadn't a <A
HREF="software.html#software.soul"
>Configuration</A
> to define how to work with a <A
HREF="software.html#software.content"
>data bundle</A
>, provided by the user. So, <A
HREF="software.html#software.soul"
>Configurations</A
> are what connects your product to the user.</P
><P
>We can use a metaphor about a Sculptor (<A
HREF="software.html#software.body"
>business logic</A
>), that needs Bronze (<A
HREF="software.html#software.content"
>content</A
>) and a Theme or Inspiration (<A
HREF="software.html#software.soul"
>configuration</A
>) from a Mecenas (<A
HREF="userfriendly.html"
>user</A
>), to produce a beautiful work (<A
HREF="software.html#software.content"
>content</A
>). He make annotations in his Journal (<A
HREF="software.html#software.logs"
>logs</A
>) about his day-by-day activities, to report to his Mecenas (<A
HREF="userfriendly.html"
>user</A
>).</P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="separe">3.2. The Importance of Clear Separation Between Four Parts</H2
><P
>OK, so let's be more practical. The fact is, if we correctly use the <A
HREF="software.html"
>universal parts concept</A
>, we greatly improve the quality of our Product. We'll do that simply separating, encapsulating, each one of these parts in different system directories (having only different files for each part is not sufficient). There is a standard called <A
HREF="http://www.pathname.com/fhs/"
TARGET="_top"
>FHS</A
> that defines the Linux directories for each part, and we'll discuss it later in <A
HREF="fhs.html"
>Section 4</A
>.</P
><P
>By now let's see the value of this separation to the user:</P
><P
></P
><OL
TYPE="1"
><LI
><P
>He gains a clear vision about where is each part, specially his <A
HREF="software.html#software.soul"
>Configurations</A
> and <A
HREF="software.html#software.content"
>Content</A
>, and he feels your Product as something completely under control. The clareza brings ease of use, security and confidence in your Product. And in practice it permits him manipulate each part independently</P
></LI
><LI
><P
>It is clear now that, for instance, when backing up, user action is needed only for <A
HREF="software.html#software.soul"
>Configurations</A
> and <A
HREF="software.html#software.content"
>Content</A
> (the puritans will also backup some <A
HREF="software.html#software.logs"
>logs</A
>). The user don't have to care about <A
HREF="software.html#software.body"
>Software on its Own</A
>, because it is safe, original, on the product CD, in his shelf.</P
></LI
><LI
><P
>For upgrades, the new package will overwrite only the <A
HREF="software.html#software.body"
>business logic</A
>, leaving intact the user's precious <A
HREF="software.html#software.soul"
>Configurations</A
> and <A
HREF="software.html#software.content"
>Content</A
>. Here is very important to keep old content and configuration compatible, or to provide some tools help migration of data</P
></LI
><LI
><P
>The logs being kept in a separate filesystem (obviously suggested in your documentation), avoids that their exaggerated growth interfere with the <A
HREF="software.html#software.content"
>Content</A
>, or with the stability of the whole system</P
></LI
><LI
><P
>If your Software follows some directory standards, the user don't have to reconfigure his system or environment to use it. He will simply <STRONG
>Install-and-Use</STRONG
>.</P
></LI
></OL
><P
>Let's make some exercise with separation using as example a system called <SPAN
CLASS="acronym"
>MySoftware</SPAN
>, in which the <A
HREF="software.html#software.body"
>business logic</A
> is in <A
HREF="software.html#example.body"
>Example 1</A
> and the configuration is in <A
HREF="software.html#example.soul"
>Example 2</A
>.</P
><DIV
CLASS="example"
><A
NAME="example.body"><P
><B
>Example 1. A Shell program referring an external configuration file</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>&#13;#!/bin/sh
#############################################################################
##
## /usr/bin/MySoftware
##
## Business logic of MyProgram system.
## Do not change nothing in this file. All configuration can be
## made on /etc/MySoftware.conf
##
## We'll not support any modifications made here.
##
# Default configuration file
CONF=/etc/MySoftware.conf <A
NAME="ex.body.const.c1"
><IMG
SRC="../images/callouts/1.gif"
HSPACE="0"
VSPACE="0"
BORDER="0"
ALT="(1)"></A
>
# Minimal content directories
MIN_CONTENT_PATH=/var/www:/var/MySoftware/www <A
NAME="ex.body.const.c2"
><IMG
SRC="../images/callouts/2.gif"
HSPACE="0"
VSPACE="0"
BORDER="0"
ALT="(2)"></A
>
if [ -r "$CONF"]; then
. "$CONF" <A
NAME="ex.body.conf"
><IMG
SRC="../images/callouts/3.gif"
HSPACE="0"
VSPACE="0"
BORDER="0"
ALT="(3)"></A
>
fi
# All the content I'll serve are the "minimal" plus the ones provided
# by the user in the configuration file $CONF
CONTENT_PATH=$MIN_CONTENT_PATH:$CONF_CONTENT_PATH <A
NAME="ex.body.merge"
><IMG
SRC="../images/callouts/4.gif"
HSPACE="0"
VSPACE="0"
BORDER="0"
ALT="(4)"></A
>
.
.
.
</PRE
></TD
></TR
></TABLE
><DIV
CLASS="calloutlist"
><DL
COMPACT="COMPACT"
><DT
><A
HREF="software.html#ex.body.const.c1"
><IMG
SRC="../images/callouts/1.gif"
HSPACE="0"
VSPACE="0"
BORDER="0"
ALT="(1)"></A
></DT
><DD
>Definition of the configuration file name.</DD
><DT
><A
HREF="software.html#ex.body.const.c2"
><IMG
SRC="../images/callouts/2.gif"
HSPACE="0"
VSPACE="0"
BORDER="0"
ALT="(2)"></A
></DT
><DD
>Definition of some static parameters.</DD
><DT
><A
HREF="software.html#ex.body.conf"
><IMG
SRC="../images/callouts/3.gif"
HSPACE="0"
VSPACE="0"
BORDER="0"
ALT="(3)"></A
></DT
><DD
>The configuration is readed from an external file, if exists.</DD
><DT
><A
HREF="software.html#ex.body.merge"
><IMG
SRC="../images/callouts/4.gif"
HSPACE="0"
VSPACE="0"
BORDER="0"
ALT="(4)"></A
></DT
><DD
>After reading the configuration file, all content directories -- user's + product's -- goes together in the <TT
CLASS="envar"
>$CONTENT_PATH</TT
>, that will be used from now on.</DD
></DL
></DIV
></DIV
><DIV
CLASS="example"
><A
NAME="example.soul"><P
><B
>Example 2. File containing only the configurations for <SPAN
CLASS="acronym"
>MySoftware</SPAN
></B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>&#13;#############################################################################
##
## /etc/MySoftware.conf
##
## Configuration parameters for MySoftware.
## Change as much as you want.
##
# Content directory.
# A ':' separated list of directories for your content.
# The directories /var/www and /var/MySofware are already there, so
# include here your special directories, if any.
CONF_CONTENT_PATH=/var/NewInstance:/var/NewInstance2 <A
NAME="ex.soul.c1"
><IMG
SRC="../images/callouts/1.gif"
HSPACE="0"
VSPACE="0"
BORDER="0"
ALT="(1)"></A
>
# Your e-mail address, for notifications.
EMAIL=john@mycompany.com <A
NAME="ex.soul.c2"
><IMG
SRC="../images/callouts/2.gif"
HSPACE="0"
VSPACE="0"
BORDER="0"
ALT="(2)"></A
>
# Logs directory
LOG_DIR=/var/log/myInstance <A
NAME="ex.soul.c3"
><IMG
SRC="../images/callouts/3.gif"
HSPACE="0"
VSPACE="0"
BORDER="0"
ALT="(3)"></A
>
</PRE
></TD
></TR
></TABLE
><DIV
CLASS="calloutlist"
><DL
COMPACT="COMPACT"
><DT
><A
HREF="software.html#ex.soul.c1"
><IMG
SRC="../images/callouts/1.gif"
HSPACE="0"
VSPACE="0"
BORDER="0"
ALT="(1)"></A
><A
HREF="software.html#ex.soul.c2"
><IMG
SRC="../images/callouts/2.gif"
HSPACE="0"
VSPACE="0"
BORDER="0"
ALT="(2)"></A
><A
HREF="software.html#ex.soul.c3"
><IMG
SRC="../images/callouts/3.gif"
HSPACE="0"
VSPACE="0"
BORDER="0"
ALT="(3)"></A
></DT
><DD
>These are user defined parameters.</DD
></DL
></DIV
></DIV
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="bodysouls">3.3. One Body, Many Souls</H2
><P
>When I was a system administrator for IBM e-business Hosting Services, I was fascinated by <A
HREF="http://httpd.apache.org/"
TARGET="_top"
>Apache</A
>'s flexibility letting us do things like this:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;<TT
CLASS="prompt"
>bash# </TT
><B
CLASS="command"
>/usr/sbin/httpd &#38;</B
>
<TT
CLASS="prompt"
>bash# </TT
><B
CLASS="command"
>/usr/sbin/httpd -f /etc/httpd/dom1.com.br.conf &#38;</B
>
<TT
CLASS="prompt"
>bash# </TT
><B
CLASS="command"
>/usr/sbin/httpd -f /etc/httpd/dom2.com.br.conf &#38;</B
>
<TT
CLASS="prompt"
>bash# </TT
><B
CLASS="command"
>/usr/sbin/httpd -f /etc/httpd/dom3.com.br.conf &#38;</B
></PRE
></FONT
></TD
></TR
></TABLE
><P
>If we don't pass any parameter (like the first example), Apache loads its default, hardcoded configuration file from <TT
CLASS="filename"
>/etc/httpd/conf/httpd.conf</TT
>. We built other configs, one for each customer, with a completely different structure, IP address, loaded modules, content directory, passwords, domains, log strategy etc.</P
><P
>This same concept is used by a text editor of a multiuser desktop (like Linux). When the code is loaded, it looks for a configuration file on the user's <TT
CLASS="envar"
>$HOME</TT
>, and depending who invoked him (user A or B), it will appear differently because each user has its own personal configuration.</P
><P
>The obvious conclusion is that the Software's body (<A
HREF="software.html#software.body"
>business logic</A
>) is pure e completely oriented by his manipulator's spirit (<A
HREF="software.html#software.soul"
>configuration</A
>). But the competitive advantage lays on how easy we switch from one <A
HREF="software.html#software.soul"
>spirit</A
> to another, like in Apache's example. It is very healthy to promote it to your user. You'll be letting him create intimacy, reliability, confort with your Product.</P
><P
>We used this approach with many different Softwares in that e-business Hosting time, and it was extremely usefull for maintenance etc. In a version migration we had total control over where were <A
HREF="software.html"
>each of its parts</A
>, and upgraded and downgraded Software with no waste of time, with obvious success.</P
><P
>But there were some Products that refused to work this way. They had so many hardcoded parameters, that we couldn't see what divided the <A
HREF="software.html#software.body"
>body</A
> from their <A
HREF="software.html#software.soul"
>spirit</A
> (or other parts). These Softwares were marked as <EM
>bad guys</EM
> and discarded/replaced as soon as possible.</P
><P
>We concluded that the <EM
>good guys</EM
> Softwares were intuitively blessed by their developer's <A
HREF="software.html"
>four parts vision</A
>. And they made our life easyer. In fact, in that time we formulated this <A
HREF="software.html"
>theory</A
>, that continues to prove itself.</P
><P
>Do you want to deploy <EM
>bad guy</EM
> or <EM
>good guy</EM
> Software?</P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="userfriendly.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="fhs.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>User Friendly: Guaranteed Success</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Linux Directory Hierarchy: Oriented to the Software Parts</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>