|
|
|
|
|
by NAFV_P
4567 days ago
|
|
> I look at this from the other side as well. I've worked with brilliant people with ivy league CS degrees who wrote much messier and less maintainable code than me, an autodidact designer/js dev with 1.5 years of experience. Maybe I'm wrong, and there was something in their code that I wasn't seeing, but I don't think so. I would have ignored your comment were it not for you mentioning that you write javascript. I started learning it on and off a few weeks ago, and yesterday I installed spidermonkey as a standalone shell. What I have noticed is that a lot of the syntax that controls flow is very similar to C, which is notorious for being gibberish. I'm guessing the same will apply to js. I do not have a CS degree, but would you say that this is readable? This is a function for extraction of nodes in a double linked list that I am currently kicking into shape. /*
* extract *p__ from p__.
* but original *p__ is shifted left or right \
* if there is still space.
* extracted ndi* is returned, but the remainder of the list \
* is sewn back up.
*/
ndi *extract_ndi(ndi **p__, const int dec) {
ndi *q_=*p__;
if(dec>=_PREV_) {
*p__=*(q_->lnk+dec); /* the shift */
if(*((*p__)->lnk+!dec)=*(q_->lnk+!dec)) { /* sew up */
*((*(q_->lnk+!dec))->lnk+dec)=*p__;
*(q_->lnk+!dec)=NULL; /* burn ends of extraction */
}
*(q_->lnk+dec)=NULL;
} else if(dec==_LONE_) /* final possibility is that *p__==NULL */
*p__=NULL; /* ie. dec==_DEAD_, no which ain't it not worth man */
return q_;
}
What the hell was I smoking when I wrote this? I can't even read it myself.Writing convoluted code is more to do with a certain state of mind. You should ask your coworkers where they obtain LSD, not where they got their degree. I haven't come across any acid for about a dozen years, I think it has gone out of fashion. Of course if this was Perl it would be even worse. |
|
It's what you get for being lazy (non judging here, I'm guilty of it too) and not naming your variables accordingly. When you write the code you probably know what ndi, q, p, lnk, etc. are supposed to mean. But then you leave the code for some time and when you return you are lost. Just write out variable and function names so that your code reads like english - programming Obj-C for some time really helped me there :)
And with pointer-heavy code I tend to create aliases for offsets so I don't have to write out things like *(q->lnk+!dec) every time I reference that specific address.
Yes, maybe it will cost me wizard points with colleagues because they start to understand my code but my sanity is it worth to me ;)
(Also trailing/leading underscores are the devil!)