Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Structured Programming
i know i know this is already offtopic and i'm sorry but i have to add one more: i'd rather go for punishing flaming than the ignoring button thing. it would mean more work for the mods, but i'm sure there's a lot of ppl on the board that would be suitable for a mod job. oh and: since i'm visiting this forum it's almost always only being about flames
quote="NecrosIhsan"]
[Image: yagl1.png]
[/quote]
Reply
Quote:i know i know this is already offtopic and i'm sorry but i have to add one more: i'd rather go for punishing flaming than the ignoring button thing. it would mean more work for the mods, but i'm sure there's a lot of ppl on the board that would be suitable for a mod job. oh and: since i'm visiting this forum it's almost always only being about flames
Quote:And I don't want an arguement here about how ignoring people on here is bad and a terrible mod to add.
Tssk tssk Marzec Tongue
Reply
Quote:calling something a "C Virus" where it is in no way related to c really but more to the philosophy of the programmer just fuels the "nuu you are but a c zealot" "NUUU you are a basic zealot" "debate".
Oh I agree. Again, I don't know what drugs she's on.

Quote:edit: i nearly forgot, can you say reinterpret_cast?
I never said C++ was exempt from unsafe statements, but at least C++ lets you know that something's going on, and the code should be understood thoroughly (the C++-style casting operators are intentionally verbose, and you're encouraged, by any sane programmer, to prefer those over the C-style casts, which give no indication of intent or safety).

C is a middle-level language, higher than assembly, lower than C++. Of course C has the potential to be more optimal compared to C++, and especially Java, but again, the lack of safety, combined with portability issues when using "optimal code", more often than not tends to overshadow any speed increases you may get.

Sorry, I'm big on safety. Safety-measures help you write better - maintanable, extensible, flexible, reusable - code. Writing better code helps alleviate more of the need for debugging, which in turn allows you to develop more "better code". Any (and in many cases negligable) speed increases you get from using C are severly outkicked by the productivity you gain in C++. That's why C was invented in the first place - assembler was/is too error-prone, complex and non-portable.
stylin:
Reply
i dunno why you said all that but... does it help if i tell you that i'm mainly using c++ and eiffel?

but i can see it now yours is bigger than mine i'm defeated now i vanish in pink puff nuuuuu
quote="NecrosIhsan"]
[Image: yagl1.png]
[/quote]
Reply
Quote:does it help if i tell you that i'm mainly using c++ and eiffel?
I don't see what languages you're currently using have any bearing on this discussion.

Quote:but i can see it now yours is bigger than mine i'm defeated now i vanish in pink puff nuuuuu
?

EDIT: I'm not trying to "out-do" you, if that's what you mean. Just having a (albeit off-topic) discussion/debate on efficient programming practices. I'm not by any means an expert, that is why I like to debate - to learn. Cheers.
stylin:
Reply
to end this "debate", the facts you presented are a nice to know but i doubt that anybody on this board actually knows what you are talking about. in my case you state the obvious so it seems a bit like showing off to me :p no offense
quote="NecrosIhsan"]
[Image: yagl1.png]
[/quote]
Reply
Quote:
axipher Wrote:I do fine with fb, and really, whats wrong with using GOTO/GOSUB's, if the program works the that should be enough. Shouldn't it???
Axipher, you made a very good point here that perhaps the structured programming purists missed.

Your point is: "if the program works...". I think that's the important issue. You wrote it, you tested it, you modify it, and you're happy with it. Almost all the QB/FB programs that all of us here write are for our own use, and are not going to have to pass inspection by some programming standards committee. If some of us chose to use gotos or gosubs because we fell comfortable coding that way and have success doing so, then "to each his own."

If the programs we write were to be maintained by programmers other than ourselves, then yes, it would be a good convention to write these programs in a structured manner.
*****

The problem is, if we have to train and try to educate future programmers, we better teach them good practice.

I don't know how programming businesses are over there, but here, that you know how to do properly structured and indented programming is a must. Many businesses even have a "book of style" with directions on how to format your code. Because time is money, if some other employee has to keep with your project, it's better that he understands the sources in no time.

It's like when you are taking scripts. You get any pen on any kind of paper, and squibble fastly. Most of the time, you will understand it. I mean, it does the job. But what if you want the script to be read and understood, used and expanded by some other person? You have to use a proper paper, nice indentation and good callygraphy.

Structured programming is just that. It favourishes encapsulation, something that is a really important concept when you are going to work in a big project with more people. It favourishes readability. It also favourishes scalability. It's easier to debug and, most of all, easier to expand and to maintain.

I'm just talking of experience. I sometimes review my old programs and I have to spend some time figuring out where all those branches go and what do those unindented nested loops begin and end, which are inside which and stuff like that.

Plus, using GOSUBs instead of SUBs is horrid for scalability. Imagine that you code something and place all your subroutines behind labels and you use GOSUB to call them. Now leave that program for two years. After that time, your boss asks you to add a new capability that someone else coded. You cut and paste the code and... ARGH! Same variable names! everything goes haywire and you have to review the source line by line to replace the variable names. That takes time.

If you had used SUBs, you just stick the new SUB in your code and forget about it. You don't even have to read the new code. That's encapsulation.

That's why all my claims grow stronger and stronger. Meg has her own crusade as well. I think that in places like this we are "forming" future programmers. And no matter how we prefer to code, we should try to show them the "easiest way to success".

I do use GOTOs, but I strongly speak against newbies using them. Avoid GOTO like the plague until you know exactly what you are doing.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
Quote:
Moneo Wrote:
axipher Wrote:I do fine with fb, and really, what’s wrong with using GOTO/GOSUB's, if the program works that should be enough. Shouldn't it???
Axipher, you made a very good point here that perhaps the structured programming purists missed.

Your point is: "if the program works...". I think that's the important issue. You wrote it, you tested it, you modify it, and you're happy with it. Almost all the QB/FB programs that all of us here write are for our own use, and are not going to have to pass inspection by some programming standards committee. If some of us chose to use gotos or GOSUB’s because we fell comfortable coding that way and have success doing so, then "to each his own."

If the programs we write were to be maintained by programmers other than ourselves, then yes, it would be a good convention to write these programs in a structured manner.
*****

The problem is, if we have to train and try to educate future programmers, we better teach them good practice.

I don't know how programming businesses are over there, but here, that you know how to do properly structured and indented programming is a must. Many businesses even have a "book of style" with directions on how to format your code. Because time is money, if some other employee has to keep with your project, it's better that he understands the sources in no time.

It's like when you are taking scripts. You get any pen on any kind of paper, and squibble fastly. Most of the time, you will understand it. I mean, it does the job. But what if you want the script to be read and understood, used and expanded by some other person? You have to use a proper paper, nice indentation and good calligraphy.

Structured programming is just that. It favourishes encapsulation, something that is a really important concept when you are going to work in a big project with more people. It favourishes readability. It also favourishes scalability. It's easier to debug and, most of all, easier to expand and to maintain.

I'm just talking of experience. I sometimes review my old programs and I have to spend some time figuring out where all those branches go and what do those unindented nested loops begin and end, which are inside which and stuff like that.

Plus, using GOSUB’s instead of SUBs is horrid for scalability. Imagine that you code something and place all your subroutines behind labels and you use GOSUB to call them. Now leave that program for two years. After that time, your boss asks you to add a new capability that someone else coded. You cut and paste the code and... ARGH! Same variable names! Everything goes haywire and you have to review the source line by line to replace the variable names. That takes time.

If you had used SUBs, you just stick the new SUB in your code and forget about it. You don't even have to read the new code. That's encapsulation.

That's why all my claims grow stronger and stronger. Meg has her own crusade as well. I think that in places like this we are "forming" future programmers. And no matter how we prefer to code, we should try to show them the "easiest way to success".

I do use GOTOs, but I strongly speak against newbies using them. Avoid GOTO like the plague until you know exactly what you are doing.





Instead of posting a meaningless post like usual, this post will actually contain information worth reading. Now Moneo, I did make a good point and na_th_an countered quite nicely, I think that most programs people make never do get released and are for personal use or for experiments. Some people though, like me, won't abandon a project until it is done and have a separate document explaining exactly what each part of the code does. Now if the program works and it is not being added to or being reviewed by someone who has never seen the code before, then using GOTO's and GOSUB's is ok, if I were making a program where there was more then just me working on it, then I would use SUB's instead. Now on the fact of indenting and UPPERCASE KEYWORDS, I am a great example, I actually do most of my coding on a Palm Pilot, I use the graffiti area to just write away, then when I transfer it to FreeBasic, it is all lower case and everything is aligned left, FreeBasic has 2 great features, 1 that turns all keywords into UPPERCASE and a feature that auto-indents. So I say don't worry about messy code when it comes to indents and keywords, they can easily be solved. Now na_th_an, I understand your stance on how we must teach future programmers proper techniques, but I found multiple teaching resource such as programs and books that teach BASIC and the first lessons use GOTO's and GOSUB's, also sometimes when examples are included with the source, you can't understand the code because of this. But if the source was not included or the program had no GOTO's or SUB's, the program would have worked just as well.

One last thing that deserves a paragraph of it's own, you all hate me posting off-topic or meaniningless posts, but then you go and flame them and create more useless posts, why not PM me and tell me to delete the post before anyone else posts???

P.S.: That's a lot of text, hope there's no mistakes :o I even corrected some of the quote's errors Big Grin
Reply
Quote:... but I found multiple teaching resource such as programs and books that teach BASIC and the first lessons use GOTO's and GOSUB's, also sometimes when examples are included with the source
The problem with the internet is that there's so much bad code, beginners have a hard time telling the difference. If the beginner's guide you're reading not only explains the use of the GOTO statement but encourages it, then you're reading a horrible guide, with horrible code, teaching horrible habits.

Please, do not take everything you read on the internet as gospel. Go to Barnes and Nobles; buy an (up-to-date) programming text book. Plenty of sites have sections on "Recommended Books For Beginners". Go there, then buy those books. It's the best way to learn good programming habits and techniques.

Quote:One last thing that deserves a paragraph of it's own, blah blah blah ...
No, that didn't deserve a paragraph of its own. Nobody hates you - get over yourself. You may find that people get along with you better if/when you stop being an attention whore, no offense.
stylin:
Reply
None taken, anyway, there are 3 CD's that I purchased, i only remember one of them was Learn To Program Basic from Scholastic, and they all had examples galore with GOTO's and GOSUB's, and had lessons devoted to using them, so that's wher I learnt my techniques from and that was in grade 7/8, so I was naive then and took whatever people said as the truth.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)