Re: readable source code [Re: OVC-discuss Digest, Vol 37, Issue 6]

From: Fred McLain <mclain_at_zipcon_dot_net>
Date: Sat Nov 03 2007 - 17:59:13 CDT

We have been accidentally given an idea example of why voting source
should be open, and openly discussed.

Comments in line below.

On Nov 3, 2007, at 3:05 PM, Danny Swarzman wrote:

> Fred,
>
> I didn't write that code. Don't blame me. I won't defend it.

Then don't call yourself "Danny Swarzman, VP Software Engineering,
OVS". If that is your title you must defend the product you are
responsible for producing. This code was at first posted by Ham to
demonstrate how unreadable code can be, but there are bigger issues.

This isn't a coding problem, it's a fundamental design problem. You
can not allow web services to count votes in an election. We can
debate this but I believe that most will concede the point, web access
to vote counting, (vs reporting), solutions isn't a very good idea.
Some people *can* read the code and point out the faults. But only if
they are allowed to discuss it with the greater community.

In fact, the brief exposure of this source code, in a forum that
active discussions are taking place, shows why we need unrestricted
access to the source. The NDAs around HR-811 would stop this very
discussion from occurring.

        -Fred-

P.S. Take a look at your logging. A System.out.println() isn't
sufficient.

>
>
> -Danny
>
>
> On Nov 3, 2007, at 12:17 PM, Fred McLain wrote:
>
>> As it turns out, I can read that code.
>>
>> Danny, you are using a bloody web service to load the configuration
>> for a voting system?!? Why would you possibly implement this as a
>> servlet? What the heck are you thinking?
>>
>> Please stick to your promise to not allow that code "in any system
>> running an election".
>>
>> By the way, commenting the code is a good idea.
>>
>> -Fred-
>>
>> On Nov 2, 2007, at 3:06 PM, Danny Swarzman wrote:
>>
>>> I promise you that code will not appear in any system running in an
>>> election. We recognize the problem. We are working on a new product.
>>> It will reflect a fanatic devotion to legibility.
>>>
>>> -Danny Swarzman, VP Software Engineering, OVS
>>>
>>> On Nov 2, 2007, at 2:45 PM, Hamilton Richards wrote:
>>>
>>>> At 10:45 AM -0700 2007/11/2, ovc-discuss-request@listman.sonic.net
>>>> wrote:
>>>>>
>>>>> Message: 2
>>>>> Date: Fri, 2 Nov 2007 10:45:52 -0700 (PDT)
>>>>> From: "Richard C. Johnson" <dick@iwwco.com>
>>>>> Subject: Re: [OVC-discuss] Representative Holt's OWN WORDS [Re:
>>>>> OVC-discuss Digest, Vol 36, Issue 9]
>>>>> To: Open Voting Consortium discussion list
>>>>> <ovc-discuss@listman.sonic.net>
>>>>> Message-ID: <479430.49366.qm@web408.biz.mail.mud.yahoo.com>
>>>>> Content-Type: text/plain; charset="iso-8859-1"
>>>>>
>>>>> Stuart,
>>>>>
>>>>> Here is some example Open Source code from the OpenScan system.
>>>>> See
>>>>> how difficult you think it would be to figure out. My own
>>>>> thought
>>>>> is that most people could correctly understand what is being coded
>>>>> and could also see that no subroutine doing nasty things was
>>>>> hidden
>>>>> in the code:
>>>>>
>>>>> <EML Id="230" SchemaVersion="5.0">
>>>>> <TransactionId>OK-2007-09-1</TransactionId>
>>>>> <CandidateList>
>>>>> <Election>
>>>>> <ElectionIdentifier Id=?Oklahoma 2007" />
>>>>> <Contest>
>>>>> <ContestIdentifier Id="State Governor" />
>>>>> <Candidate>Brad Henry</Candidate>
>>>>> <Candidate>John Wayne</Candidate>
>>>>> <Candidate>Bill Okapi</Candidate>
>>>>> <Candidate>Jane Smith</Candidate>
>>>>> </Contest>
>>>>> </Election>
>>>>> </CandidateList>
>>>>> </EML>
>>>>>
>>>>> ***************************
>>>>>
>>>>> I do believe that there are enough people who could read such code
>>>>> to make such Open Source a reasonable approach to increased
>>>>> transparency of elections. How many people can read the above and
>>>>> understand it? Quite a few, I would think. I admit, Open Source
>>>>> drivers for a scanner are more difficult, but I can read them even
>>>>> if it would be hard for me to write them myself.
>>>>>
>>>>> -- Dick
>>>>>
>>>>
>>>> Sure, many people could read code like that, if by "read" you mean
>>>> "recognize most of the words." But how many people could explain
>>>> how
>>>> one could determine whether that code is correct?
>>>>
>>>> For a more realistic example, spend a minute perusing the Java code
>>>> appended below
>>>> <http://emlvoting.cvs.sourceforge.net/emlvoting/USAballot/src/java/
>>>> action/CountingAction.java?revision=1.1&view=markup>.
>>>> Then give us an estimate of the fraction of the population that
>>>> could
>>>> formulate a coherent argument for its correctness. How many could
>>>> even give a coherent definition of "correctness"?
>>>>
>>>> Thanks,
>>>>
>>>> --Ham
>>>>
>>>>
>>>> public ActionForward execute(ActionMapping actionmapping,
>>>> ActionForm
>>>> actionform, HttpServletRequest httpservletrequest,
>>>> HttpServletResponse httpservletresponse)
>>>> 70 throws Exception
>>>> 71 {
>>>> 72 String forwardName = "defaultPage";
>>>> 73 try {
>>>> 74
>>>> 75 //pl = new PropertyLoader
>>>> ("http://localhost:8080/connecticutVotingDemo/properties/
>>>> application.properties");
>>>> 76 pl = new PropertyLoader
>>>> ("http://localhost:8080/connecticutVotingDemo/properties/
>>>> application.properties");
>>>> 77 prop = pl.getCache();
>>>> 78 } catch (Exception e) {
>>>> 79 e.printStackTrace();
>>>> 80 }
>>>> 81
>>>> 82 try
>>>> 83 {
>>>> 84 CountingForm countingform = (CountingForm)actionform;
>>>> 85 HashMap hashmap = new HashMap();
>>>> 86 BallotVO ballotvo = new BallotVO();
>>>> 87 MessageBean messagebean = new MessageBean();
>>>> 88 httpservletrequest.setAttribute("messageBean",
>>>> messagebean);
>>>> 89 makeWarning(httpservletrequest, "Welcome to Counting!
>>>> Please click on the given below enabled button to process the
>>>> counting...! ");
>>>> 90 String countingType = countingform.getCountingType();
>>>> 91 logSB.append("CountingType "+countingType+"\r\n");
>>>> 92 if(countingType.equals("ballotToEML440")) {
>>>> 93 System.out.print("ballotToEML440");
>>>> 94 String ballotLookupFolder =
>>>> prop.getProperty("ballotLookupFolder");
>>>> 95 System.out.println("ballotLookupFolder
>>>> "+ballotLookupFolder);
>>>> 96 //parse and map ballot look up
>>>> 97 parseBallotLookup(ballotLookupFolder);
>>>> 98
>>>> 99 try {
>>>> 100 // Ballot XML Parser
>>>> 101 HashMap listOfBallotMap = new HashMap();
>>>> 102 String ballotFolder =
>>>> prop.getProperty("ballotFolder");
>>>> 103 // Reading list of BALLOT XML file
>>>> 104 listOfBallotMap =
>>>> readListofFiles(ballotFolder);
>>>> 105 if (listOfBallotMap != null) {
>>>> 106
>>>> System.out.println("listOfEMLXMLs " +
>>>> listOfBallotMap.size());
>>>> 107 Set keySet = listOfBallotMap.keySet();
>>>> 108 if (keySet != null) {
>>>> 109 Iterator bIt =
>>>> keySet.iterator();
>>>> 110 while (bIt.hasNext()) {
>>>> 111 String key =
>>>> (String) bIt.next();
>>>> 112 xmlString =
>>>> (String) listOfBallotMap.get(key);
>>>> 113 //
>>>> System.out.println("Ballot XML size "+ xmlString.toString());
>>>> 114 BallotXMLMap
>>>> ballotMap = new BallotXMLMap();
>>>> 115 HashMap
>>>> ballotXMLMap = ballotMap.getXMLMap(xmlString.toString().trim());
>>>> 116
>>>> System.out.println("\r\n\r\nballotXMLMap Size
>>>> "+ballotXMLMap.size()
>>>> 117
>>>> +" ballotLookupXMLMap "+ballotLookupXMLMap.size());
>>>> 118
>>>> logSB.append("\r\n\r\nballotXMLMap Size "+ballotXMLMap.size()
>>>> 119
>>>> +" ballotLookupXMLMap "+ballotLookupXMLMap.size());
>>>> 120
>>>> writeFile(logSB.toString());
>>>> 121
>>>> //ballotVO.setBallotData(ballotXMLMap);
>>>> 122 xmlString = null;
>>>> 123 // Generate
>>>> EML440 XML file
>>>> 124
>>>> generateEML440(ballotXMLMap, ballotLookupXMLMap);
>>>> 125
>>>> ballotXMLMap=new HashMap();
>>>> 126
>>>> //System.out.println("\r\n\r\nballotXMLMap Size
>>>> "+ballotXMLMap.size());
>>>> 127
>>>> 128 }
>>>> 129 }
>>>> 130 }
>>>> 131
>>>> ballotvo.setTransactionDetails("Ballot to EML440 has been
>>>> converted successfully...!");
>>>> 132 countingform.setCountingType("eml440To510");
>>>> 133 } catch (Exception e) {
>>>> 134 System.out.println("Exception in
>>>> Ballot..." + e.getMessage());
>>>> 135 ballotvo.setTransactionDetails(e.toString());
>>>> 136
>>>> 137 }
>>>> 138 }
>>>> 139
>>>> 140 if(countingType.equals("eml440To510"))
>>>> 141 {
>>>> 142 System.out.println("eml440To510?");
>>>> 143 logSB.append("inside the eml440To510 if
>>>> condition\r\n");
>>>> 144 countingform.setCountingType("eml510To520");
>>>> 145 HashMap emlXMLMap = new HashMap();
>>>> 146 emlXMLMap = getEMLXMLCountingDataMap();
>>>> 147 System.out.println("emlXMLMap "+emlXMLMap.size
>>>> ());
>>>> 148 generateEML510(emlXMLMap);
>>>> 149 logSB.append("EML440 to EML510 has been converted
>>>> successfully...!");
>>>> 150 writeFile(logSB.toString());
>>>> 151 ballotvo.setTransactionDetails("EML440 to EML510
>>>> has been converted successfully...!");
>>>> 152 doRankedChoice();
>>>> 153 }
>>>> 154 if(countingType.equals("eml510To520"))
>>>> 155 {
>>>> 156 System.out.print("eml510To520");
>>>> 157 countingform.setCountingType("done");
>>>> 158 forwardName = "success";
>>>> 159 parseCounting410Lookup();
>>>> 160 parse510XML();
>>>> 161 generateEML520();
>>>> 162 makeWarning(httpservletrequest, "");
>>>> 163 }
>>>> 164 if(httpservletrequest.getParameter("countingType") !=
>>>> null &&
>>>> httpservletrequest.getParameter("countingType").equals("done"))
>>>> 165 {
>>>> 166 makeWarning(httpservletrequest, "");
>>>> 167 System.out.print("Inside done...!!!");
>>>> 168 countingform.setCountingType("done");
>>>> 169 }
>>>> 170 System.out.println("countingType " + countingType);
>>>> 171 System.out.println("Forward Status " + forwardName);
>>>> 172 writeFile(logSB.toString());
>>>> 173 }
>>>> 174 catch(Exception exception1)
>>>> 175 {
>>>> 176 exception1.printStackTrace();
>>>> 177 writeFile(logSB.toString());
>>>> 178 }
>>>> 179 return actionmapping.findForward(forwardName);
>>>> 180 }
>>>> --
>>>> ------------------------------------------------------------------
>>>> Hamilton Richards, PhD Department of Computer Sciences
>>>> Senior Lecturer (retired) The University of Texas at Austin
>>>> ham@cs.utexas.edu hrichrds@swbell.net
>>>> http://www.cs.utexas.edu/users/ham/richards
>>>> ------------------------------------------------------------------
>>>> _______________________________________________
>>>> OVC-discuss mailing list
>>>> OVC-discuss@listman.sonic.net
>>>> http://lists.sonic.net/mailman/listinfo/ovc-discuss
>>>> By sending email to the OVC-discuss list, you thereby agree to
>>>> release the content of your posts to the Public Domain--with the
>>>> exception of copyrighted material quoted according to fair use,
>>>> including publicly archiving at http://gnosis.python-hosting.com/
>>>> voting-project/
>>>>
>>>>
>>>
>>> _______________________________________________
>>> OVC-discuss mailing list
>>> OVC-discuss@listman.sonic.net
>>> http://lists.sonic.net/mailman/listinfo/ovc-discuss
>>> By sending email to the OVC-discuss list, you thereby agree to
>>> release the content of your posts to the Public Domain--with the
>>> exception of copyrighted material quoted according to fair use,
>>> including publicly archiving at http://gnosis.python-hosting.com/
>>> voting-project/
>>>
>>
>> Instant Messaging (IM) Addresses:
>> Jabber: mclain@jabber.org
>> Yahoo: appworx_fred, schemalogic_fred
>> MSN: appworx_fred@hotmail.com, schemalogic_fred@hotmail.com
>> AIM: mclain98021
>> ICQ: 6947005
>> GTalk (Jabber): mclain98021@gmail.com
>> Skype: fmclain
>>
>>
>>
>> _______________________________________________
>> OVC-discuss mailing list
>> OVC-discuss@listman.sonic.net
>> http://lists.sonic.net/mailman/listinfo/ovc-discuss
>> By sending email to the OVC-discuss list, you thereby agree to
>> release the content of your posts to the Public Domain--with the
>> exception of copyrighted material quoted according to fair use,
>> including publicly archiving at http://gnosis.python-hosting.com/
>> voting-project/
>>
>>
>
> _______________________________________________
> OVC-discuss mailing list
> OVC-discuss@listman.sonic.net
> http://lists.sonic.net/mailman/listinfo/ovc-discuss
> By sending email to the OVC-discuss list, you thereby agree to
> release the content of your posts to the Public Domain--with the
> exception of copyrighted material quoted according to fair use,
> including publicly archiving at http://gnosis.python-hosting.com/voting-project/
>

Instant Messaging (IM) Addresses:
Jabber: mclain@jabber.org
Yahoo: appworx_fred, schemalogic_fred
MSN: appworx_fred@hotmail.com, schemalogic_fred@hotmail.com
AIM: mclain98021
ICQ: 6947005
GTalk (Jabber): mclain98021@gmail.com
Skype: fmclain

_______________________________________________
OVC-discuss mailing list
OVC-discuss@listman.sonic.net
http://lists.sonic.net/mailman/listinfo/ovc-discuss
By sending email to the OVC-discuss list, you thereby agree to release the content of your posts to the Public Domain--with the exception of copyrighted material quoted according to fair use, including publicly archiving at http://gnosis.python-hosting.com/voting-project/
==================================================================
= The content of this message, with the exception of any external
= quotations under fair use, are released to the Public Domain
==================================================================
Received on Fri Nov 30 23:17:08 2007

This archive was generated by hypermail 2.1.8 : Fri Nov 30 2007 - 23:17:31 CST