Ok, my answer was this:
- GetWorld() refers nowhere
- Unnecessary copy by value in PrintArray function. It will trigger a copy of quite a big array.
I didn’t include pointer check because I cant substantiate it.
Ok, now the funny part. I’ve received this feedback:
- the candidate missed out on the main issue, which is the lack of UPROPERTY() macro. A couple of mistakes were not pointed out as well (spawn of 100k actors at the same time, potential nullptr Actor, const keywords)
UPROPERTY macro missed… It was the main issue…
Nobody here is quilified enough to work in this beautiful company.
Check out the other mistakes: “spawning 100k actors.”
The author of the code must have been told to spawn 99 999 actors instead. But he spawned 100k. Obvious mistake, I feel ashamed, how could I miss it.
“const keywords” - ¯_(ツ)_/¯
I requrested a more detailed feedback of course, and check this out:
1) ”spawn of 100k actors at the same time"
This function was not addressed as expected. UE4 does not have limitations when it comes to the amount of actors that spawn. However, this outcome would have a significant impact on the device’s resources. It is always important to evaluate whether your solutions will have an impact on the performance of the game when working with any given device’s limitations.
So, if you do something that have a significant impact on the device’s resources - it’s a mistake. Remember this, guyes.
2) ”potential nullptr Actor"
spawnActor returns a pointer that can be collected by GC at any moment if it is not secured properly. It is always a good idea to check actor’s pointer validity. Actor could get destroyed between the moment we spawn it and we print the array.
*spawnActor returns a pointer that can be collected by GC
So, you can spawn a monster that attacks the player and disappears 2 meters away because it was GCed. Everyday’s situation I must say.
that can be collected by GC at any moment
Can you imagine that? At any moment. GC must be running in a parallel thread, so the object could be GCed even before you assigned the pointer to anything. It can be GCed even after you have checked it existed, so you have to double check it, but better tripple check, just for sure.
It is always a good idea to check actor’s pointer validity.
Yeah. It’s good idea to check if an object was GCed or not by checking a raw pointer. Good suggestion. I’ll note that.
Actor could get destroyed between the moment we spawn it and we print the array.
Oh my god! It can be destroyed even before SpawnActor() exit!
- ”const keywords"
This is an example of an area of improvement according to the code standard that was shared in the description of the technical test. Here are some examples of where this could have been considered: (doesn’t matter)
Yeah, it was shared indeed. Coding Standard | Unreal Engine Documentation
So, I was supposed to figure out that the given example must follow the linked coding standart, and read a thousand lines document within 15 minutes that was given for the task.
I admit, I failed.
- ”UPROPERTY() macro"
Usually we consider code example as a UOBJECT and use reflection macroses properly, however, your example requires a few improvements to avoid misinterpretation.
What? My example? What my example? What’s an UBOJECT? You consider code example as a UOBJECT? How cares what you consider? My example requires a few imrovements? So, your code example does not require a few improvements and it can not be misinterpreted?
I can not understand. I need a translator from Indian to English.
Now, I share it because I found it not just stupid, but ridiculously stupid.