New Member
Hi everyone.
I'm currently going for my Associates degree in programming. My instructor told us about this site and encouraged us to join.
Any help anyone could offer me by way of advice would be appreciated.
Thanks.
IT Employment
Hi everyone.
I'm currently going for my Associates degree in programming. My instructor told us about this site and encouraged us to join.
Any help anyone could offer me by way of advice would be appreciated.
Thanks.
by djameson
by jaqui
this is the best way to make code readable.
a comment just before a function to explain what the function does, will always help decipher the code in the function.
( since function names are not intuitive to all, even if the name is to you )
Var
NumberOfInvoices : Integer // The Number Of Invoices
Procedure PrintInvoices;
// This procedure prints the invoices
Var
lp : Integer; // LoopCounter
Begin
//Loop though the list of invoices and print each one
For lp := 0 ToNumberOfInvoices - 1 Do
InvoiceList[Index].Print;
End;
Great eh, but this is all too often what people do when told to comment, comment, comment.
Drives me f'ing wild. Total complete utter waste of time, effort & resources and on top of that counter productive;
Comments should be restricted to why, they should be sectioned off somewhere relevant, but they should not break up the flow of the code, nor should they be so far to the right you have to scroll across to read them.
If comments are required to understand what the code does then it isn't readable.
They are useful on occasion though.
An example I ran into yesterday
Procedure TMyObject.FreeResource; Override;
....
Procedure TMyObject.FreeResource;
Begin
//Stubbed out to avoid calling parent's method.
End;
Great I can see that, why wouldn't you want to free the resource though ? Answer after some investigation on my part having looked at how the parent's methods had been overridden or hidden was the resource was never actually allocated and the stub was to simply avoid a warning of abstract methods in a created class message at compile time.
Now that in the comment would have saved me half an hour's investigation. Needless to say the comment has now been beefed up for when in six months time I or some other poor wally has to go near this code again.
Annotated code only helps if the annotation is helpful, the comment comment comment approach is for languages where there is a serious limitaion in the naming of entities.
I' always consider comments in code in a modern language to be an indicator that I know I've written it poorly.
There's nothing wrong with a bit of blurb at the top of the file describing what's in there though, any pre & post conditions, god forbid implicit dependancies etc.
by hgbryan9
To add on what S junkie said, this is surely the right place for you. Pls try to make the very best of verious section, and make sure you set your focus before logging on ( define your goal(S)). As well, try to ask as much question you can, and make the difference.
At a close, I wish you all the very best, WELCOME...WELCOME....WELCOME....
by itgirli
I hope your instructor knows what he has gotten you into.
We're really okay here.
Really.
Not crazy at all.
by djameson
by m_quy
You all have been really helpful. I'm really enjoyin this site, and all it has to offer.
gonna change my name to RealityBytes (not email address)
Look forward to meetin all of ya.
by the admiral
First, Comment in your code, so people who come after you know how to fix it.
Second, Subroutine, Subroutine, Subroutine. I can not tell you how many times I have seen people re-do code over and over again when it would have been better to put in a call to a subroutine to take care of the problem.
Third, Make sure your programs clean up their trash. Every launch of an application makes a temporary file. Make sure when you hit the close button that it whacks the temp file before going south. I have seen XP systems crash because temp files don't get whacked.
Fourth, Don't re-invent the wheel. If you can get code from a free source, comment that the code is not yours, but theirs, then change it to fit your needs. Object-Oriented programming is just that, re-usable code.
Last, you will not write any code that has not already been written. So when you get stuck, ask!
This discussion is closed to new replies.
Sort by Trending