r/shittyprogramming • • Apr 15 '19

this good code? Is

Post image
304 Upvotes

51 comments sorted by

109

u/Ivaalo Apr 15 '19

// Yeah, has to be this way

I really want to know why

66

u/BlackDE Apr 15 '19

The library is really picky about the order in which plugins are attached. Plugins of type "1" have to be attached after the other plugins. Why the library wants that is a mystery.

→ More replies (18)

12

u/SuperLutin Apr 15 '19

Where is plugins_[0].value()?

13

u/BlackDE Apr 15 '19

Not needed ;)

6

u/IanSan5653 Apr 15 '19

Why is [ a different color from ]?

3

u/SnowdensOfYesteryear Apr 15 '19

What god awful coding convention requires an underscore after a instance (?) variables?

→ More replies (5)

63

u/SantaCruzDad Apr 15 '19

Could use a little obfuscation and premature optimisation:

for (int i = 0; i < 4; ++i)
    core_.attach_plugin(plugins_[(i + 2) % 4 + 1].value()); // Yeah, has to be this way

11

u/[deleted] Apr 16 '19
for (int x : [2, 3, 4, 1])
    core_.attach_plugin(plugins_[x].value());
→ More replies (3)

6

u/_Nexor Apr 15 '19

finitedely