From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!news.flashnewsgroups.com-b7.4zTQh5tI3A!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: What do you think about this? References: <9894cde7-2cf8-4060-be65-857812ad7b09@googlegroups.com> <17436268-aceb-461f-bdcf-eee8436cd0e6@googlegroups.com> <86y4jaqzdx.fsf@stephe-leake.org> Date: Wed, 24 Jun 2015 05:17:04 -0500 Message-ID: <86oak5qulb.fsf@stephe-leake.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (windows-nt) Cancel-Lock: sha1:cgSM5VMDTxOlJE5d5MtjmswGcXs= MIME-Version: 1.0 Content-Type: text/plain X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: b2fab558a83a3e97f808419765 X-Received-Bytes: 5973 X-Received-Body-CRC: 1115972189 Xref: news.eternal-september.org comp.lang.ada:26453 Date: 2015-06-24T05:17:04-05:00 List-Id: Laurent writes: > On Tuesday, 23 June 2015 16:21:17 UTC+2, Stephen Leake wrote: >> I did not download and compile it, but I did browse around it a bit. > > That's why I like git. More precisely, the web front-end to git. Many other source code management systems have similar web front-ends. >>What is the whole thing supposed to do? > > It is supposed to generate something like this: > This should be included in a document in the git repository. The first step in building a software system is having a clear description of what it is supposed to do. These are formally called "requirements"; it is a mantra at NASA that "an engineer does not have a job until s/he has requirements". > > And then write it in a text file. That's not what you state below. > > > The hospital I work for has acquired a new software for epidemical > surveillance. I work in the lab in the microbiology department and I > have been asked to verify the transmission of the results from the > analyzer to the software used by the nurses/docters. > > I have 3 possibilities to do that: > > 1) launch tests but that takes 24hrs and I have no influence on the result > 2) use existing tests and rename them. Which means I have to tinker > around with results of actual patients. Is bad because of the iso > certification which requires everything to be traceable. No influence > on the result > 3) write a program which generates textfiles with random results which > I can copy into the transfer folder on the analyzer. If your requirement is to verify only the transmission of the data, not the generation of the data from actual patients, then 3 is clearly the correct choice. But above you stated your requirement as "generate a text file with a particular format". Perhaps you have divided up your task into subtasks, and were talking about a subtask above. How are you going to compare the test text file to the data recieved by the "software used by the nurses/doctors"? >>but it lacks comments > > Yup something I have to improve. In this case the program is only used > by me and quite probable only once. No program that is paid for will ever be used "only once". In your case, the analyzer will be upgraded, and the nurse/doctor software will be upgraded (or either will be replaced). That will require this test to be done again. Even if it turns out to be used "only once", writing good comments is still a good idea. You might get run over by a bus, and someone else will have to take over. You might be interrupted for a longish time, and forget the design details. Good comments are also an extension of the requirements documentation; they help clarify the design of the software, so you understand it better. At a minimum, there should be a reference to the analyzer document that defines the text file format. >>... it is better to return a String; then the caller can just use it >> without conversion, or declare a >local variable to hold it. > > Well without the "+" conversion function I would agree because the > To_Bound... thing is annoying. Yes, but the use of "+" can hide inefficiencies. > For the last part I don't understand what you mean. In the main file I > have the function Make_File_Name where File_Name is local variable. If > it is of type String or the custom V_String, where is the difference? > Ok I have to convert it later in procedure Generate. Requires an > additional "+". I find it is a quite good tradeoff for the flexibility > it offers me. I'm probably arguing for premature optimization. On the other hand, your V_String package has an upper bound on string length, which you might hit at some point. Learning how to use plain Ada String properly is a useful tool; it helps avoid many pitfalls. > For the CMI I would have preferred to use enumerations but that > doesn't seem to be possible: > > CMI_Type is ("<=1","0,004","3"); or CMI_Type is ("1","2","3"); This is not an enumeration; it is an aggregate of strings. In Ada you can do this as: type CMI_Type is array (Integer range <>) of access constant String; CMI_1 : constant CMI_Type := (+"<=", +"0,004", +"3"); where "+" is: function "+" (Item : in String) return (new String'Item); > but that works CMI_Type is ('1','2','3'); ? This defines a new character type. An enumeration type would be: type CMI_Type is (One, Two, Three); There are probably better names for these. And you probably need something other than CMI_Type'Image (foo) in the output text file. You can define an array: type CMI_Image_Type is array (CMI_Type) of access constant String; CMI_1 : constant CMI_Image_Type := (+"<=", +"0,004", +"3"); or a function: function Image (Item : in CMI_Type) return String is return (case Item is when One => "<=1", when Two => "0,004", when Three => "3"); -- -- Stephe