
Helloooo! I am Moose! They/Them/He/Him I am a embedded software engineer with autism, depression and anxiaty ( Wooo! ). I post about... whatever I want... software things, mental health things... whatever I feel like Feel very wellcome to send me asks about... anything that strikes your fancy :3
266 posts
(Nearly) Never Use Auto In C++!!!
(Nearly) Never use auto in C++!!!
So I used to be amongst the people who thought "Yeah ok, auto hides the type. But if the type is not really important to understand the code, and was really long and confusing then it is worth it"
Like this: std::vector<std::pair<std::string, Employee>> MyFunction(); To turn it into: auto MyFunction();
And I was wrong. Do NOT use auto to hide that monstrosity. You FIX it. auto hides that awful thing and dumps the problem on the next poor fucker who will use it. ( People writing and using metaprogramming libraries are especially prone to doing this, since their typenames can fill entire screens ).
YOU just looked at YOUR code. Found it confusing... And decided... to HIDE it??? What it is the next person who did NOT write this code going to do when they read this going to do???
No. I beg of you. Use typedef.
You can create aliases of anything and make your code easy to read. And this only "hides" the code as much as auto and you can get the types the alias points to by musing over it. So it is auto... but way better. Because it is a UNIQUE name. Which can DESCRIBE things.
Like, with the horror in the previous example. Let us have a typedef in the .hpp file where "MyFunction" is declared. Now it reads MUCH better:
std::vector<std::pair< Employee_ID, Employee>> MyFunction();
I actually understand what the pair is now! Key value pairs! And screw it. Let us typedef the pair too now that we understand it!
std::vector<Employee_KeyValuePair> MyFunction();
And fuck it. Once more! Typedef the vector too!
Employee_Roster MyFunction();
I will bet most of you reading this only realized what the hell that moster was when you got near the end. BECAUSE THE FIRST THING IS FREAKING UNREADABLE! Fix it. Make your code readable. If you feel the urge to use an auto to hide a typename, it is time to typedef that motherfucker!
-
trishfishseven liked this · 8 months ago
-
steve-cat liked this · 8 months ago
-
rorschach-black liked this · 10 months ago
-
nikki-blogging liked this · 1 year ago
-
lidge-soup liked this · 1 year ago
-
sweetpoetrygladiator liked this · 1 year ago
-
darlingvagary liked this · 1 year ago
-
apotheologie liked this · 1 year ago
-
colorfulcollectorpirate liked this · 1 year ago
-
ryuji-terix reblogged this · 1 year ago
-
bovid-beauty liked this · 1 year ago
-
stuck-in-unova liked this · 1 year ago
-
jolene757 liked this · 1 year ago
-
captaintarin liked this · 1 year ago
-
green-mountain-goose liked this · 1 year ago
-
cyberfolktale liked this · 1 year ago
-
quirkyplutonian liked this · 1 year ago
-
liiht reblogged this · 1 year ago
-
growtiredofpublicvulnerability liked this · 1 year ago
-
magnolea liked this · 1 year ago
-
deadstrides liked this · 1 year ago
-
hayacode liked this · 1 year ago
-
quietmarie liked this · 1 year ago
-
wolfmestize liked this · 1 year ago
-
zukulini reblogged this · 1 year ago
-
zukulini liked this · 1 year ago
-
brudiza-spudnik liked this · 1 year ago
-
velvettroupe reblogged this · 1 year ago
-
velvettroupe liked this · 1 year ago
-
genderfluid-dynamics liked this · 1 year ago
-
dessometrics liked this · 1 year ago
-
lady-inkyrius reblogged this · 1 year ago
-
lady-inkyrius liked this · 1 year ago
-
dabub167 liked this · 1 year ago
-
kodicraft reblogged this · 1 year ago
-
i-love-linux-and-reject-gender reblogged this · 1 year ago
-
yourlocalnerd07 reblogged this · 1 year ago
-
nourhanlwt reblogged this · 1 year ago
-
nourhanlwt liked this · 1 year ago
-
lljramirez liked this · 1 year ago
More Posts from Moose-mousse
Denmark... is a elitist, right wing country
( Trigger warning, if you do not wish to hear about my political posts, blacklists the tag Danish Politics") So I am a Dane. And weirdly enough for my atheist, polyamorous self, I actually do want to be proud of my nation. And I AM, of several things Denmark have done... But overall? No. Denmark have widespread corruption ( A test in the spring of 2023 of "Who is willing to take bribes if we offer them 50k DKK (About 7.5k USD)" had 91% of politicians in parliament saying yes please) but a lot of the success of Denmark is based on what people THINK of Denmark, rather than what it actually is. For example, I finished university currently. And not only did the Uni teach students a way of doing databases that was in direct breach of GDPR (I documented this, and still have it all, since at the end of my education, I did not trust the university at all), but in at least 4 classes, the teacher did not bother to define what the students had to do to pass. In my robotics class, our final papers definition was "It must be 5 pages". That was it. No topic, no focus, no anything. You could still fail, but the requirements was inside a professors head, and you had to guess. If you ask the universities they will tell you that they received basically no complains. They forget to mention that there is no way TO complain. Despite this completely incompetent behavior, people having a danish education is thought of as high level. Because we used to be. Basically anything good you hear of Denmark, is inertia from its behavior in the 1990s (30+ years ago). Today it is a corrupt, right wing extremist state like so many other disappointments. We still have rights, but they are getting removed. And the majority of Danes do not care. They are busy yelling their sympathies to Israel.
Fun fact. Markdown... is a markup language
If you do not know what markup is... you should look it up. It is basically HTML that works both encoded and as clear text. Meaning it is the perfect note taking "language". In reality it is "just" a convention for how to write super nice-looking notes that have been tested by millions of people to be the very best it can be.
No big deal.
Oh also it is free, you do not even need a special program to look at it. Your browser can do it perfectly.
This is freaking amazing. And I think you are making good choices in simply cutting away what is not working so you can make your deadline.
I am still curious though.
Power banks are freaking temperamental little bitches ( There is NO standard for when they should give charge, other than the vague " When a phone is connected" ). How did the environmental sensor not like it?
And did the programmable RGB have a datasheet to explain the logic of how to address LEDs?
And would it be possible to adjust the addressable LEDs by powering them with a PWM signal? ( IE, is it powered by 5V? )
Servo skull integration is underway!
I have run a few tests and the core functionality seems to be working fine - so I can press the button and it'll take a picture with the camera embedded in the left eye socket, briefly illuminating an led that's in the right eye socket and playing a buzzer briefly.
The green led turns on when the program I wrote is running, and if it's connected to a network the orange led will also turn on(so I can tell whether it's accessible to get the pictures off of it)
So it should be all good for MCM London on Saturday at this rate, just need to check that the cranial casing for the left hand side won't affect the picture too much


Had to remove the environment sensor as it didn't like that it was being powered from a power bank - so no temperature alert when it gets too hot for me(It was going to light up the remed if the temperature got above 30°)
Also had to take off the programmable RGB array, as whoever wired that integrated circuit was clearly on a great many things when they designed it - Trying to just access specified lights was madness. The first led was accessed through (0,1) whilst the 2nd was (1,1) and the third (6,0). And having all of them on made it looks like the skull was about to self-destruct with how bright they are
Hmmmm.... I would have to do some math to be sure, but you usually write 0x to indicate hex ( 0b for binary).
So 0n66537... I would guess meaning it is in base 66537, or maybe base 66?
Which would run you out of letters of the alphabet... So what if each number character is represented with 2 characters?
So 10 would mean 1 but 11 would mean 1 + (26+9). So 36
Maybe?
Hex 0n66537uyyx9lyv12kypxmnaku5ch2fe4khvfxemu24y5uih2oext7437v82fwuiqkhu40m1jeey9zjvn34vn7i72lcpuopl0jcyf8ak394u0x0xt6yc9mxylbiwsj36sttut00pqhtjtlz2d8ur9ljaetingeaqi4z4xpn4785n69ymxi1gby4f8jgetm8n28uy23h9kcgukpetibd2b4f9cxhxqx0ptmyj1p2crbb4mclksraugkwo1lpteaoroxk1li6hx6r03wudisu9mkzcmc29wbixyyle81yxejwmuvhbs7jfr5q69o6pwbt259upwc7cdpa6l16xyh4m5lrn39bb9478kv9o6jrzgna1bj5ak449e8arxdto4cvnp7nof2gmb9eyxexrop351ojqbb8nf76nh8okh69pjea81el0khxngckwlqt5qh41i6gbvw5fuk2nuew5ix98b2azf621d61knkhfetrfvnbsojk3ushi3hm4uxwyf7l16t549ngp3wuibzxgp8tv729vi1ys0ydsipx7b7yxeqvpjv12se2iv938sstiq6uzoziuc7sn6qi9c14e4hmxgzh2iz8gzt8307mhlrgu58ka0opa5rcix93wk7qhiad04mruweg196zgn58rsmkcuimetzv9i3b6bhn0ft9wuf1h8riq96xbg28fvj99bjy6ms7fblrwizu4elt9r9a76myrcvkt7z9epo7fp3s3icyqeq4l6l3t7hyec2k9ft1cpmm2aqa4itflg6a325rdkb0n3rhdeyadpox277tag16o2zdnunhunp6m6gh0fpqfa3dzx22tjxx59ztlue2t7wwm61ahtxwxp6g8j72yd2k6div2vjg4z366rvsnvpm1rad07g2lkfbz20x5bxcg3thdo3jmpg2fld4ny7wyb7kmfdavs9kbeg55n09b3gl3tmepw2m6w0neor3pz713rtt5sc24jfnybuunpwc3jo627wr7dveyixb9pase7pb1klracijr5j3fccyyvg27nbaykbpf83zcjikxcsjj34no83mtm52jh64wccbh0553nqycwzmq8jsz9hznx9tzym8p1jbp99en59i6gsq2fjknay0mxzugobmdxn97ovl4mj9jy2sp6bh53toaxuxgef64k73m1866m4os5zjouuz82vnypn9pp9ttx3jvbh9iutr3vl3usveiuxikgth3slf5g1owbp4ta8ih2eaeyp039oxqu4ogq01izc7hkmg6r6epycb2fcjpxhz51wnr4f7c3o67gow26nz57ubztrc92zs9ajpx3mkqt02hp7bkcc40kz1p7dsy6oy05g0tcoqcrazg3mb3afin7eg3edg572u4346vevst3hr09vw6jr4btrqwu26wali6wz43cwqi610cmjtopsdztn85grare1aprxol978fbgostwyjlrj92k6xcsu0zqq8hns8pwaliqxd3jm8n3j73n0zy8ey870ynpwankg3pylr2qdi0eavvyx4mtx0xsiro8s75kzx9vmvv0nlraikvwunbo4hybsrevdi83etgrg9p1p3n0rgxsect9vam5tiuip6dn9pzrg5hy5zpzjiqc9x5ohbo5qnbp8dccjli7r7vskhgmajmvfczjit8cbcdhwms16tkjt3b1i8rndlcn528y4vd8it0txcwg41w6q6bth36ljn4x2o44zc9wga52rdzhz03h68ughkgrcbq7ik1hmqbrzookj4ljuus0e1hj8ljlt6onmxozxtn48g6t00zaxmxfb2y4oky4w1xe1j7cwrac4xqkfujxldbz1zvyn43bcfh6e4two9bpe1sifusb8bol6j8rau26tuvfza05r6941xk1c3qgjf2uinsq3ps9kdxie5cx1o8cwhw4l4ikev6yc7q18yyz2ocn7m0cuo7eytomxswz0v732dbribuagbq5cez4f3xrlmk411wts3v9dio8r23gr8uky3kqar1iyy4lojsqjtzs49gg3ptkij1lcbvksr83tk7yc357w95hinfm3bukngqnsu6v8zcn9dt55cpjul7c7fl152t4cbzvpd2adqmbg6wjhqij2vmf5nglv5xi5kwfz4uys5segniu3pyva8fjj7ttsgr9kujf0irxkopueg29ztue2gn733rrd81byp1m7waqhm6b6s1t5jl03ku7k5xrkhi0kd5juaumq26wy8syaw0e4km77qoyw1qkkyv9i8q93i703m0bka4mnflqqcfah6y8ph40x4z36nokd5tt00hxf3dm491ekj64s0ahsgaswyl4i55tepzxutkey4xdrdxy6p9ylgk60pbheygq6198tk25uqkwrbjqqp2o2llwkjpsia7yh4kxd2hiw9euvv1e2pnousxvvs5lk4pxt8ha28tmwjsl5yi6rbfl93snaxe7mpbl41z35xmg2q5nno0t886sx2gisallh7npxkci7fic7cukg68nun6ajf0nhc7jblnvbzoqafqdqqzczk9x6dofbejmdahikl5az3yr1oxndyk5kzaxvnifav0ts88snn402hsu8kob81qnzhuxokwo0raqgnh6wyfsn6ssbmu9jd2uijb4pgfcs4f1wpv7l4w6jmwzkmdrc9wqtptcxfnj5g4uvlaxjjb18bzk7kcabf4cyi1jpwkez9uex7jp7px3a19bv5m3ek4fhnsuc9jpmqkry3qzklvk2tsskvde2x3x7yih79zpfggo67y0e8i9ikfv4muqufyvqm861g08xgh4woou132flzyj8dnk7wmps7nstu6q9f33gfwdsfusuokzoc1fui716b7809welruen45f8z0ici3pnkirdhwl7xr732gee7exbgx0ynl56cx6y07jjc3r90qd0e7hll4wwt9brax7d1s2r4kae24z2hnw6dsfjgkth0srwhus8iaw7xlw8kascd0cyj7odch72myq78lmgkfwmsy2t587oihz13e16h5qzdp63njm1ffg1qvb3bajswgq6ygfnrzsuvmmgrl64udkhb2dg2f0vhe2le3kff65277kldamnf4wvwkwphfcw91pnrnw17tl5fykizj45bn4gknpclhxfyw4kr4uxrsxgvtlzw3qewbs9ywt15s9mc6nssfs6red3os07oehwsehgdml7f29yl5j26i9rdnv5sjj08ypgvg4 w1 s2 v27
am i doing something wrong? i somehow can't decode this from hex
Sharing knowledge is awesome! This inspired me to write... a small novel... which did not really fit as a reblog so I will post as its own thing :)
What’s your take? Should senior developers spend more time coding or coaching more junior peers?