Coding horror.

Status
Not open for further replies.
I previously had to complete an Android app that was started by another guy. Now I'm debugging an iPhone version of the same app, written earlier by a totally different dude. Anyway, despite their differences, these two programs have something in common.

Upon user command, the program must switch between several perspectives. The normal way to do this is to make a few superviews and put all the components associated with them inside. When you need to swich, you hide or remove the current superview and show or add another.

These einsteins hide and show EVERY SINGLE VIEW THAT IS ASSOCIATED WITH EVERY PERSPECTIVE whenever they need to switch. WHY?

Also, 3/4 of the code is in the main file (activity and app delegate, respectively). Makes the code barely comprehensible. And they complicate things further by storing data in an sqlite DB, even though there's no reason to store it at all.

I don't get it. If one man did this, I'd think he's an idiot But when two men do it, the third one starts to wonder if maybe he's the one who's wrong.

EDIT: I keep looking though the program... The sort of inefficient, inelegant coding I described above is even more pervasive than I thought. It's not here and there, it's throughout. There are noob mistakes, there are stupid mistakes, there are mistakes that make you wonder if the coder was on crack, but this is not them. I think this was done on purpose. I don't know why, but it was.
 

andrewme

Senator
7,120
Subscriptor
Kalila":2vazske6 said:
A device driver I was debugging last week had a queue implemented in a curious way. It was basically a char **, where the previous guy always read from 0 and mem copied/shifted all of the entries one by one whenever he had a new addition.

If I had a nickel for every time I saw C# code using arrays and calling Array.Resize(array.Length + 1) every time it needed to append (instead of using a List and calling Append), I'd be rich.
 

fitten

Ars Legatus Legionis
55,634
Subscriptor++
andrewme":2x2qyuuq said:
Kalila":2x2qyuuq said:
A device driver I was debugging last week had a queue implemented in a curious way. It was basically a char **, where the previous guy always read from 0 and mem copied/shifted all of the entries one by one whenever he had a new addition.

If I had a nickel for every time I saw C# code using arrays and calling Array.Resize(array.Length + 1) every time it needed to append (instead of using a List and calling Append), I'd be rich.

Yeah... list.Add() ;) I've seen a few instances of "around the world", too... basically had someone add functionality to some stuff I wrote while I was on vacation. What should have been five lines of code in one function (literally) ended up being (their implementation) completely worming itself through about half the code in that entire subsystem.
 

M. Jones

Ars Tribunus Angusticlavius
9,988
Tiiba":34anr3bg said:
Also, 3/4 of the code is in the main file (activity and app delegate, respectively). Makes the code barely comprehensible. And they complicate things further by storing data in an sqlite DB, even though there's no reason to store it at all.

I don't get it. If one man did this, I'd think he's an idiot But when two men do it, the third one starts to wonder if maybe he's the one who's wrong.

One copied the other, or both followed a specification that you haven't received?

Never store state if you can avoid it.
 

topham

Ars Legatus Legionis
13,756
Subscriptor
M. Jones":13a2mafh said:
Tiiba":13a2mafh said:
Also, 3/4 of the code is in the main file (activity and app delegate, respectively). Makes the code barely comprehensible. And they complicate things further by storing data in an sqlite DB, even though there's no reason to store it at all.

I don't get it. If one man did this, I'd think he's an idiot But when two men do it, the third one starts to wonder if maybe he's the one who's wrong.

One copied the other, or both followed a specification that you haven't received?

Never store state if you can avoid it.

An iPhone app can be interrupted at any time. Any such interruption may result in the application being terminated. A phone call will interrupt the application and the user can, while on the call, switch to other applications starving the device of memory and cause applications to be turfed.

This can, and does result in some interesting designs in some cases. Some are a little over zealous, while others don't go far enough.
 
Status
Not open for further replies.