Yep the proc' i found was way too long.
Since you mentioned IsFunctionPrologue(), I presume you're referring to AnalyzePe32().
It isn't too long. Moreover, it has a number of nested functions which exist because their code is executed in more than one place (as should be the reason for a function and/or procedure to exist.)
As I guessed, you had to use lots of comments to explain the code......
Yes, I consider comments that thoroughly explains what the code does to be a characteristic of good programming but, feel free to disagree.
this is one reason to split it up
No, that's no reason to split it up. Splitting that function would remove the surrounding context in which the code is being executed which would be detrimental to clarity and ease of understanding.
and use descriptive names.
I believe I use very descriptive names and also very descriptive comments. Do you have something against that ? In addition to that, what makes you think that a usually short function name is better than a descriptive comment ?... Please explain what the problem is with having a lot of comments.
Also you have used lots of 'break', 'continue', 'exit' etc. This is just another way to use 'goto'.
Yes, I freely use break, continue and exit. That's WAY different than a "goto" and since you apparently don't know what the difference is, here it is: a "goto" can go just about anywhere, IOW, there is no indication of the goto's target in the "goto" statement itself (the presence of a label is worthless because the label can be anywhere), a break, continue or exit's target is determined before the statement is found, e.g, the target of a break is the end of loop and hopefully you read the source code and know where the "while", "for" or "repeat" started, also, unlike in the case of a "goto", it really shouldn't take much effort to find the end of the "while", "repeat", "exit" target. IOW, while break, continue and exit are control flow instruction they ARE very different than a "goto" in a _crucial_ way, their target, unlike a goto, is preset by the location in which it occurs. Free education for you.. you're welcome.
You should educate your self on the idea of 'one entry point and one exit point.'
I'm very pleased you bring up education... you obviously need some since you can't even tell the difference between using "goto" and using "break", "continue" and "exit". (however, if you read the previous paragraph, you should be able to now. Again, you're welcome.)
You don't need to keep declaring a const/type/var blocks. Once is enough.
No, it's not. There should be one block for every group of logically related variables, types and constants. That's what justifies multiple block declarations. No spaghetti variables, types nor constants. Keep things that are independent separate from each other and, group things that are related.
There seems to be some 'magic numbers' in there. How would anyone know what they mean.....use a constant.
I don't like magic numbers anymore than you do. Please show the instances where non-obvious and _uncommented_ use of numbers appear. Thank you.
if IsFunctionPrologue() then
begin
PrologueFound := TRUE;
break;
end; { if function prologue ... }
This is just one example of atrocious code.
Why do you even need the break ???
Why do you need the comment after end ???
if you had read the code, you'd know the break statement is to exit the while loop. What's atrocious is that you can't figure that out.
I'll give you that the comment is superfluous since it is quite obvious what the "end;" is for.
It should read:
ProloguFound := IsFunctionPrologue;
No, it should not because that doesn't cause the remainder of the while loop to be skipped if the prologue was found.
My recommendation to you is: read the code, if you do, it will be more likely for you to find something that can genuinely be improved (like your observation about the superfluous comment... good catch!)
The one observation you should have made is that the "if not PrologueFound then" which follows the first "if" is superfluous because that statement can only be reached if the prologue has not been found. That test was probably there as a result of code that originally needed it and I later changed and not noticed that the "if" became obsolete. You should have caught that.
Ok, I see you are quite talented when it comes to generating poor suggestions BUT, I'll give you a chance to prove me wrong. Rewrite AnalyzePe32() in the way you believe it should be coded. IOW, restructure my code to fit what you think is right. Note that I'll test whatever you come up with, it has to be as good and thorough as the original code otherwise it will just be junk. Just in case, it has to be as functional as my code, IOW, successfully cover all the test cases. At least you have my code to guide you... I didn't have that.
Show me what you got...