Re: 1 step or many lines?

Tech-Archive recommends: Speed Up your PC by fixing your registry



"Ant" <Ant@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:2F3C9B98-
44CA-4E05-A3C7-8A0648A255C7@xxxxxxxxxxxxx
> Hi,
>
> I'm wondering how most developers think when coding with regards to
> steps of code. Is it best to have as much done as possible on one
> line, making the code faster, or is it better to break it up a bit so
> that it's more readable & easier to debug? As a simple example,
> concatinating strings, or setting up an ADO object in code.

for simple operations like building a string with multiple concatenations
I'd say one (continued) line is fine. I'm not sure what you mean with the
ADO object example.

For complex statements I much prefer code that has been broken down into
simpler, more discrete steps. If makes understanding the code months or
years later much easier and usually the difference in execution speed is
negligible at best. If you have a short bit of code that is
computation-intensive and which runs many thousands of times then it may be
worth optimizing for speed over clarity (provided you include comments that
itemize the steps) but for that most part clarity wins the battle easily as
far as I'm concerned.

> For that
> matter, is it best to set as many properties using the properties box
> instead of in code? Does this also increase code efficiency?

I doubt it'd make much difference as it doesn't take much time to set
initial properties and that's normally done only a very limited number of
times. There are advantages to doing it via code when it comes to
maintenance but since it's simple to check the design-time properties I
don't find that to be a big deal either way. The only thing I do limit is
never setting multi-line text properties or listbox contents, etc, at design
time since they are harder to work with.

--
Reply to the group so all can participate
VB.Net: "Fool me once..."

.