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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.42.10.142 with SMTP id q14mr28531921icq.28.1435177308601; Wed, 24 Jun 2015 13:21:48 -0700 (PDT) X-Received: by 10.140.82.166 with SMTP id h35mr113018qgd.36.1435177308427; Wed, 24 Jun 2015 13:21:48 -0700 (PDT) Path: buffer1.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news.glorb.com!j8no866577igd.0!news-out.google.com!4ni2664qgh.1!nntp.google.com!q107no3128958qgd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 24 Jun 2015 13:21:48 -0700 (PDT) In-Reply-To: <86oak5qulb.fsf@stephe-leake.org> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=83.99.95.58; posting-account=sDyr7QoAAAA7hiaifqt-gaKY2K7OZ8RQ NNTP-Posting-Host: 83.99.95.58 References: <9894cde7-2cf8-4060-be65-857812ad7b09@googlegroups.com> <17436268-aceb-461f-bdcf-eee8436cd0e6@googlegroups.com> <86y4jaqzdx.fsf@stephe-leake.org> <86oak5qulb.fsf@stephe-leake.org> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: What do you think about this? From: Laurent Injection-Date: Wed, 24 Jun 2015 20:21:48 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: number.nntp.giganews.com comp.lang.ada:193764 Date: 2015-06-24T13:21:48-07:00 List-Id: On Wednesday, 24 June 2015 12:17:08 UTC+2, Stephen Leake wrote: > 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". It is my first real project and I am a noob and I am doing this for fun or = doing something more useful than being a couch potato. So no background on = how to do things the correct way. That's also the reason why I asked what y= ou think about it.=20 I will try to improve the next time. The problem is that I have only a printout of the formatted text file from = the analyzer. I have absolutely no clue if I am allowed to reverse engineer= something from that. So I won't mention the name of the company or whateve= r. > > > > And then write it in a text file. >=20 > That's not what you state below. >=20 > > > > 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 res= ult > > 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. >=20 > 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. If I didn't know how to write a program than I would stick to 1) and/or 2).= Or handcrafting random text files. Well that would be option 4) and sucks = even more. Would have taken as much time as getting my program together. > 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. Not sure if I understand what you mean. In the main program I define the di= fferent objects I need. Every type has its own IO package with a procedure = which writes only the part it is responsible for. I have been daisy chainin= g the different components together and at the end I get the desired file. Then I only have to copy it into the upload folder on the analyzer and if I= am lucky I gets treated and finds it way through the different layers of t= he middleware/LIS and I don't know what else. So the 2 different things you mentioned actually are the same I think or I = didn't understand what you mean. > How are you going to compare the test text file to the data recieved by > the "software used by the nurses/doctors"? For the moment not at all because I don't have access to this particular ap= plication. But that's an other problem.=20 The IO-packages have the procedure To_BCI which write the different fields = and the separators and there is also a Display procedure which shows the co= ntent of the message on screen. But more readable.=20 I have "just" to add it in the Generate procedure in the main file and perh= aps modify it (Display procedure) to write to a text file, would be easier = to compare later, instead of scrolling around the terminal window. > >>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. >=20 > 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. Eh who said that I am paid for writing this thing. I am paid for cultivatin= g bacteria on agar plates.=20 The verification task is an additional bonus because I couldn't shut my fuc= king mouth. I am interested in understanding how the whole online works because I can g= et some problems solved easier because I know the cause. I have then "just"= to kiss the ass of the person who has access to program/integrator/configu= ration... So the problem gets solved in 5 min instead of hour/days and I ge= t actually do my job. So I got the reputation of being "competent in inform= atics" Falls in the category: The one eyed is king among the blind. So far about s= hutting my mouth. > 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.=20 Well in that case I hope the bus doesn't brake and I get a swift death. Take over? Who? >You might be interrupted for a longish time, and > forget the design details. Yep forget once that I hadn't finished something and whined here why it doe= sn't work. Cf one of my Stupid problem threats. > Good comments are also an extension of the requirements documentation; > they help clarify the design of the software, so you understand it better= . >=20 > At a minimum, there should be a reference to the analyzer document that > defines the text file format. Yes Google found the specification of the BCI protocol. =20 > >>... 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. >=20 > Yes, but the use of "+" can hide inefficiencies. >=20 > > 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. >=20 > 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. That's which one? Standard.Strings; Ada.Fixed; Bounded, Unbouded or the Gna= t.Formatted? Or some other I have forgotten. If there would be one for all String it would be ok but so I find it very c= onfusing. IMO using Strings in Ada is nearly as complicated than master acc= esses. Especially because I am a noob and I don't have loaded all the diffe= rent specifications, the RM and I don't know what else continuously in my b= rain. > > For the CMI I would have preferred to use enumerations but that > > doesn't seem to be possible: > > > > CMI_Type is ("<=3D1","0,004","3"); or CMI_Type is ("1","2","3"); >=20 > This is not an enumeration; it is an aggregate of strings. In Ada you > can do this as: >=20 > type CMI_Type is array (Integer range <>) of access constant String; >=20 > CMI_1 : constant CMI_Type :=3D (+"<=3D", +"0,004", +"3"); >=20 > where "+" is: >=20 > function "+" (Item : in String) return (new String'Item); >=20 >=20 > > but that works CMI_Type is ('1','2','3'); ? >=20 > This defines a new character type. Yes and because they are characters the compiler accepts. A character is st= ring with only one element. Why not have the possibility to use strings? > An enumeration type would be: >=20 > type CMI_Type is (One, Two, Three); >=20 > 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: >=20 > type CMI_Image_Type is array (CMI_Type) of access constant String; > CMI_1 : constant CMI_Image_Type :=3D (+"<=3D", +"0,004", +"3"); >=20 > or a function: >=20 > function Image (Item : in CMI_Type) return String is return > (case Item is > when One =3D> "<=3D1", > when Two =3D> "0,004", > when Three =3D> "3"); Too complicated for a beginner. Too much risk to make a mess and too few po= ssibilities to find the cause because I can't see the result via Text_IO. A= nd until now I didn't touch the debugger. Not even sure that I can figure o= ut what it tries to tell me. Have done it like this: subtype CMI_Type is V_String.Bounded_String; subtype SIR_Type is V_String.Bounded_String; Max_Nbr_CMI : constant Positive :=3D 10; -- max number of different CMI CMI_1 : constant CMI_Type :=3D (+"0,001"); -- '+' =3D Common_Defs.= To_Bound_String CMI_2 : constant CMI_Type :=3D (+ "<=3D2"); CMI_3 : constant CMI_Type :=3D (+"4"); CMI_4 : constant CMI_Type :=3D (+"16"); CMI_5 : constant CMI_Type :=3D (+">=3D32"); CMI_6 : constant CMI_Type :=3D (+"320"); CMI_7 : constant CMI_Type :=3D (+"SYN-S"); CMI_8 : constant CMI_Type :=3D (+"SYN-R"); CMI_9 : constant CMI_Type :=3D (+"Neg"); CMI_10 : constant CMI_Type :=3D (+"Pos"); Max_Nbr_SIR : constant Positive :=3D 5; -- max number of different SIR SIR_1 : constant SIR_Type :=3D (+"S"); SIR_2 : constant SIR_Type :=3D (+"I"); SIR_3 : constant SIR_Type :=3D (+"R"); SIR_4 : constant SIR_Type :=3D (+"-"); SIR_5 : constant SIR_Type :=3D (+"+"); Max_Antibiotiques : constant Natural :=3D 100; -- max number of antibiot= ics in configuration subtype Antibiotiques_Index is Positive range 1 .. Max_Antibiotiques; subtype CMI_Index is Positive range 1 .. Max_Nbr_CMI; subtype SIR_Index is Positive range 1.. Max_Nbr_SIR; type Antibiotique is private; type Antibiotiques_Array is array (Antibiotiques_Index) of Antibiotique; type CMI_Array is array (CMI_Index) of CMI_Type; type SIR_Array is array (SIR_Index) of SIR_Type; type Configuration_Array is private; private type Antibiotique is record Name : Name_Type:=3D(+"null"); Code_SIL : Code_Type:=3D(+"null"); CMI : CMI_Type:=3D(+"null"); SIR : SIR_Type:=3D(+"null"); end record; type Configuration_Array is record Anti_Config : Antibiotiques_Array; CMI_Config : CMI_Array :=3D (CMI_1, CMI_2, CMI_3, CMI_4, CMI_5, CMI_6, CMI_7, CMI_8, CMI_9, CMI_10); SIR_Config : SIR_Array :=3D (SIR_1, SIR_2, SIR_3, SIR_4, SIR_5); Anti_Counter : Natural :=3D 0; end record; Thanks for the comments. Still have a lot to learn Laurent