Let met guess; YOU could do better?

Let met guess; YOU could do better?

Attached: 1613489647783.png (828x801, 149.38K)

What's he up to nowadays?

So how does one fix it?
Are you supposed to use switch with enums or what?

regex

I'm a better codemonkey but obviously he did better since he actually accomplished something which shows that getting shit done is more important than being an autistic leet coder.

Attached: 1533925551451.png (540x540, 315.48K)

retard. enums and set/hashtable

polymorphism

change string to Short ID, move switch to an external static function

also this, ooptards cope

holy shit

how can code even be written this badly

>if this.Teacher instead of subclassing
>if options== string opts instead of enums

and the worst of all.

this code seems to set the response of the teacher, ranked by what is the worst they've seen

why not just give everything they can see a "threat level" and sort everything they saw, and pick the most severe one.

I fucking hate whoever wrote this piece of shit

The proper solution depends on how often you need to do something like this, how long the list of possibilities gets, if there's more complex logic in other locations, and whether or not you are going to port to other languages. Some options...

At launch load the keys/values from a text file into an ordered array, then search the array when you need a set of values. In a high level language this would be fairly trivial to implement because you could likely use something like a Dictionary object for storage. And you might even have built in code to load/map a CSV file to the Dictionary.

Another alternative would be to store the keys/values in a SQL database and query that database for what you need. This might seem like overkill but if you did that with all of the user facing language in the application then translating to other languages becomes trivial.

Since this looks like game behavior and it's probably all over the actual program, it might warrant modeling the behavior with objects that are backed by one of the above for message storage.

Now if you only have to do something like this in one or a few spots and you're writing something to be as compact and code/memory efficient as possible...and your list of possibilities isn't going to get too crazy...a switch statement might be the best choice. Except that it should use constants and enumerations.

Fix it by refactoring until it is good enough.
obvious and easy changes are using a switch and proper constants instead of string literals.
As a next step, instead of setting two values each time, you could make it a table (array or map) lookup for the two values.
That might be the sweet spot here. That data can then be moved to a pure data file when it makes sense to do so.
A different approach would include polymorphism but I don't think it's terribly beneficial in this case.

damn shut up smartass

might as well start putting makeup on pigs

that's my fetish

This would be like 3 lines of prolog

same old same old

Attached: file.png (920x896, 665.53K)

I always thought making games was like an impossible task, but that pic is actually weirdly optimistic.

Tldr put into array and iterate over values.

based retard

YanDev
never learned
switch case

Attached: YanDev.png (629x430, 527.61K)