Page 2 of 2
Posted: Mon Oct 01, 2007 3:22 am
by Thalius
Everyone its own style id say. Theres plenty of good structured code on the boards if you need a "style-guide". However i think all this just was commented because you didnt use code tags to post the code so it completelly got ripped apart.
Otherwise nice game
Thalius
Ohh...
Posted: Mon Oct 01, 2007 5:26 am
by SMartin
Oh, It was the posted code....
Now that makes more sense, without the code tags it's a bit of a mess.
I didn't post that message but I could see how someone might think I did.
Maybe I'm not completely insane...but then again...maybe just a little.
Steve.
Posted: Tue Oct 02, 2007 3:43 am
by Rook Zimbabwe
@ SM: I wasn't trying to RIP... or Flame... The code was different, but it worked. I was hard to read for me. Very nonlinear. I apologize if you felt I was flaming you... I was only teasing (should have used more smileys!!!)
Really... it worked well. I think it works better than the original since I have had a few issues with the original giving FALSE info by undercounting mines around the square... yours has not done that yet which shows it to be an improvement!!!
Hope you accept the well intended apology.
RZ
Thanks.
Posted: Tue Oct 02, 2007 4:42 am
by SMartin
RZ, Thanks, I appreciate it.
It's probably me that needs to lighten up a bit

and you have my apologies for that.
It's always a little weird moving to a new platform because you don't always know what the conventions and standards are, and peer review is very helpful, in my humble opinion. So I do appreciate it.
So...I've got to ask...
By non-linear do you mean that you think the code is easier to follow if the procedures are organized by what they do, or organized by how they're likely to be called?
Steve
Posted: Wed Oct 03, 2007 4:02 am
by Rook Zimbabwe
Steve...

Your style works... thats what is important keep doing what you do as it works for you!
Linear styles are great for readability, but suffer in that a great deal of organization (IMO) is necessary to manae your code and flow.
To pundit:
All programs are organized so that the initial declares all variables, types, lists etc.
the main body of the program loop is organized
and the functions are placed at the end.
but it does not have to work that way.
Indeed, when I switched to PB from BB3d I had issues with the structures created by the window designer and had to learn how to work within the framework.
Witht the new way the window designer works I am relearning a bit. I have switched a POS project from the old method, to the new incredible functions list method (a function for every button...
On a POS there are a lot of buttons... )
I am not saying this well enough because I am typing it in an airport waiting to go to Newfoundland to install a new set of Xerox Printers for GMC. Too many people being nosy here !!!
OK organization:
When I studied for myMEd in Educational Psychology (and get my Teaching certificate) I learned [ie:forced down my throat] the Madeline Hunter Lesson Cycle as a methodology for classroom instruction and as a way to organize a lesson plan.
Anythin I would say on organization would probably apply just to me.
I keep it simple...
will edit in a moment... have to do the check in
Posted: Wed Oct 03, 2007 4:38 am
by DoubleDutch
SMartin: About your coding style...
I prefer to think of programming as an artform, like creative writing or similar. It's not (unless tought as such) a science - in the old days you could get a BA or a BSC in Computing - you decided at the end! (now its just BSC

). Maybe it really should depend if it was natural ability or not and if the output is "creative"?
Anyhow, my point is, it doesn't matter how you get to the end result, or what particular style you used to get there. It really also doesn't matter if people don't appear to appreciate your work or are critical of your style. What matters is that you enjoyed the experience and that it was creative (for you) in some form or another.
If you like the way you program, stick to that method. It obviously works.

Thanks
Posted: Thu Oct 04, 2007 2:11 am
by SMartin
Thanks for the replies. It's interesting reading.
I program strictly for the pleasure of it, so the doing, and the methodology is often more interesting to me than the product.
The truth is, I don't even play minesweeper that often, (I just wanted a way to cheat a little so I could win once in a while)
Re coding styles: I'm feelin' the need to refine mine. The project I'm working on now has already got four windows and the formatting style (like Termite Terminator) I'm using is starting to feel a little overloaded. I think I should have gone with separate files for each window and used 'Includes' and not relied so much on the code folding to keep my brain from exploding.
Also, this hand coding of the controls has got to go. Pure comes with a really good visual designer but I haven't quit figured out how to wrap in into my style yet.
I spent a good part of the summer before last writing (in .net) a Sudoku program that can create puzzles and solve to a fairly high level, so I've also been thinking a lot on the methodology of converting classes to a procedural based system.
I'd love to convert it to Purebasic. Those tiny, fast, executables that this system makes really puts a big smile on my face.
Steve
Posted: Thu Oct 04, 2007 3:33 am
by Rook Zimbabwe
it doesn't matter how you get to the end result,
Doubledutch cut through the miasma of my excess verbage to say what is really important.

Re: Minesweeper clone, getting my feet wet with PureBasic
Posted: Sat Dec 08, 2007 3:24 pm
by Tipperton
SMartin wrote:I discovered that GetCurrentDirectory() doesn't mean that you get the application's start path, so I added some gak to check for the directory that contains the graphics.
If you need the path to the program to get the graphics files, try:
Thanks
Posted: Sun Dec 09, 2007 5:59 am
by SMartin
Tipperton,
Thanks for the tip. I hadn't come across that yet, and it's very useful.
Steve Martin
Posted: Sun Dec 09, 2007 10:25 am
by blueznl
I tend to organize my code in groups, ie. related procedures are close to each other in the source. That often saves a little scrolling
I also use this framework:
procedure init()
whateverprocedure()
procedure end()
procedure mainloop()
init()
mainloop()
end()
ie. i start my code with all procedure definitions, first one that contains all initialisations, then all used subsections, then one that frees up stuff (if need be), then the mainloop, then three calls to subsequently init(), mainloop(), and end().
But it is all a matter of choice and taste.
It's the same story on commenting and indenting. Everyone likes something different.
Posted: Sat Jan 19, 2008 2:21 pm
by superadnim
I indent with a tab per group (so an if inside a procedure has 1 tab, simple indentation but without spaces, just real tabs). I comment using robodoc template because that allows me to output good docs out of my sources and it also keeps it all clean and nice
for big libraries I use 2 files, just like in C. one is a header containing declarations for that specific library and the other one is a source where the declarations are put to use with code content.
I also separate every module into a different dir which contains also their dependencies, etc.
Regarding code-style, I try to follow a GCC style I always used in C, but with the obvious differences on PB.
About file structure, that's a whole different subject, but this is how my things work through SVN (mind you, single user repositories are not the same as multi-user, IMO).
Code: Select all
root
|-> project name
| |-> bin
| | |-> program exe, dll, common files/dirs for the program, etc
| |
| |-> src
| | |-> libs
| | | | -> libraries in different directories, etc.
| | |-> main sources (the main file is called main.pb usually)
| |
| |-> tmp
| | |-> any temporary data goes in here (test files such as txt, binary, images, etc)
|-> project name....
| |-> ...
Its actually a little more complicated than that, but just to give you an idea.
Yep, it's all about the whole process and not just the end product that is enjoyable.