PDA

View Full Version : Please critique my first attempt at pseudo-code



Trouble31
29-10-2011, 03:04 PM
Instructions:
The code should reflect running the directory listing of all files on the system in alpha order.
Once that is completed, copy the files from the root of the HDD to the root of the FDD.
Once this process is completed, then append the current system date to the end of the AUTOEXEC.BAT and CONFIG.SYS.
Establish a connection to the printer located on INFO1120 and combine the code from AUTOEXEC.BAT and CONFIG.SYS.
Once the code is combined, redirect it to the printer.

Pseudo-Code:
Suppress all output to the monitor
Tell the user the purpose of the batch file
Pause to allow user read the explanation
Display alphabetic directory listing
Copy files from root of C: drive to root of A: drive
Add current system date to AUTOEXEC.BAT
Add current system date to CONFIG.SYS
(I donít know what to write about establishing a connect to the printer)
Combine AUTOEXEC.BAT and CONFIG.SYS
Redirect combined information to printer INFO1120
Tell user to pick up directory listing at the printer

Erayd
29-10-2011, 03:57 PM
Welcome to PressF1.

I must admit, I'm tempted to simply respond with 'DYOFH'; your post doesn't show much (if any) effort on your part.

For what it's worth, most people wouldn't consider your example pseudo-code - you've simply paraphrased the instructions in list form.

If you're having difficulty with an aspect of the problem, asking for help understanding that particular aspect is more likely to get you a useful answer.

Trouble31
29-10-2011, 04:09 PM
I'm just going by samples given to me. I thought that was what pseudo-code was - here is the definition I was provided with:

pseudocode - The outline of a program that is written in a form that can easily be converted into real programming statements but cannot be compiled nor executed, and there are no real formatting or syntax rules. Its benefit is that it enables the programmer to concentrate on the algorithms without worrying about all the syntactic details of a particular programming language. It is possible to write pseudocode without even knowing what programming language you will use for the final implementation.

Please tell me what point I am missing if I am not just supposed to write out what the program is to do. As I said, this is my first attempt.

Erayd
29-10-2011, 04:30 PM
The point of pseudo-code is to illustrate the logic flow of a program, without writing actual code in any particular language. The general idea is to show a logical framework that can solve the problem.

I think I was a bit harsh in my initial response (sorry) - having read your instructions a bit more closely, it doesn't look like there's much scope in there for anything other than linear flow, so your response isn't too bad given the context. My initial reaction was just "aaargh, another homework question" - I should have read it more carefully.

Your current suggestion of an answer to that isn't too bad, although it still has a few issues: It assumes you're writing a Windows / DOS batchfile, and therefore does language/platform specific things like suppressing the command echo. Pseudocode should be independent of the implementation.
You're adding steps that the instructions don't define, one of which is blocking - if the program is run in a non-interactive way, this could really gum up the works, because there will be no user present to continue the script. If you're sleeping rather than pausing for a response, then this introduces a delay that may be unwanted.
Be more specific about what you mean by add - you need to specify that you're appending to those files.
You don't need to be to explicit about how you connect to the printer - simply specifying that you're connecting to it is fine.You may also want to check with whoever set the assignment whether they expect you to include error-correction logic (e.g. only print if the connection to the printer succeeded, etc), or if they're happy with assuming implicit checking.

pctek
29-10-2011, 04:40 PM
written in a form that can easily be converted into real programming statements
enables the programmer to concentrate on the algorithms

Which it isn't, unless English sentences are suddenly easily converted to code.

Where are your algorithms?

Erayd
29-10-2011, 05:12 PM
Which it isn't, unless English sentences are suddenly easily converted to code.Which they are. The level of abstraction is subjective, and depends on what you're trying to do with pseudocode in the first place.


Where are your algorithms?That was my initial thought too, but there doesn't appear to be anything in the original question that requires anything other than linear flow. Unless they're expecting him to include error handling, there's simply not much there to work with.

pctek
29-10-2011, 08:44 PM
Well we had to do this sort of thing at tech and what we wrote was more a cross between Basic and a flow chart.

Paul.Cov
29-10-2011, 09:52 PM
Pseudo-Code:
Suppress all output to the monitor
Tell the user the purpose of the batch file
Pause to allow user read the explanation
Display alphabetic directory listing
Copy files from root of C: drive to root of A: drive
Add current system date to AUTOEXEC.BAT
Add current system date to CONFIG.SYS
(I don’t know what to write about establishing a connect to the printer)
Combine AUTOEXEC.BAT and CONFIG.SYS
Redirect combined information to printer INFO1120
Tell user to pick up directory listing at the printer

Well start by looking at how line 1 clashes with the intent of lines 2, 3 and 4.
Secondly, don't add anything to Autoexec or Config files (coz you'd be changing system files), but feel free to include date info along with copies of the content of these files.
Using a temporary file as your container for this info is logical. In the days of DOS a technique called Piping, and another called Redirection was the answer to your challenge.

Why do I feel like I'm doing a school kids homework for him?

Agent_24
30-10-2011, 10:02 AM
Why do I feel like I'm doing a school kids homework for him?

Because you are.