Fortunately not
Why on earth would you want multiple statements on a line ?
What about code clarity ?
Christian Desbourse (Belgium)
The short-hand iif() statement is an example of multiple
statements on a line.
Marc Desjardins
Vancouver/MR, BC
Canada
>.
>
--
Fred
Microsoft Visual FoxPro MVP
Please respond only to the newsgroups so that all may benefit.
"Marc" <itprog...@hotmail.com> wrote in message
news:605901c112d9$21af3be0$a4e62ecf@tkmsftngxa06...
> It would
> reduce vertical clutter, especially in constructs and
> loops.
Vertical clutter? Hm. Even though I personally _like_ really tight
constructs and IIF(), there is actually support for the assertion that
this the _wrong_ way to go, and so I have to disagree (not that I'm
likely to give up all my IIF()).
1. What you call vertical clutter is one of the least important reasons
to chose a style because once the routine is written, it should never
be revisited except for maintenance or if a new person on the project
needs to be familiar with the code, in which case what you call clutter
would be self-documenting code, which is a Good Thing (tm).
2. There are studies that support the assertion that single command
lines of code are less prone to have bugs. Another Good Thing (tm).
There is no optimization since the compiler will do that regardless of
any editor style.
There is _a_ case where something is vertically cluttered (I'm quite
enamored of that expression <g>), but the solution isn't to mash the
commands together. That case is when you have a block of commands that
compose a routine that you use in more than one place in you code. In
this case, you would write a function and call that. Vertical clutter
is gone, the code is nicely encapsulated for changes, and self-
describing.
The only time it's nice to be able to mash commands together is when
you have to deal with code blocks, but VFP has other ways of
implementing that concept.
--
Nancy
So that all can benefit from the discussion,
please post all followups to the newsgroup.
sele icmaster
dele
skip -1
sele icmaster; dele; skip -1
>.
>
In article <607f01c112e9$4d6020f0$a4e62ecf@tkmsftngxa06>,
itprog...@hotmail.com says...
> Hi Fred,
> Do you work for the Microsoft VFP development team?
Huh? No, Fred's not an MS employee.
> I have worked in commercial software development in
> several languages (mostly C/C++) for the last thirteen
> years and have had no opportunity to work with BASIC.
> Just want to condense some of the high level commands.
> Maybey better to call udf's or should I leave it the way
> it is and get the job done :)
I think leave it the way it is.
>
> sele icmaster
> dele
> skip -1
>
> sele icmaster; dele; skip -1
Less readable. Less extendible. No more optimized. Doesn't even look
pretty. <g> Indeed, if you were a programmer in my shop, I'd insist
you write the commands out in full. Unless you're writing one-off
programs.
C++ isn't VB or VFP or Delphi. There's a whole different mindset that
I'm guessing you might be having a little trouble leaving behind.
>.
>
Hey, what's life without tangents?
> I'm going
> to do something out-doors for the rest of the day.
> Thank's to everyone for their input.
:) Sounds like good advice that I should take, too. If only I can
finish this *(%*#@)@ article. <g>
Give me one command per line any day. For that reason I am not keen on IIF,
particularly nested IIFs, even though I use them because they are so handy !
Cheers
Stephen
>:) Sounds like good advice that I should take, too. If only I can
>finish this *(%*#@)@ article. <g>
Nancy, please keep your expletives to one per line :-)
anthony shipley
<math> 2 + 2 = 5 for sufficiently large values of 2</math>
Oh. It was unclear? Sorry about that. ;-)))
I'd rather shoot myself. :-(
You have my sympathy. BTW, interesting factoid, variable names between
9-15 characters lead to higher comprehension. Cite _Code_Complete_.
Procedures probably should be about 15 to 25 characters long to
facilitate comprehension.
> I'd rather shoot myself. :-(
9-15?? hahaha...(see attachment 2)
That may explain why all the original developers had left the
company.
--
Fred
Microsoft Visual FoxPro MVP
Please respond only to the newsgroups so that all may benefit.
"Marc" <itprog...@hotmail.com> wrote in message
news:607f01c112e9$4d6020f0$a4e62ecf@tkmsftngxa06...
VFP doesn't need to save the space in the source code the way that dBaseIII
and QBASIC needed to, back when each and every byte of space was important.
It's just not worth the savings for the lack of clarity. In fact, in the
compiled p-code, there will be 0 savings, both versions will evaluate to
exactly the same p-code, so why not make the human readable source code as
clear as possible. Do you also leave out comments? ;) (something I've been
accused of in the past)
--
Fred
Microsoft Visual FoxPro MVP
Please respond only to the newsgroups so that all may benefit.
"Marc" <itprog...@hotmail.com> wrote in message
news:837501c1133d$1eb425e0$19ef2ecf@tkmsftngxa01...
>No, I do not work for the VFP development team, but I do have about 17 years
>experience with C/C++, 22+ years overall in software. Even though you can
>do multiple commands on a single line there, I still don't recommend it.
>Just because you *can* do something doesn't mean you *should*. I still find
>it hard to decipher code (mine or anyone elses) that's bunched together
>instead of using lots of white-space (vertical or otherwise). And the
>resultant machine code is no smaller even if you do cram it all together on
>one line, so what are you saving besides disk space for the source code?
One reason for not concatenating several commands onto one line is that it makes
it harder to scan the code when looking for a specific command/word/comment.
Instead of scanning along the left edge of the code, you now have to scan along
each line paying much closer attention.
<shrug> The shortened names are a holdoever from xBASE days, and
constrained by the length that was allowed then. Not everybody coding
today was around then. I use indoor plumbing, too, instead of an
outhouse. <gd&r>
Seriously, with VFP you can type abbreviations and intellisense fills
in the full name.
Funny. That's the only one I abbreviate, too. I think it's from a
Clipper command that was just EVAL, but I might be remembering
incorrectly.
I usually start out abbreviating MODI COMM, etc in the command window.
1/2 the time tho' it takes longer to remember I can abbr than it takes
to just type it. <g>
> One reason for not concatenating several commands onto one line is that it makes
> it harder to scan the code when looking for a specific command/word/comment.
>
> Instead of scanning along the left edge of the code, you now have to scan along
> each line paying much closer attention.
Exactly. "If my code was hard to write, it should be hard to read."
<vbg>
> 9-15?? hahaha...(see attachment 2)
> That may explain why all the original developers had left the
> company.
Worked with a guy once who always proclaimed that long variable names
were for people with weak minds. <g>
>.
>
>.
>
--
Fred
Microsoft Visual FoxPro MVP
Please respond only to the newsgroups so that all may benefit.
"Marc /k" <itprog...@hotmail.com> wrote in message
news:6b9c01c113cf$528217a0$9ee62ecf@tkmsftngxa05...
Heh. No I was serious. I really do like the term "vertical clutter." :)
Nah. We're just all an opinionated lot. Except for me, of course. ;-)
How could you trace a variable named "CT" in a program during
maintenance.
The two columns in the code fragment below is supposed to
be aligned. Not sure how this messagebox is going to
treat it. Lengthy lines of code are divided up onto
several lines as below. I do this for all lengthy
statements. It's not a big secret ;)
create cursor curArReport (;
cinvno c(10),;
ccustno c(10),;
ccompany c(40),;
dinvoice d,;
ddue d,;
nbalance n(14,4))
if ((condition 1................) or;
(condition 2................) and;
(condition 3................))
&& statements
endif
It shouldn't take any time at all for a programmer to
interpret common abbrev. function calls like allt(), eval
(), tran(), messageb(), etc.
I do abbrev. variables, however they are explicit.
local lcInvno, lcCustno, lnBalance, etc.
I would not work for anyone who wants me to write
lcInvoiceNumber or lcInvoice_number. You could offer me
$1000K and I won't do it :)
Marc (k)
Thanks to everyone for their insight.
Got to go and get some sleep so I can work efficiently
tommorow. See you all again. Take care.
>.
>
--
Fred
Microsoft Visual FoxPro MVP
Please respond only to the newsgroups so that all may benefit.
"Marc (k)" <itprog...@hotmail.com> wrote in message
news:930701c1140e$3ea409c0$9ae62ecf@tkmsftngxa02...
Mmmm. We had an outsourced component that was rather like that, "Beautify"
actually made it pretty readable in an instant but I was still stuck with
silly var. names.
Makes you wonder why they didn't abbreiviate REPLICATE to REPL...
--
Andrew Howell
I'm not advocating the use of multiple-statement lines but I've always used
the search feature to do that.
--
Andrew Howell
> I would not work for anyone who wants me to write
> lcInvoiceNumber or lcInvoice_number. You could offer me
> $1000K and I won't do it :)
Wow, and most programmers won't even stand up to an employer who asks
them to do unethical things. ;-)
Underscores suck, for sure.
Here's my reasoning for spelling it out.
If you use lcInvoiceNumber (or I have a convention to use No for
Number, there's always exceptions to every rule), and not InvNo, then
you don't have to remember "now, was it InvNo? Or was it InvoiceNo? Or
maybe it was InvNum?"
IOW, abbr. make it harder to remember what your convention is. Or, I
should say, it makes it harder for maintainability, which is, The Great
Turtle willing, the larger part of the project than development, yes?
But, then again, I just type so damned fast and well that Invoice
presents no hardship over Inv. <gd&r>
> In article <930701c1140e$3ea409c0$9ae62ecf@tkmsftngxa02>, "Marc \(k\)"
> <itprog...@hotmail.com> says...
>
>> I would not work for anyone who wants me to write
>> lcInvoiceNumber or lcInvoice_number. You could offer me
>> $1000K and I won't do it :)
>
> Wow, and most programmers won't even stand up to an employer who asks
> them to do unethical things. ;-)
>
> Underscores suck, for sure.
Well, there are times when you need those too. Because
some things do not retain case (like field names). Then
using underscores to separate words is about all you have
unless you want the words to run together.
> Here's my reasoning for spelling it out.
>
> If you use lcInvoiceNumber (or I have a convention to use No for
> Number, there's always exceptions to every rule), and not InvNo, then
> you don't have to remember "now, was it InvNo? Or was it InvoiceNo? Or
> maybe it was InvNum?"
>
> IOW, abbr. make it harder to remember what your convention is. Or, I
> should say, it makes it harder for maintainability, which is, The Great
> Turtle willing, the larger part of the project than development, yes?
>
> But, then again, I just type so damned fast and well that Invoice
> presents no hardship over Inv. <gd&r>
>
Same here. I think I am the most verbose programmer that
I know - tons of comments and descriptive method, field,
variable names, etc. I think the code is *much* easier
to read this way.
-- TRW
_______________________________________
My e-mail: t r w 7
@ i x . n e t c o m . c o m
_______________________________________
Underscores and upper case are great for constants.
#define K_ESC 27
#define XOKAY_BX 0 + 48 + 0
#define XYESNO_BX 4 + 48 + 256
local lcInvno, lcCustno, lnBalance, etc.
It was late at night when I wrote the above :)
Should be lcInvNo, lcCustNo, lnBalance
What could lcInvNo possibly mean in the accounts
receivable module? :)
Look at your reports where the number is displayed.
Do they say Invoice Num, Invoice Number or
Invoice No.
Same with the customer number -
Customer Num, Customer Number or
Customer No.
Think about it carefully before you say anything. :)
Yes, from a business point of view, text book coding
conventions is great! Make the code so readable that you
virtually need no commenting! Then replace the
experienced $40.00/hr programmer with a cost efficient
solution. Nothing personal - it's just business. :)
There is no prestige in being a programmer these days.
Everyone is a programmer. Guess who is perpetuating it?
Stoping here. Starting to fly off the handle again.
Marc /k
Thanks again.
I will never do time sheets! Well mabey for $1000K :)
--------------
Whew. Marc. I hope you got a good night's sleep last night. <bg>
Thank you for your concern.
Marc /k
>.
>
Sleep is good.
> Thank you for your concern.
You're welcome. :)