comp.lang.ada
 help / color / mirror / Atom feed
* [ot... well kindof] SDI
@ 2002-08-04  0:24 chris.danx
  2002-08-04 14:16 ` Robert Dewar
  0 siblings, 1 reply; 14+ messages in thread
From: chris.danx @ 2002-08-04  0:24 UTC (permalink / raw)


Hi,

Umm, this is going to sound a little cheeky but since terms over I 
thought I'd ask here.  I'm revising for a Software Design and 
Implementation course (pre software engineering but beyond meer 
programming course :) ) and am doing some past papers, but no solutions 
are available (CS policy is not to distribute solutions, which is 
annoying since I don't know what kind of answer they are looking for - 
each questions is worth 20pts but very little indication of the depth of 
answer required is given; I am usually too concise or not concise enough 
and lose marks; :(  Seems to be that the stuff I find obvious isn't and 
the stuff I rattle on about is :) ).

Can I post my answers here for someone to take a look at them? 
Everyones answers will be different (there is no one solution as we all 
know) and I'm not looking for answers, more feed back on the decisions 
I've made.

If someone is willing to look at them, I'll post each question & answer 
set in a separate thread under a master thread for easy reading (there 
are 3 or 4 Qs i think).


Regards,
Chris

-- 

to reply change 'spamoff' to 'chris'




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ot... well kindof] SDI
  2002-08-04  0:24 [ot... well kindof] SDI chris.danx
@ 2002-08-04 14:16 ` Robert Dewar
  2002-08-04 18:19   ` tmoran
  0 siblings, 1 reply; 14+ messages in thread
From: Robert Dewar @ 2002-08-04 14:16 UTC (permalink / raw)


"chris.danx" <spamoff.danx@ntlworld.com> wrote in message news:<Tv_29.3543$UD1.24013@newsfep3-gui.server.ntli.net>...
> Hi,
> 
> Can I post my answers here for someone to take a look at 
> them? 

The only posts appropriate to this newsgroup are specific
technical discussions of Ada or Ada related issues. If one
of your questions raises specific Ada issues then it is
reasonable to post here, not otherwise.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ot... well kindof] SDI
  2002-08-04 14:16 ` Robert Dewar
@ 2002-08-04 18:19   ` tmoran
  2002-08-04 19:08     ` chris.danx
  2002-08-05  1:26     ` Robert Dewar
  0 siblings, 2 replies; 14+ messages in thread
From: tmoran @ 2002-08-04 18:19 UTC (permalink / raw)


> The only posts appropriate to this newsgroup are specific
> technical discussions of Ada or Ada related issues.
  Is there anywhere else Ada questions might be appropriate?  If
not, and this is indeed the newsgroup closest to appropriate, then
posting here is appropriate.  Not asking the question at all is not
appropriate, and turning off prospective Ada users is especially
inappropriate.
  Of course, students should normally find a teacher a better
source of answers than a newsgroup (although apparently not in the
OP's situation), and putting something like "[newbie Q]" in the
subject line is helpful to all concerned, and if there's enough
demand, there should be a separate "simple Ada questions"
newsgroup.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ot... well kindof] SDI
  2002-08-04 18:19   ` tmoran
@ 2002-08-04 19:08     ` chris.danx
  2002-08-04 20:00       ` Chad R. Meiners
  2002-08-05 15:58       ` Stephen Leake
  2002-08-05  1:26     ` Robert Dewar
  1 sibling, 2 replies; 14+ messages in thread
From: chris.danx @ 2002-08-04 19:08 UTC (permalink / raw)


tmoran@acm.org wrote:

> Of course, students should normally find a teacher a better
> source of answers than a newsgroup (although apparently not in the
> OP's situation), and putting something like "[newbie Q]" in the
> subject line is helpful to all concerned, and if there's enough
> demand, there should be a separate "simple Ada questions"
> newsgroup.

Some of the questions relate to software design in Ada, some relate to 
language (Ada) features and others to design quality, testing.


These are some of the questions from the papers:-

   - "Ada 95 provides exceptions, packages and generics.  Briefly explain
      why these language features are important in SE".

   - "what is meant by reliability, in the context of SE?"

   - "...
      Make a list of testing goals for functional testing of this
      subprogram.  Then choose a set of test cases making sure these test
      cases cover all of your testing goals"

   - "the following procedures use result codes:
      ...

      Modify the procedures to use exceptions instead, ensuring that the
      effect is the same."


Where would be a better place to seek criticism of my answers to 
questions like this?


Chris

-- 

to reply change 'spamoff' to 'chris'




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ot... well kindof] SDI
  2002-08-04 19:08     ` chris.danx
@ 2002-08-04 20:00       ` Chad R. Meiners
  2002-08-05 18:22         ` chris.danx
  2002-08-05 15:58       ` Stephen Leake
  1 sibling, 1 reply; 14+ messages in thread
From: Chad R. Meiners @ 2002-08-04 20:00 UTC (permalink / raw)



"chris.danx" <spamoff.danx@ntlworld.com> wrote in message
news:ZYe39.2264$tm4.18073@newsfep3-gui.server.ntli.net...
> tmoran@acm.org wrote:

> These are some of the questions from the papers:-
>
>    - "Ada 95 provides exceptions, packages and generics.  Briefly explain
>       why these language features are important in SE".
>
>    - "what is meant by reliability, in the context of SE?"

The correctness of these questions depend heavily upon the viewpoint of the
grader.  This is why it is important to try to pick good professors for each
class and learn to pay careful attention to their viewpoints and/or agendas
on the subjest (I know this is sad, but we are all human, even professors).
Sure, there are some basic points that must be covered, but these points can
usually be easily discovered with a little reading and reasoning.

>    - "...
>       Make a list of testing goals for functional testing of this
>       subprogram.  Then choose a set of test cases making sure these test
>       cases cover all of your testing goals"

a software engineering newsgroup, perhaps?

>    - "the following procedures use result codes:
>       ...
>
>       Modify the procedures to use exceptions instead, ensuring that the
>       effect is the same."

I think this question would be suitable here since you can show both
versions of the code and ask specific questions about the codes'
equivalance.

> Where would be a better place to seek criticism of my answers to
> questions like this?

Peers and friends that know the subject you wish criticism about.

-CRM





^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ot... well kindof] SDI
  2002-08-04 18:19   ` tmoran
  2002-08-04 19:08     ` chris.danx
@ 2002-08-05  1:26     ` Robert Dewar
  1 sibling, 0 replies; 14+ messages in thread
From: Robert Dewar @ 2002-08-05  1:26 UTC (permalink / raw)


tmoran@acm.org wrote in message news:<Uee39.5912$i_1.69723273@newssvr21.news.prodigy.com>..
>   Is there anywhere else Ada questions might be 
> appropriate? 

Ada questions are always appropriate, but I am not sure
that general questions in a software engineering course
necessarily qualify, which is why I emphasized that this
group is about technical Ada issues. A question on an Ada
issue of course qualifies!

I don't see any point in a separate newsgroup for newbie
questions, there aren't that many of them here, and people who could
answer accurately are unlikely to hang out on
that other group (even in the main CLA, we get plenty of
inaccurate answers which can be confusing to experts let
alone newbies :-)



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ot... well kindof] SDI
  2002-08-04 19:08     ` chris.danx
  2002-08-04 20:00       ` Chad R. Meiners
@ 2002-08-05 15:58       ` Stephen Leake
  2002-08-05 16:10         ` chris.danx
  1 sibling, 1 reply; 14+ messages in thread
From: Stephen Leake @ 2002-08-05 15:58 UTC (permalink / raw)


"chris.danx" <spamoff.danx@ntlworld.com> writes:

> Some of the questions relate to software design in Ada, some relate to
> language (Ada) features and others to design quality, testing.
> 
> <snip question list>

I would not like to see discussion of this kind of question on
comp.lang.ada.

You might try a software engineering newsgroup (I forget the name).

Or get some of your colleagues together; are they all gone for the summer?

-- 
-- Stephe



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ot... well kindof] SDI
  2002-08-05 15:58       ` Stephen Leake
@ 2002-08-05 16:10         ` chris.danx
  0 siblings, 0 replies; 14+ messages in thread
From: chris.danx @ 2002-08-05 16:10 UTC (permalink / raw)


Stephen Leake wrote:
> "chris.danx" <spamoff.danx@ntlworld.com> writes:
> 
> 
>>Some of the questions relate to software design in Ada, some relate to
>>language (Ada) features and others to design quality, testing.
>>
>><snip question list>
> 
> 
> I would not like to see discussion of this kind of question on
> comp.lang.ada.

Fair does, I will only post the code for the conversion from result 
flags to exceptions which I did last night and save the others for the 
SE groups.

> You might try a software engineering newsgroup (I forget the name).

I found comp.software-eng, and comp.software-eng.testing last night so 
maybe I'll try there.


> Or get some of your colleagues together; are they all gone for the summer?

Unfortunately I know very few ppl in CS, and even less serious ppl.  I'm 
very 'shy'.



Chris

-- 

to reply change 'spamoff' to 'chris'




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ot... well kindof] SDI
  2002-08-04 20:00       ` Chad R. Meiners
@ 2002-08-05 18:22         ` chris.danx
  2002-08-05 18:24           ` chris.danx
  2002-08-05 19:46           ` Chad R. Meiners
  0 siblings, 2 replies; 14+ messages in thread
From: chris.danx @ 2002-08-05 18:22 UTC (permalink / raw)


Chad R. Meiners wrote:
> "chris.danx" <spamoff.danx@ntlworld.com> wrote in message

>>   - "the following procedures use result codes:
>>      ...
>>
>>      Modify the procedures to use exceptions instead, ensuring that the
>>      effect is the same."
> 
> 
> I think this question would be suitable here since you can show both
> versions of the code and ask specific questions about the codes'
> equivalance.

this is the original code.


subtype Postcode is String (1..7);

type PersonRecord is
    record
       name    : ...;
       address : ...
       pc      : Postcode;
    end record;

-- Read a postcode from standard input into code.
-- Set ok to true if and only if that post code is
-- well-formed.
--
procedure get_postcode (pc : out Postcode;
                         ok : out Boolean) is
begin
    get (pc);
    ok := is_letter(pc(1)) and ...;
end get_postcode;


-- Read complete personal details from standard input into person,
-- interactively promting the user for each detail.
--
procedure get_personal_details (person : out PersonRecord) is
    pc_ok : Boolean;
begin
    ... -- read person.name and person.address.
    loop
       put ("enter postcode");
       get_postcode (person.pc, pc_ok);
       exit when pc_ok;
       put_line ("postcode is ill-formed!");
     end loop;
end get_personal_details


This is my revision to make it work with exceptions instead.

subtype Postcode is String (1..7);

type PersonRecord is
    record
       name    : ...;
       address : ...
       pc      : Postcode;
    end record;

postcode_error : exception;

-- return true if pc is well-formed, false otherwise.
--
-- I prefer this since postcode formats may change in future,
-- this makes a change easier!
--
function is_wellformed (pc : in postcode) return boolean  is ...;


-- Read a postcode from standard input into code.
--
-- raises a Postcode_Error exception if the postcode is ill-formed.
--
procedure get_postcode (pc : out Postcode) is
begin
    get(pc);
    if not is_wellformed (pc) then
       raise Postcode_Error;
    end if;
end get_postcode;

-- Read complete personal details from standard input into person,
-- interactively promting the user for each detail.
--
procedure get_personal_detials (person : out PersonRecord) is
begin
    ... -- read person.name and person.address.
    loop
       begin
          put ("enter postcode");
	
          get_postcode (person.pc, pc_ok);
          exit;  -- ???
       exception
          when Postcode_Error => Put_Line ("Postcode is ill-formed!");
       end;
     end loop;
end get_personal_details


My concern is at the line marked "-- ???" the code will just exit the 
begin-end block not the loop, is this correct?  If so a simple revision 
that introduced a flag set after get_postcode would do.

The effect of the code has to be the same, that is it must loop until a 
valid postcode is entered.



Chris

-- 
to reply change 'spamoff' to 'chris'




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ot... well kindof] SDI
  2002-08-05 18:22         ` chris.danx
@ 2002-08-05 18:24           ` chris.danx
  2002-08-05 19:46           ` Chad R. Meiners
  1 sibling, 0 replies; 14+ messages in thread
From: chris.danx @ 2002-08-05 18:24 UTC (permalink / raw)


chris.danx wrote:

> -- Read a postcode from standard input into code.
> -- 
> -- raises a Postcode_Error exception if the postcode is ill-formed.
> -- 
> procedure get_postcode (pc : out Postcode) is
> begin
>    get(pc);
>    if not is_wellformed (pc) then
>       raise Postcode_Error;
>    end if;
> end get_postcode;
> 
> -- Read complete personal details from standard input into person,
> -- interactively promting the user for each detail.
> -- 
> procedure get_personal_detials (person : out PersonRecord) is
> begin
>    ... -- read person.name and person.address.
>    loop
>       begin
>          put ("enter postcode");
>     
>          get_postcode (person.pc, pc_ok);
                                    ^^^^
Copy and paste error!

Should be

    get_postcode (person.pc);




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ot... well kindof] SDI
  2002-08-05 18:22         ` chris.danx
  2002-08-05 18:24           ` chris.danx
@ 2002-08-05 19:46           ` Chad R. Meiners
  2002-08-05 22:25             ` chris.danx
  1 sibling, 1 reply; 14+ messages in thread
From: Chad R. Meiners @ 2002-08-05 19:46 UTC (permalink / raw)


"chris.danx" <spamoff.danx@ntlworld.com> wrote in message
news:Ynz39.11$5d3.56@news13-win.server.ntlworld.com...
>> procedure get_personal_detials (person : out PersonRecord) is
> begin
>     ... -- read person.name and person.address.
>     loop
>        begin
>           put ("enter postcode");
>
>           get_postcode (person.pc);
>           exit;  -- ???
>        exception
>           when Postcode_Error => Put_Line ("Postcode is ill-formed!");
>        end;
>      end loop;
> end get_personal_details
>
>
> My concern is at the line marked "-- ???" the code will just exit the
> begin-end block not the loop, is this correct?  If so a simple revision
> that introduced a flag set after get_postcode would do.

Read the Ada Reference Manual Section 5.7 on Exit Statements.
When in doubt look up the rules of the language ;) or label your loop.
For instance you will find the following nice example in the above section
which I think you'll agree is quite helpful in expressing you intentions
clearly.

Main_Cycle:
 loop
  -- initial statements
  exit Main_Cycle when Found;
  -- final statements
 end loop Main_Cycle;

-CRM





^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ot... well kindof] SDI
  2002-08-05 19:46           ` Chad R. Meiners
@ 2002-08-05 22:25             ` chris.danx
  2002-08-05 23:17               ` Chad R. Meiners
  0 siblings, 1 reply; 14+ messages in thread
From: chris.danx @ 2002-08-05 22:25 UTC (permalink / raw)


Chad R. Meiners wrote:
> "chris.danx" <spamoff.danx@ntlworld.com> wrote in message
 >>
>>My concern is at the line marked "-- ???" the code will just exit the
>>begin-end block not the loop, is this correct?  If so a simple revision
>>that introduced a flag set after get_postcode would do.
> 
> 
> Read the Ada Reference Manual Section 5.7 on Exit Statements.
> When in doubt look up the rules of the language ;) or label your loop.
> For instance you will find the following nice example in the above section
> which I think you'll agree is quite helpful in expressing you intentions
> clearly.

I didn't understand that section in the RM exactly so I tried a little 
snippet to see what would happen.

If the code looks something like this it works.

loop
    begin
       some_statement (some_parameters);
       exit when True;
    exception
       when Some_Exception => Put_Line ("bad input");
    end;
end loop;


What about flabby coding?  Can I ask how to tidy that up here?  I have 
one snippets of Ada code, which is flabby and need to tidy it up, but am 
not sure exactly why it is flabby (actually I now think I know why it is 
flabby, just not how to make it tighter).


Thanks Chad,
Chris

-- 

to reply change 'spamoff' to 'chris'




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ot... well kindof] SDI
  2002-08-05 22:25             ` chris.danx
@ 2002-08-05 23:17               ` Chad R. Meiners
  2002-08-05 23:46                 ` chris.danx
  0 siblings, 1 reply; 14+ messages in thread
From: Chad R. Meiners @ 2002-08-05 23:17 UTC (permalink / raw)



Try,

Robust_Input :
 loop
     begin
        some_statement (some_parameters);
        exit Robust_Input;
     exception
        when Some_Exception => Put_Line ("bad input");
     end;
 end loop Robust_Input;

> What about flabby coding?  Can I ask how to tidy that up here?  I have
> one snippets of Ada code, which is flabby and need to tidy it up, but am
> not sure exactly why it is flabby (actually I now think I know why it is
> flabby, just not how to make it tighter).

If tidy code is code done the Ada way, I imagine you can have it critiqued
here.

You're welcome,
-CRM







^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ot... well kindof] SDI
  2002-08-05 23:17               ` Chad R. Meiners
@ 2002-08-05 23:46                 ` chris.danx
  0 siblings, 0 replies; 14+ messages in thread
From: chris.danx @ 2002-08-05 23:46 UTC (permalink / raw)


Chad R. Meiners wrote:
> Try,
> 
> Robust_Input :
>  loop
>      begin
>         some_statement (some_parameters);
>         exit Robust_Input;
>      exception
>         when Some_Exception => Put_Line ("bad input");
>      end;
>  end loop Robust_Input;

Cheers, it's a bit clearer what the exit does in the above code than in 
mine, which is good.


>>What about flabby coding?  Can I ask how to tidy that up here?  I have
>>one snippets of Ada code, which is flabby and need to tidy it up, but am
>>not sure exactly why it is flabby (actually I now think I know why it is
>>flabby, just not how to make it tighter).
> 
> If tidy code is code done the Ada way, I imagine you can have it critiqued
> here.

ok, the code is for multiplying two n*n matrics.


type Matrix is array (1..n, 1..n) of Float;

function prod (a, b : in Matrix) return Matrix is
    p : Matrix;
begin
    for i in 1..n loop
      for j in 1..n loop
         p(i,j) := 0.0;

         for k in 1..n loop
           p(i,j) := p(i,j) + a(i,k)*b(k,j);
         end loop;
      end loop;
    end loop;
end prod;

This code does n*n*n iterations of the innermost loop, which I think is 
why the code is flabby (I think it can be done in less but am sure 
exactly how).

Anyone got a pointer in the right direction?


Chris




^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2002-08-05 23:46 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-04  0:24 [ot... well kindof] SDI chris.danx
2002-08-04 14:16 ` Robert Dewar
2002-08-04 18:19   ` tmoran
2002-08-04 19:08     ` chris.danx
2002-08-04 20:00       ` Chad R. Meiners
2002-08-05 18:22         ` chris.danx
2002-08-05 18:24           ` chris.danx
2002-08-05 19:46           ` Chad R. Meiners
2002-08-05 22:25             ` chris.danx
2002-08-05 23:17               ` Chad R. Meiners
2002-08-05 23:46                 ` chris.danx
2002-08-05 15:58       ` Stephen Leake
2002-08-05 16:10         ` chris.danx
2002-08-05  1:26     ` Robert Dewar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox