The Student Room Group

Are custom Functions from Visual Basic allowed in pseudocode?

Hello, I have a bit of a dilemma here.According to the Teachers guide,there is no mention of general visual basic functions such as '.Length' ,'.GetType' etc. Now i am aware that those functions are dedicated to VisualBasic but how would i go about handling array's in pseudocode ,if these are not allowed?
Thanks,

0478 IGCSE Computer Science
(edited 5 years ago)
Short answer - yes it's fine.

Pseudocode isn't a real language, so from a student point of view, its syntax doesn't have any strict rules - you can just make it up as you go along. Exam boards have defined their own pseudocode standard so that exam questions which ask students to read and understand pseudocode are consistent and unambiguous.

From a student point of view, you're going to be asked to write code in the exam which the examiner is going to mark based on how well you prove you understand the programming concepts and problem solving ability, so if you write it in a style which looks the same as Visual Basic or Python or any other popular high-level programming language, then it's fine. You don't need to learn their specific pseudocode syntax - there's not even any point trying to learn it as long as you can understand the way questions are written in the exam and write something which resembles a programming language, your time is better spent practicing solving problems in VB/Python/etc
(edited 5 years ago)
Reply 2
Original post by winterscoming
Short answer - yes it's fine.

Pseudocode isn't a real language, so from a student point of view, its syntax doesn't have any strict rules - you can just make it up as you go along. Exam boards have defined their own pseudocode standard so that exam questions which ask students to read and understand pseudocode are consistent and unambiguous.

From a student point of view, you're going to be asked to write code in the exam which the examiner is going to mark based on how well you prove you understand the programming concepts and problem solving ability, so if you write it in a style which looks the same as Visual Basic or Python or any other popular high-level programming language, then it's fine. You don't need to learn their specific pseudocode syntax - there's not even any point trying to learn it as long as you can understand the way questions are written in the exam and write something which resembles a programming language, your time is better spent practicing solving problems in VB/Python/etc

Awesome! So does that mean i can write 'Console.WriteLine()' or 'printf()' with no trouble. Cool.A while back a teacher also told me that 'goto' is not allowed (for an unknown reason ) as i hate using Repeat Until loops.does that also come in the play of 'understanding how to code'?
Original post by jack001214
Awesome! So does that mean i can write 'Console.WriteLine()' or 'printf()' with no trouble. Cool.A while back a teacher also told me that 'goto' is not allowed (for an unknown reason ) as i hate using Repeat Until loops.does that also come in the play of 'understanding how to code'?

I guess you could write "console.writeline" but you might as well just use "Print" because it's less writing - pseudocode isn't meant to be real code, it's meant to be structured human-readable logic and there's no bonus points for nit-picky syntax. To be honest, the best thing to do is keep it as simple as possible; adding "console." is unnecessary to help the examiner understand what you mean. Try to think in terms of plain English language words as closely as possible.

And yes, the Repeat-Until, or "Do-While", or "For" (or even For-Each) are all programming structures that you need to understand.

The important thing to realise about 'goto' is from a real-world programming point-of-view - it's universally regarded as an extremely bad way of writing code because that kind of "branched" logic has no structure. ('branch' is the term for any point within the logical flow of a program which could shoot off to a completely different line in another part of that program)

By that I mean that when using 'goto' there's nothing obvious in the structure of 'goto' which could show a human where the Beginning or End of a branch is, and it's also possible that there's no end at all, but a human wouldn't be able to tell just by looking at it - it can go anywhere. It's also easy to accidentally write un-reachable code without realising too - i.e. a branch with no beginning.

The end result is that you can easily write "spaghetti" logic that jumps all over the place, making it hard for a human to reason over the flow of a program, which is a real problem when trying to understand code, and especially if there's a bug, then it's harder to figure out why something is broken, and usually harder to figure out how to fix it too.


On the other hand, things like If/Else, For, While, etc are all structured forms of branching (the good kind) because they create "blocks" of code where the logical flow is self-contained between the Beginning and End of that block - the start/end is always obvious, and there's no chance of it jumping around.

In reality, there's always lots of ways to structure your code which makes 'goto' un-necessary anyway, because you can always structure your code in a way whereby using one or more of those will achieve the same thing. e.g. sometimes you might need to put an "IF" inside a "WHILE" (or the other way around), but that's much more logical and structured than having lots of goto/jump statements all over the place, and therefore easier for a human to read.

So while it may not have been explained very well by your teacher, that's essentially the reason why all computer science courses at all levels have banned the use of 'goto' (since sometime in the 1970s when computer scientists all agreed between each other that it was bad), and it's nearly always 'banned' in real-world programming too for the same reason.
(edited 5 years ago)
Reply 4
Original post by winterscoming
I guess you could write "console.writeline" but you might as well just use "Print" because it's less writing - pseudocode isn't meant to be real code, it's meant to be structured human-readable logic and there's no bonus points for nit-picky syntax. To be honest, the best thing to do is keep it as simple as possible; adding "console." is unnecessary to help the examiner understand what you mean. Try to think in terms of plain English language words as closely as possible.

And yes, the Repeat-Until, or "Do-While", or "For" (or even For-Each) are all programming structures that you need to understand.

The important thing to realise about 'goto' is from a real-world programming point-of-view - it's universally regarded as an extremely bad way of writing code because that kind of "branched" logic has no structure. ('branch' is the term for any point within the logical flow of a program which could shoot off to a completely different line in another part of that program)

By that I mean that when using 'goto' there's nothing obvious in the structure of 'goto' which could show a human where the Beginning or End of a branch is, and it's also possible that there's no end at all, but a human wouldn't be able to tell just by looking at it - it can go anywhere. It's also easy to accidentally write un-reachable code without realising too - i.e. a branch with no beginning.

The end result is that you can easily write "spaghetti" logic that jumps all over the place, making it hard for a human to reason over the flow of a program, which is a real problem when trying to understand code, and especially if there's a bug, then it's harder to figure out why something is broken, and usually harder to figure out how to fix it too.


On the other hand, things like If/Else, For, While, etc are all structured forms of branching (the good kind) because they create "blocks" of code where the logical flow is self-contained between the Beginning and End of that block - the start/end is always obvious, and there's no chance of it jumping around.

In reality, there's always lots of ways to structure your code which makes 'goto' un-necessary anyway, because you can always structure your code in a way whereby using one or more of those will achieve the same thing. e.g. sometimes you might need to put an "IF" inside a "WHILE" (or the other way around), but that's much more logical and structured than having lots of goto/jump statements all over the place, and therefore easier for a human to read.

So while it may not have been explained very well by your teacher, that's essentially the reason why all computer science courses at all levels have banned the use of 'goto' (since sometime in the 1970s when computer scientists all agreed between each other that it was bad), and it's nearly always 'banned' in real-world programming too for the same reason.

That's actually pretty reasonable. I mean i am used to programming ardunio boards and the only way to view output the result or the 'section' is to dump it out on the Serial buffer. Putting Console.x just makes me comfortable that i am not accessing some other device like the 16x2 lcd or something which have the same command set.
Also this brings up a another question. Callbacks? The thing is that nesting Repeat-Until and If statements just makes a mess when validating a user entry. For example.

Console.WriteLine("Would you like to bid on any items in this list? Y|N")
Do
Dim UserInput = Console.ReadLine()
If UserInput = "Y" Then
check = 1
... 'Do something now imagine nesting this for some other input ;-; lets say confirmation i would have to copy this set again..
ElseIf UserInput = "N" Then
check = 1
Return False 'snip-it inside a function
Else
Console.WriteLine("Invalid Command. e.g Y,N")
check = 0
End If
Loop Until check = 1 'loop until the input is correct

If so then i would spend my 45 minutes just working on verification and the actual code will be missed.What would be the best way to handle this?
(edited 5 years ago)
Original post by jack001214
That's actually pretty reasonable. I mean i am used to programming ardunio boards and the only way to view output the result or the 'section' is to dump it out on the Serial buffer. Putting Console.x just makes me comfortable that i am not accessing some other device like the 16x2 lcd or something which have the same command set.
Also this brings up a another question. Callbacks? The thing is that nesting Repeat-Until and If statements just makes a mess when validating a user entry. For example.

Console.WriteLine("Would you like to bid on any items in this list? Y|N")
Do
Dim UserInput = Console.ReadLine()
If UserInput = "Y" Then
check = 1
... 'Do something now imagine nesting this for some other input ;-; lets say confirmation i would have to copy this set again..
ElseIf UserInput = "N" Then
check = 1
Return False 'snip-it inside a function
Else
Console.WriteLine("Invalid Command. e.g Y,N")
check = 0
End If
Loop Until check = 1 'loop until the input is correct

If so then i would spend my 45 minutes just working on verification and the actual code will be missed.What would be the best way to handle this?


You seem to be overthinking this a lot. If it takes you 45 minutes to write some code which has nothing to do with the question and doesn't give you any marks, then just don't spend any time writing code which isn't needed. The question would say if it wants you do do all of that (and there would be marks, with enough time to do it as well). Otherwise, if it's just a simple case of 'ask the user' then all you need is a simple line of code, something that looks like this would be fine -

UserInput = Read()




Am I right in thinking you're at GCSE level? If so I doubt that callbacks or functional programming are even on your syllabus so it's highly unlikely that you'd get a question which needs callbacks or anything like that. Everything you'd be asked at GCSE should be about procedural programming really.


Otherwise, if you were answering a question to be answered in a functional programming style using callbacks, then most people would write something which looks similar to a callback in a real programming language too. e.g.

Function doSomething(callbackFunc)
Begin
callbackFunc()
End

But realistically speaking I don't think any GCSE or even A-Level syllabus covers this stuff so don't worry about it.
(edited 5 years ago)
Reply 6
Thank you so much for the comfort. Lately i have been experimenting with Node.JS so that is why i brought up the question of callbacks. For some reason i like going a tad bit further from my syllabus and forget what my course is!

Quick Reply

Latest

Trending

Trending