Vagueness of standard tutorials/examples

For other topics related to the FreeBASIC project or its community.
Hexadecimal Dude!
Posts: 360
Joined: Jun 07, 2005 20:59
Location: england, somewhere around the middle
Contact:

Postby Hexadecimal Dude! » May 23, 2008 9:51

MichaelW wrote:It’s common practice among some programming elitists and wannabe elitists. Programmers started using foo and bar for the same reason that some kids use leetspeak in places where it is not appropriate.


foo and bar as established cultural standards for programmers to express generic versions of things. They appear in examples across languages etc., making these examples clearer by removing application-specific information.

I guess it's just like all those elitists who use HTTP instead of allowing any message for asking for stuff off the net, or all those elitists who teach their kids the language spoken by everyone else, instead of allowing them to fumble around with noises.

Bar, on the other hand, has multiple well-established meanings, including some that are commonly used in programming. I have a Webster’s dictionary from 1979 that lists 23 meanings for the noun bar. To most people bar is a great deal less abstract than X, Y, A, B, etc. The educational system preconditions people to expect names like X, Y, A, B, etc to represent abstract variables, and in the absence of a good reason to do otherwise, these are the sort of names that should be used.


Perhaps this is true, though, maybe we should replace all "bar"s with "baz"s (I don't think X and Y are good choices for abstract variables since they are commonly used for co-ordinates. For example, you would expect a variable x_bar to be the average horizontal co-ordinate, showing the weakness of both our points)

Anyway, I'm not arguing against context-bound examples, or examples which use metasyntactic variables other than foo and bar, I'm just saying don't slight the usefulness of foo and bar, or remove foo...bar examples from the wiki, just go ahead and add a context-based example to every wiki page. No-one is going to stand in your way.
Mentat
Posts: 332
Joined: Oct 27, 2007 15:23
Location: NC, US
Contact:

Postby Mentat » May 23, 2008 10:58

Why not create a page explaining what foo & bar are?
Sisophon2001
Posts: 1704
Joined: May 27, 2005 6:34
Location: Cambodia, Thailand, Lao, Ireland etc.
Contact:

Postby Sisophon2001 » May 23, 2008 12:11

Mentat wrote:Why not create a page explaining what foo & bar are?


How about this:

<sarcasm>
"Foo and bar are rubbish variable names to use when you lack the imagination to think of anything more useful"
</sarcasm>

I am guilty of using foo and bar myself, but I promise to try harder to find more descriptive variable and function names in future. The fact is that foo-bar was first used by somebody many of us (including I) look up to, but that doesn't mean that it was a good descriptive choice.

Garvan

Edit: Typo
Last edited by Sisophon2001 on May 23, 2008 13:50, edited 1 time in total.
Mentat
Posts: 332
Joined: Oct 27, 2007 15:23
Location: NC, US
Contact:

Postby Mentat » May 23, 2008 12:59

It's better than just letting newcomers guess at what foobar means. How many will think "It is a metasyntatic variable" the first time? This isn't a big problem for those who've had previous experience with other languages.

Personally, I think names like mySub and num are better.
AGS
Posts: 1284
Joined: Sep 25, 2007 0:26
Location: the Netherlands

Postby AGS » May 25, 2008 9:51

Going back to the original topic (vagueness of standard tutorials/examples) I do not think the standard tutorials/examples are vague. It's just that as soon as you leave the realm of qbasic syntax and step into the realm of FreeBASIC syntax something happens.

All of a sudden you are confronted with a preprocessor that creates possibilites to produce code that gets more difficult to understand. Add to that the fact that at the very least some of the developers have experience with programming in C and the vagueness starts to come.

The use of pointers combined with preprocessor magic and the fact that you can do a bit of OOP with FreeBASIC can produce almost uncomprehensible code.

Ultimately it is up to the programmer to decide what is wanted. You can just use arrays instead of pointers. Using types can be handy even if you just use them to throw together some data. The fact that you can do all sorts of interesting stuff with FreeBASIC does not mean you should? Just leave all those difficult to read examples/tutorials for what they are and go for what you do understand.

Programming should be easy and fun. And talking from my experience with FreeBASIC I say you can have loadsa fun while programming in FreeBASIC. I just leave the difficult stuff alone. And when I feel like it I dive in and have a go at translating some program in a language other than FB to FB having fun while doing the translation (and getting to know a lot of programming languages while doing it).

BASIC = Beginners All-purpose Symbolic Instruction Code

(and don't you forget that :) )
Scottinmt
Posts: 11
Joined: May 09, 2008 15:49
Location: Montana, USA

Postby Scottinmt » Jun 04, 2008 4:40

It's better than just letting newcomers guess at what foobar means.


Foo and Bar have been used as example names for as far back as I can remember. They probably date back as far as the term "BUG" for a program crash. Anyway, in those days programmers were either government, or under contract to the govt. (read that military). Govt. and military introduced society to several acronyms such as: SNAFU and FUBAR. I suspect FOO and BAR were derived from FUBAR. My theory anyway.
Mentat
Posts: 332
Joined: Oct 27, 2007 15:23
Location: NC, US
Contact:

Postby Mentat » Jun 04, 2008 12:28

Scottinmt wrote:
It's better than just letting newcomers guess at what foobar means.


Foo and Bar have been used as example names for as far back as I can remember. They probably date back as far as the term "BUG" for a program crash. Anyway, in those days programmers were either government, or under contract to the govt. (read that military). Govt. and military introduced society to several acronyms such as: SNAFU and FUBAR. I suspect FOO and BAR were derived from FUBAR. My theory anyway.


Before that, I think. There was some website that listed out FOOBAR's history, and that was pretty long.

Anyways, in general, it is safe to assume - when writing the examples - that the reading beginners don't know or care about its history or meaning.
Phydaux
Posts: 11
Joined: Feb 21, 2006 18:40

Postby Phydaux » Jun 08, 2008 13:09

I don't think explaining what or where foo, bar etc. come from will make the examples clearer because they are used because they have no meaning and that is the problem some people have with the examples. But as others have said, it's just a wiki so you can update it if you want.

If anyone is actually using foo and bar in their code then I feel sorry for you and anyone who has to look at your code. Having to spend 10 mins trying to work out what that foo var is for, is 10mins wasted. If you can't think of a good name for a var, maybe you need to stop coding and go back to designing what you want to code, if you can't think of a good name do you even know what you're trying to do?
Hexadecimal Dude!
Posts: 360
Joined: Jun 07, 2005 20:59
Location: england, somewhere around the middle
Contact:

Postby Hexadecimal Dude! » Jun 08, 2008 13:28

Mentat wrote:Anyways, in general, it is safe to assume - when writing the examples - that the reading beginners don't know or care about its history or meaning.


The dangerous assumption here is that the wiki is necessarily for beginners. Maybe foo and bar are out of place in the Community Tutorials section, if the tutorial is aimed at beginners, but I'd say the main usefulness of the wiki is in reminding you about the specifics of how things work (I use it all the time for this-- I have a bad memory) in which case they're fine. (better than that, they save you the few brainwaves work of abstracting a concrete example so that you can apply it to your own problem)
yetifoot
Posts: 1710
Joined: Sep 11, 2005 7:08
Location: England
Contact:

Postby yetifoot » Jun 09, 2008 5:06

Phydaux wrote:..snip.. If anyone is actually using foo and bar in their code then I feel sorry for you and anyone who has to look at your code. ..snip..


I don't think this is about people using foo/bar in real code, I think most people would agree that is not a great idea, the question seems to be more about if they are acceptable in short example codes.

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 3 guests