Initial add of defaria.com
[clearscm.git] / defaria.com / blogs / Status / archives / week_2006_11_26.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" id="sixapart-standard">
4 <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6    <meta name="generator" content="Movable Type 5.2.3" />
7
8    <link rel="stylesheet" href="http://defaria.com/blogs/Status/styles-site.css" type="text/css" />
9    <link rel="alternate" type="application/atom+xml" title="Atom" href="http://defaria.com/blogs/Status/atom.xml" />
10    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://defaria.com/blogs/Status/index.xml"$>" />
11
12    <title>Status for Andrew DeFaria: November 26, 2006 - December  2, 2006 Archives</title>
13
14    <link rel="start" href="http://defaria.com/blogs/Status/" title="Home" />
15    <link rel="prev" href="http://defaria.com/blogs/Status/archives/week_2006_11_19.html" title="November 19, 2006 - November 25, 2006" />
16    <link rel="next" href="http://defaria.com/blogs/Status/archives/week_2006_12_10.html" title="December 10, 2006 - December 16, 2006" />
17 </head>
18 <body class="layout-one-column">
19    <div id="container">
20       <div id="container-inner" class="pkg">
21
22          <div id="banner">
23             <div id="banner-inner" class="pkg">
24                <h1 id="banner-header"><a href="http://defaria.com/blogs/Status/" accesskey="1">Status for Andrew DeFaria</a></h1>
25                <h2 id="banner-description">Searchable status reports and work log</h2>
26             </div>
27          </div>
28
29          <div id="pagebody">
30             <div id="pagebody-inner" class="pkg">
31                <div id="alpha">
32                   <div id="alpha-inner" class="pkg">
33                      
34                      <p class="content-nav">
35                         <a href="http://defaria.com/blogs/Status/archives/week_2006_11_19.html">&laquo; November 19, 2006 - November 25, 2006</a> |
36                         <a href="http://defaria.com/blogs/Status/">Main</a>
37                         | <a href="http://defaria.com/blogs/Status/archives/week_2006_12_10.html">December 10, 2006 - December 16, 2006 &raquo;</a>
38                      </p>
39                      
40                      
41                      
42
43                      <h2 class="date-header">December  1, 2006</h2>
44                      <a id="a000600"></a>
45                      <div class="entry" id="entry-600">
46                         <h3 class="entry-header">GPDB Bug Fixed</h3>
47                         <div class="entry-content">
48                            <div class="entry-body">
49                               <ul>
50   <li>Fixed bug in domain_ranges.sql script</li>
51
52   <li>Finished Create site</li>
53
54   <li>Added replica_name field</li>
55
56   <li>Fixed naming error with snapto_dir and owning_group</li>
57
58   <li>Expanded size of snap_notify to 1024 bytes</li>
59 </ul>
60                               
61                               <p class="entry-footer">
62                                  <span class="post-footers">Posted by  at 11:21 AM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000600.html">Permalink</a>
63                                  
64                                  
65                               </p>
66                            </div>
67                         </div>
68                      </div>
69                      
70                      
71
72                      <h2 class="date-header">November 29, 2006</h2>
73                      <a id="a000599"></a>
74                      <div class="entry" id="entry-599">
75                         <h3 class="entry-header">Perl Style</h3>
76                         <div class="entry-content">
77                            <div class="entry-body">
78                               <h2>A little bit about Perl Style</h2>
79
80 <p>By and large I feel that massively indented and thus multi level conditional statements are not handled well by most people. You see as your evaluating the code you have to "put on the mind stack" each condition and bear it in mind as you successively consider each of the nestings of code. As such I always "look for ways out" of the script/function/routine that I'm in. The idea is to avoid nesting by handling error conditions and other "if this happens then we're done" first, often die'ing, erroring out, returning the script/function or subroutine. The net effect is that the rest of the code, the code that normally executes, is shifted to the left a level or two. Additionally complicated, repeated or complex code can be written into a well named subroutine and called from the main or other functions when needed. To me this all makes the code a lot easier to read.</p>
81
82 <p>As an example, and again, I'm not trying to pick on your script specifically and I realize that this might not be the final version, but in reality it contains only a call to GetOptions and 2 if statements. The first if statement merely calls usage if -h is specified. BTW this could be re-written as:</p>
83
84 <div class=code><pre>
85 GetOptions (
86   'f=s',      \$facility,
87   'p=i',      \$port,
88   'a=s',      \$XAID,
89   'w=s',      \$password,
90   'n=s',      \$projName,
91   'g=s',      \$unixGroup,
92   's=s',      \$serverName,
93   'c=s',      \$cachePath,
94   'h',        sub { usage },
95 ) || usage;
96 </pre></div>
97
98 <p>IOW rather than define an $h variable and then set it via GetOptions then test it afterwards only to call usage, define an anonymous subroutine can calls usage directly from GetOptions. Or, since anything other than the stated options displays usage (as per the "|| usage") simply drop the "h" line entirely. If the user specifies -h then it's unknown and usage is displayed. Then $h can be removed as well as the if test following GetOptions.</p>
99
100 <p>The next if statement tests that all of the above variables have been defined. If so then all real processing happens inside that if (and other nested if's therein). Otherwise usage is called. In following with the "looking for a reason to get out" philosophy how about:</p>
101
102 <div class=code><pre>
103 usage unless (
104   defined $password   &amp;&amp;
105   defined $XAID       &amp;&amp;
106   defined $projName   &amp;&amp;
107   defined $serverName &amp;&amp;
108   defined $unixGroup  &amp;&amp;
109   defined $cachePath  &amp;&amp;
110   defined $port       &amp;&amp;
111   defined $facility
112 );
113 </pre></div>
114
115 <p>Basically this says, "if any of these are not defined call usage" and since usage doesn't return everything inside the old if statement can be shifted to the left. Other opportunities exist to continue to apply this philosophy of "getting out while you can" and reducing the nesting level of the program. For example, inside the old if statement you
116 check to see if the login of GPDB successfully made you an administrator. If not you're gonna stop the script right there. So then how about something like:</p>
117
118 <div class=code><pre>
119 my $login = gpdb_login ($XAID, $password);
120
121 error "$XAID is not an administrator", 1 if $login !~ /administrator/;
122 </pre></div>
123
124 <p>gpdb_login returns a string that will contain "administrator" if you were able to login as an administrator. Here I use error, a routine that I often use (in fact I'd like to publish it to TI as a common utility) that writes an error message to STDERR and optionally exits if
125 the second parameter is not 0.</p>
126                               
127                               <p class="entry-footer">
128                                  <span class="post-footers">Posted by  at  6:38 AM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000599.html">Permalink</a>
129                                  
130                                  
131                               </p>
132                            </div>
133                         </div>
134                      </div>
135                      
136                      
137
138                      <h2 class="date-header">November 28, 2006</h2>
139                      <a id="a000598"></a>
140                      <div class="entry" id="entry-598">
141                         <h3 class="entry-header">More GPDB fixes</h3>
142                         <div class="entry-content">
143                            <div class="entry-body">
144                               <ul>
145   <li>Added CSS class for input fields</li>
146
147   <li>Changed Project names to be drill down links</li>
148
149   <li>Fixed some bugs in add project. Now checking that project name and owning group are not blank</li>
150
151   <li>Added Port Ranges to Sites. As implemented it's just a text field with no real enforcement. I think the plan is to eventually augment the DesignSync creation script to check the port ranges from the GPDB Site table</li>
152
153   <li>Augmented Create Site to accommodate newly added fields. Still need to implement the handling of multiple domains per site. Should a check be implemented to insure that a domain name is not duplicated at any other site?</li>
154
155   <li>Implemented checking of IP Ranges to insure they are valid IP addresses and that the lower range is lower than the upper range. Still need to check that these ranges do not overlap any other IP ranges.</li>
156
157   <li>Changed several drop downs to properly sort the items. For example, user names are not sorted by at least first name, sites are sorted by site name, etc.</li>
158 </ul>
159                               
160                               <p class="entry-footer">
161                                  <span class="post-footers">Posted by  at  8:44 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000598.html">Permalink</a>
162                                  
163                                  
164                               </p>
165                            </div>
166                         </div>
167                      </div>
168                      
169                      
170
171                      <h2 class="date-header">November 27, 2006</h2>
172                      <a id="a000594"></a>
173                      <div class="entry" id="entry-594">
174                         <h3 class="entry-header">More tables, fields and bug fixes</h3>
175                         <div class="entry-content">
176                            <div class="entry-body">
177                               <ul>
178   <li>Added PDB_ALIASES and PDB_MIRRORS to GPDB</li>
179
180   <li>Expanded VOB_TAG to accommodate larger VOB_TAGS</lI>
181
182   <li>Added more fields to PDB_SITES to hold login information that used to be kept in the gpdb_site_list.txt</li>
183
184   <li>Fixed bug with not displaying/updating phone number<li>
185 </ul>
186                               
187                               <p class="entry-footer">
188                                  <span class="post-footers">Posted by  at  8:11 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000594.html">Permalink</a>
189                                  
190                                  
191                               </p>
192                            </div>
193                         </div>
194                      </div>
195                      
196                   </div>
197                </div>
198             </div>
199          </div>
200       </div>
201    </div>
202 </body>
203 </html>