9 Replies - 1532 Views - Last Post: 15 February 2018 - 12:37 PM

#1 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 6285
  • View blog
  • Posts: 21,606
  • Joined: 05-May 12

That assignment that required using 36 variables...

Posted 14 February 2018 - 09:07 PM

I am still having my mind blown that assignment the required using 36 separate variables for something that would naturally fit into an array is a current assignment at the University of Illinois at Chicago as part of their CS 141 course. It even has a YouTube video.

I did not expect this at all. (But then nobody ever expected the Spanish Inquisition, either.)

Is This A Good Question/Topic? 4
  • +

Replies To: That assignment that required using 36 variables...

#2 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12324
  • View blog
  • Posts: 45,424
  • Joined: 27-December 08

Re: That assignment that required using 36 variables...

Posted 14 February 2018 - 09:30 PM

This is quite disturbing... UIC is actually a really good CS school. And based on the instructor's CV, he appears to be quite capable as well. The only valid reason I can imagine for such an assignment is to create an appreciation for data structures.

I would be very interested in hearing the instructor's justification for this assignment.
Was This Post Helpful? 0
  • +
  • -

#3 jon.kiparsky   User is online

  • Beginner
  • member icon


Reputation: 11091
  • View blog
  • Posts: 18,973
  • Joined: 19-March 11

Re: That assignment that required using 36 variables...

Posted 14 February 2018 - 10:22 PM

Yeah - I could see sketching out the 36-variable solution in a lecture to motivate the use of a suitable data structure, but asking a student to write that? That's insane.
Was This Post Helpful? 0
  • +
  • -

#4 jimblumberg   User is offline

  • member icon

Reputation: 5519
  • View blog
  • Posts: 17,109
  • Joined: 25-December 09

Re: That assignment that required using 36 variables...

Posted 14 February 2018 - 11:28 PM

Quote

but asking a student to write that? That's insane.

I would agree if this was an intro type of course but it seems that it is an advanced class based on the course title (CS 141, Programming Design II) and may be appropriate depending on the prerequisites and the textbook.

I think the following gives a hint as to the why "Hint: Think about how you would write the program if you were using arrays. Consider how you might instead use a function in each location where otherwise you would use an array.".

Also IMO program 1 is also not a simple program so it appears that the students are expected to already have mid level programming experience prior to taking this class.

Jim
Was This Post Helpful? 0
  • +
  • -

#5 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 6285
  • View blog
  • Posts: 21,606
  • Joined: 05-May 12

Re: That assignment that required using 36 variables...

Posted 15 February 2018 - 07:23 AM

Almost, except for the places where using the function would be most useful, Dale tells the students to explicitly use the variables:

Quote

You would generate a random number and then check to see if it is even or odd (using the mod operator). If the random number is even, set the board variable p0 to 'O'. If the random number is odd, set that board variable p0 to 'X'. Repeat this for each board variable, starting with p0 and ending with p35.

and

Quote

When you display the board you can use cout with a string literal (e.g. cout << " 1 2 3 4 5 6 7 \n"; ) to display the parts around the edges, but for the interior section you should be printing the variables (e.g. cout << p0 << " " << p1 ...) that contain the previously set 'X' or 'O' values.


And the sentence before his hint is ambiguous at best:

Quote

You may not use arrays, or strings, or any other method to circumvent the need to handle fundamentally using the 36 variables throughout your program.


A lot of macro magic can be used, but would that be considered circumventing? The resulting code would be accessing the appropriate variable directly as required.
Was This Post Helpful? 0
  • +
  • -

#6 jimblumberg   User is offline

  • member icon

Reputation: 5519
  • View blog
  • Posts: 17,109
  • Joined: 25-December 09

Re: That assignment that required using 36 variables...

Posted 15 February 2018 - 07:40 AM

Also after looking at some of the course handouts it appears that older (probably pre-standard) material is being used, ie. pre-standard headers, C-strings without even the mention of C++ strings, raw arrays instead of C++ containers, void main(), main() (and the lack of consistency), etc, etc.

Overall after looking at these handouts I'd say this is one horribly outdated instructor and class material.


Jim
Was This Post Helpful? 2
  • +
  • -

#7 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 2555
  • View blog
  • Posts: 10,255
  • Joined: 03-December 12

Re: That assignment that required using 36 variables...

Posted 15 February 2018 - 07:47 AM

I can second the appreciation factor. But, it leads down a bad road. I have worked with people that took parts of a class and expect that to be how to handle things. It has never ended well.
Was This Post Helpful? 0
  • +
  • -

#8 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6644
  • View blog
  • Posts: 30,937
  • Joined: 10-May 07

Re: That assignment that required using 36 variables...

Posted 15 February 2018 - 10:25 AM

*
POPULAR

"Must use GOTO statements!" -- professor SpectateSwamp
Was This Post Helpful? 6
  • +
  • -

#9 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 6285
  • View blog
  • Posts: 21,606
  • Joined: 05-May 12

Re: That assignment that required using 36 variables...

Posted 15 February 2018 - 11:58 AM

... preferably with labels whose alpha components impart as little context as possible (little_lower where "little lower" means keep scrolling lower down the page), or as misleading name as possible (ex. line_10 where the label actually lives somewhere on line 20042). For future proofing to prevent conflicting with other labels, be sure to suffix with a date time stamp. (ex. line_10_15Feb2018)
Was This Post Helpful? 2
  • +
  • -

#10 h4nnib4l   User is offline

  • The Noid
  • member icon

Reputation: 1276
  • View blog
  • Posts: 1,811
  • Joined: 24-August 11

Re: That assignment that required using 36 variables...

Posted 15 February 2018 - 12:37 PM

And no splitting functionality into multiple functions!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1