quote:
Original post by The1Blade
If they made a small algorithmical change, then they should tell you where they did it, and then you go and easily figure that one line out yourself.
What if its not an algorithmic change? What if its something about the particular software you are using. I''ll give you an example. Note this is an Oracle PL/SQL statement and not C or C++, but the point is the same.
SELECT ''X'' INTO employee_begin_after_jan_31_1999 from employees where employees.start_date > TO_DATE(''JAN-31-1999'',''MON-DD-YYYY''
Now anyone with any PL/SQL (or SQL) experience and probably a lot without, would be able to see that this is trying to find out if there are any employees that have started after the date of Jan 31/1999. But, wouldn''t it be nice if I added a line of comment to it so that you didn''t need to read the sql statement? Something like:
-- check to see if any employees have started after jan 31/1999SELECT ''X'' INTO employee_begin_after_jan_31_1999 from employees where employees.start_date > TO_DATE(''JAN-31-1999'',''MON-DD-YYYY''
Arguably that hardly adds anything to the code as it would be pretty obvious what my code is doing, but I bet I saved you a few seconds, and when time is money....
Now here is where we get to what my point really was about. What if I change the statement to look like this:
-- check to see if any employees have started after jan 31/1999SELECT ''X'' INTO employee_begin_after_jan_31_1999 from employees where employees.start_date > TO_DATE(''JAN-31-1999'',''MON-DD-YYYY'' and rownum = 1
This is an optimization trick. In this case you don''t care how many employees started after jan 31/2000, only that fact that someone has. The ''and rownum = 1'' tells the database server to stop after its found the first one, rather than scan the whole table, which is what it would do without it. If you were inexperienced in sql optimizations or had never seen that before, you might not know what it is there for. A little comment would take care of that.
quote:
Thanks for proving a point of mine, if the good programmers write the code, then it is properly modulized, etc. and the maintenance people could easily figure it out. The only thing that would take thinking are the more complex algorithms, which would take you the same amount of time to figure out with or without comments.
I hardly think I proved a point of yours. I never said ''good programmers'', I said ''more experienced programmers'', they are not necessarily the same thing. And good or not, more experience generally means they have learned more sneaky optimization tricks or a faster (but possibly more convoluted) way of doing things. And I disagree that it would take as much time to figure out the more complicated code with or without comments. But then we are allowed to disagree. We should probably drop this as doubt you will ever convince me that comments are not necessary, and its looking like I will will never convince you or they are.
Bret.