Which Is Better Coding?

And maybe.......thousands of hours wasted in the world because programmers can't find the code error, because they DIDN'T declare their variables !!
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
And maybe.......thousands of hours wasted in the world because programmers can't find the code error, because they DIDN'T declare their variables !!

Michael:

I agree. But I'm saying there is a trade-off.

People also spend thousands of hours typing in informative comments and creating intelligent variable names - and many of these are never looked at again by anyone, ever.

The issue is an optimization problem.
 
There's been a lot of hours wasted on this forum alone because someone hasn't used Option Explicit.

Common example x1Up and xlUp.

Without Option Explicit, x1Up won't stop the code compiling but it will break it at runtime.
 
Peter

It does not take thousand of hours typing this information in.
 
Peter

It does not take thousand of hours typing this information in.

Norie,

I might be off, (I have been before!) but I based it on:

Population of US: 310 million
Number who are programmers: 1 in 500
Number of programers - absolute: 620,000
Coding hours per year per programmer: 2000
Total programming hours per year in US: 1.24 billion
Percentage of time spend on superflous programming: 3%
Hours of superflous programming: 37.2 million

Margin of error +/- several million.

But you're right - it's millions, not thousands.
 
So question is: where is the line between simple and complex?
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>

Here is my take on this subject, by the way this should be in the Lounge instead of Excel Questions.
1. You wrote the code
2. You understand it
3. You will maintain it
4. You will fix it when “broke”
5. It was written just for YOU
6. You could care less after you are gone

THE LINE_________________________________________THE LINE

1. You write the code in a more understandable way
2. As Norie stated, Option Explicit, Declarations, Variables, Comments, etc. all help long after it was written(years in some cases) to fix any problem or add to it
3. If writing code to help “others” the above is all good for their learning experience
4. Easily adapted once YOU are gone
<o:p></o:p>
So the question is: have we got the right balance?
<o:p></o:p>

That is a question that only YOU can answer. What do YOU want to do or achieve.
 
I think Peter has to be trolling, at least partially.

But on a related-to-formal-programming note, what type of environments do professional Excel-VBA programmers typically work in-- as consultants or within a large corporation? Is their a concentration in any particular industry? Are the applications predominantly front-ends to databases (SQL/Access)?

Do corporations have IT-help positions related to solely Excel?
 
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
Here is my take on this subject, by the way this should be in the Lounge instead of Excel Questions.
1. You wrote the code
2. You understand it
3. You will maintain it
4. You will fix it when “broke”
5. It was written just for YOU
6. You could care less after you are gone

THE LINE_________________________________________THE LINE

1. You write the code in a more understandable way
2. As Norie stated, Option Explicit, Declarations, Variables, Comments, etc. all help long after it was written(years in some cases) to fix any problem or add to it
3. If writing code to help “others” the above is all good for their learning experience
4. Easily adapted once YOU are gone
<o:p></o:p>
<o:p></o:p>
That is a question that only YOU can answer. What do YOU want to do or achieve.

Agree about "should be in the lounge" and I like your "line graphic", but I think you've rather missed the point when you talk about "you this" and "you that".

The issue is about the complexity of the code and whether it justifies a certain degree of comment and variable-naming consistency. Not about who wrote it.
 
If I have work I need done, I prefer to hire someone that does it right every single time, no matter how simple the job is.
And by "Does it right" I mean, follows the same rules and procedures in place for their job. Every Time.


Take your car...
If you need some maintenance done (even a simple oil change).
do you take your car to Wal-Mart, where they find the quickest cheapest way to get the job done?
Or do you take it a mechanic you trust to do the job right every time?

I would rather spend the extra minute or so to declare my variable, then spend several minutes or hours chasing down a problem because I misspelled the variable.
Or Even worse, you didnt' realize you misspelled the variable and assumed the result of the code was correct, when it actually isn't.
 
If I have work I need done, I prefer to hire someone that does it right every single time, no matter how simple the job is.
And by "Does it right" I mean, follows the same rules and procedures in place for their job. Every Time.


Take your car...
If you need some maintenance done (even a simple oil change).
do you take your car to Wal-Mart, where they find the quickest cheapest way to get the job done?
Or do you take it a mechanic you trust to do the job right every time?

I would rather spend the extra minute or so to declare my variable, then spend several minutes or hours chasing down a problem because I misspelled the variable.
Or Even worse, you didnt' realize you misspelled the variable and assumed the result of the code was correct, when it actually isn't.

... but surely it's a trade off. If I only want milk, and Wal-Mart is cheaper, then I go for Wal-Mart (i.e, a non-complex coding module) but, as you say, if it's a more complicated requirement (oil -change = more complicated coding) then Wal-Mart might be a bad choice.

In other words: sometimes...

For x = 1 to 12

... is just fine with no declarations and no comments.
 

Forum statistics

Threads
1,214,918
Messages
6,122,241
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top