It's UWAweek 10 (1st semester, week 2)

help2002

This forum is provided to promote discussion amongst students enrolled in CITS2002 Systems Programming.
Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.
Displaying selected article
Showing 1 of 1168 articles.
Currently 2 other people reading this forum.


 UWA week 35 (2nd semester, week 6) ↓
SVG not supported

Login to reply

👍?
helpful
5:48am Thu 31st Aug, Christopher M.

"Jacob Read" <23*7*9*6@s*u*e*t*u*a*e*u*a*> wrote:
> For project 1, would you rather we pass multiple pointers to all of our functions instead of using global variables, or are you ok with global variables if the scope of the variable is almost global or global. The pointers approach can obviously make code less readable and more complicated, and require the passing of arguments to functions when those arguments will always be the same, making the functions slightly less readable.
Hi Jacob, I understand (most of) your question, but there's no general one-size-fits-all answer. The best choice is going to be specific for a particular program - number of variables and functions, required degree of sharing between functions and, if concerned about memory and execution time, how large is the global data, whether copies of the data must be made if passed or parameters, or whether you actually want to use pointers in your program. Readability is certainly important but, of course, whether a program is less (or even more) readable if it uses pointers depends on who's reading the program. I've deliberately written the sample solution without pointers, to demonstrate (as claimed) that it can be done that way, and to not require students to use pointers. The result is many more global variables than I'd prefer to use, and I find it less readable. I'm unsure what you meant by "...the variable is almost global or global". Almost global? Whether a variable is global or not refers to the lexical level where it is defined, either inside or outside of a function.

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  5:07AM Sep 06 2023
Privacy policy