My most immediate project is a program that will take parameters for a given RPG's die system and output some statistical calculations--so you could ask how likely you are to succeed in a given opposed roll in nWoD or how many hobgoblins your ranger can kill before getting nat-20'd to death. Eventually I'd like to release it as a series of free apps--one for each system I end up supporting.
I made a dice rolling program, and I plan to expand it to include probabilities and more systems, although my general goals for that are much smaller then yours (I don`t plan to include calculations for opposed roles, I don`t want to make it user friendly, etc).
There is a formula which I think is correct for calculating the probability of a certain sum in a roll of a few dice, but I don`t remmember it exectly.
Where are you and what are you doing in terms of programming? Employment, education or in your spare time?
I have a MS and BS in computer science and am working as a software engineer at a Big Data company.
What language or languages are you using primarily at the moment? What's your favourite, and why?
Languages I'm using at work: C, C++, Python, and MySQL.
Languages I'm using for fun: Perl, PHP, and Java.
I love Perl's quirky syntax and built-in hashes and regular expressions, so I'd say that's my favorite right now.
Where do you hope to go with your programming? Any plans for the future, or just waiting to see if anything of interest comes along?
No plans, really, I just like coding.
Any projects, personal or otherwise, you're in the middle of? Anything you're really focused on?
I'm working on a D&D database for my group's use, basically a comprehensive SRD of all 3e material out there like dndtools or realmshelp, but that isn't missing anything and that has more powerful searching and sorting. It's all OCRing PDFs, parsing, formatting, scanning, stuff like that. I've also recently made a tower defense game with an AI that reacts to the player's choice of tower types, paths defended, etc.
What environment do you work/prefer to work in? Netbeans/Eclipse/Command line and a text editor?
Linux terminal and vim for me, please. My work laptop is a Macbook, but the dev team works in a RHEL 6 VM.
Quote:
Originally Posted by Kallisti
My most immediate project is a program that will take parameters for a given RPG's die system and output some statistical calculations--so you could ask how likely you are to succeed in a given opposed roll in nWoD or how many hobgoblins your ranger can kill before getting nat-20'd to death. Eventually I'd like to release it as a series of free apps--one for each system I end up supporting.
Writing dicerollers and other gaming apps is a hobby of mine as well. I wrote a diceroller that handles conditional logic, exploding dice, rerolls, multiple rolls, and more. Some examples:
...as well as a simulator for Star Wars Saga vehicle combat to handle massed attacks, condition track steps, shield reduction, and such. It made combats in my Rogue Squadron campaign ("72 TIE Interceptors and 2 Dreadnoughts? There's 12 of us, we can take 'em!") a lot easier to handle.
__________________
Better to DM in Baator than play in Celestia
You can just call me Dice; that's how I roll.
Sig of Holding
Spoiler
Quote:
Originally Posted by abadguy
Darn you PoDL for making me care about a bunch of NPC Commoners!
For people into Python: I thought this was pretty neat.
I don't get it... What does it do? Other than write "good job" in big red letters, obviously.
EDIT: On second look, it compiles the code you type in? that is neat in a redundant sort of way.
Might as well add a question of my own: Is everything classes and automatic garbage collection these days? I ask because we don't use that much where I work. The programs we make has to run real time, so I guess we have a wierd programming style.
I'm sitting here with a little hobby project and the garbage collected classes from microsoft and my own code does NOT want to play nice together. It does not really want to mix managed classes and my code. Should I just give in and make everything managed? Proformance is not too important in this little application.
__________________ Bad to the Bone! Miko Miyazaki : Strip #120 - #464 : R.I.P.
Writing dicerollers and other gaming apps is a hobby of mine as well. I wrote a diceroller that handles conditional logic, exploding dice, rerolls, multiple rolls, and more. Some examples:
*kersnip'd*
Ah, very nice; I've got a little dice program myself from ages ago that I've really been meaning to expand on. It asks you how many sides the dice you want to roll has, how many times you want to roll it, and returns the results of each roll, and the total value of all rolls combined:
Spoiler
Code:
Enter the amount of sides the dice has:
6
Enter number of times to roll the dice:
100
The total result is 381
1: 11
2: 17
3: 18
4: 15
5: 12
6: 27
Some things I want to add to it is having conditonal rolls(such as critical hits, nat 20s, nat 1s,), and automatically adding in modifiers, and possibly tying it to a database of weapons that would have damage, crit ranges, etc.
Once I get the dice program to a level I'm happy with, I'll try and use it for some other projects; I've been meaning to get a D&D character generator up and running, and I'm planning on doing it in netbeans forms, or possible some other form of GUI.
Quote:
Originally Posted by Neftren
Also, that silly moment when you realize sys.maxint returns a 64-bit number locally, but a 32-bit number on the deployment server.
Yeah. That just happened to me.
It could be worse; try having an Arraylist(in java) of objects, and a method to take objects from it and give it to another Arraylist; I had:
Spoiler
Code:
static ArrayList<Card> dealToHand(ArrayList<Card> deck, ArrayList<Card> hand, int cards)
{
for(int i = 0; i < cards; i++)
{
Card test = deck.get(0);
test.setHasBeenDealt(true);
hand.add(deck.get(i));
deck.remove(i);
}
return hand;
}
And I was driving myself mad trying to find out why it taking the first card, then the third, then the fifth, when I wanted it take just the first each time; turns out I just needed to have the is as 0s, and it took longer than I'd like to admit for this piece of logic to click.
Quote:
Originally Posted by Neftren
I'm no expert in Java, but my hunch would be that calling toString() on an object without an overloaded toString() method would print the memory address or something similar to that degree.
Yeah, you would have to have an overridden toString(), and personally I find it just the same to have a printDetails() method, especially as I can have printCard(), printHand(), and printDeck() for different formats of printing.
Quote:
Originally Posted by akma
A note about the card class:
I think it would be better if you used Enums instead of String values for Suit and Number. That way if you accidently insert incorrect values to the constructor, the program would fail instantly with obvious reasons instead of messing up things later.
The way the toString method is implemented by default is by returning the class name and it`s address in hexdecimal format.
Ah, but I've designed it in a way that an incorrect value can't be put in for Suit or Number, so I don't have to worry about using an enum. Also, haven't covered enums yet, and I'm starting to get worried about the amount of stuff on my plate at the moment.
Also, something of note: I found a free online Introduction to Computer Science course from Harvard, if anyone is interested in signing up for it; it started yesterday, and goes on until the 15th of April.
Last edited by Miscast_Mage : 10-16-2012 at 05:45 AM.
Reason: Spelling error. :3
I only looked at the code in the second spoiler, but it looks like a good time to try out a for:each statement. I'm not sure if it's possible with the way your program is written, but if you can do it, it is usually a nice way to perform a set amount of operations to a list of objects.
__________________
SUBMIT your searches
TO
GOOGLE.
I only looked at the code in the second spoiler, but it looks like a good time to try out a for:each statement. I'm not sure if it's possible with the way your program is written, but if you can do it, it is usually a nice way to perform a set amount of operations to a list of objects.
Hmm, the thing is, I don't think a for-each loop would work out here(I have used for-each loops a bit, at this point); the method takes in the number of cards to take from the deck and to give to the hand. I can't see how you would do this in a non-messy way using a for-each loop. A for-each loop would go through every card in the deck, whereas I only want a specific number of cards from it(e.g. deal five cards to a hand).
So our head programmer at work...just dropped dead last weekend! I'm not making this crap up. The funeral is next tuesday.
I wonder what part of his 1 million unfinished but highly business critial projects will land on my head? Well, now the power of careful documentation will come to it's fullest! Oh wait! We don't do paper! Our mantra is "The documentation is in the code", because documentation is for amaturs!
I'm not asking for detailed documentation for every little bit of code, but it would be nice if I knew, like, what the program was *supposed* to do.
*Sigh* I will miss his completely unmotivated outbursts of "WHAT?!" whenever his code did something unexpected, his constant clicking of ball point pens and violent sneeze attacks, all heard from two cubicles over.
__________________ Bad to the Bone! Miko Miyazaki : Strip #120 - #464 : R.I.P.
At any rate, this is why our project has several dozen, possibly several hundred, articles by me in the project wiki discussing every aspect of what I've done and why I did it.
Respectfully,
Brian P.
__________________
"Opportunities to do good are everywhere but the darkness is where the light needs to be".
-- Eliezer Yudkowski, author of "Harry Potter and the Methods of Rationality"
At any rate, this is why our project has several dozen, possibly several hundred, articles by me in the project wiki discussing every aspect of what I've done and why I did it.
Respectfully,
Brian P.
"Project wiki"?! You got to be kidding me. That sounds cool.
BTW, my coworker died from a heartattack of some kind. He had previously had a quardruble bypass. So at least he went quick. Man, what if he had dropped dead at work?!
__________________ Bad to the Bone! Miko Miyazaki : Strip #120 - #464 : R.I.P.
"Project wiki"?! You got to be kidding me. That sounds cool.
BTW, my coworker died from a heartattack of some kind. He had previously had a quardruble bypass. So at least he went quick. Man, what if he had dropped dead at work?!
For large code bases, it's not uncommon to have a Wiki or other established comment system (e.g. GitHub commit histories).
Allow me to direct you to Assembla . They provide a repository, trouble ticket management system, a wiki, and a bunch of other stuff. There's a free version for students which provides something like :mumble mumble: storage space in 1 workspace. I've had occasion to use the paid versions, but for which companies and which projects I cannot say.
Respectfully,
Brian P.
__________________
"Opportunities to do good are everywhere but the darkness is where the light needs to be".
-- Eliezer Yudkowski, author of "Harry Potter and the Methods of Rationality"
I`m thinking of trying to learn Assembly after I`ll be more satisfied with my skill in java (I want to try something not object oriented).
How bad is it? I know there are no classes, are there even method declerations?
How bad is it? I know there are no classes, are there even method declerations?
Assembly is raw machine code instructions...it doesn't really have *any* language constructs you might be familiar with. As an example, this is a small piece of in-line assembly code I put into a C function to speed it up many years ago:
To give you a clue, the things at the beginning of lines ending colons are labels, anything starting with a J is a jump command that will jump to one of those labels depending on conditions (e.g. jnz = jump if non-zero). This might look like the most horrible spaghetti code you've ever seen, but this is the *only* way to code in raw assembler.
If all you know is Java, I would not waste my time trying to learn assembly: it will be next to impossible. To jump from one of the highest level languages in existence to assembly (the lowest level practical language) would take inordinate amounts of time, practice, and dedication.
It would legitimately be quicker to learn another language at a lower level and then try to learn assembly, than it would be to just jump to it from Java. At the very least you should know a language that is no higher level than C++ before you start assembly ( C would be even better). Then it may be easier to mess around with something like an Arduino, which can be programmed basically in C or in assembler, allowing you progress down into the assembly code as you are comfortable with (and you can actually see it do stuff which makes code verification easy).
If you want to go straight from Java to assmbly code, go for it; I'm just saying that there are much better ways to go about it that will take a lot less time and be a whole lot less frustrating.
__________________
SUBMIT your searches
TO
GOOGLE.
It might also be prudent to start with another assembly language than x86. We had assembly programming as a part of a computer architecture course last spring, where we were taught MIPS assembly, which wasn't all too hard to grasp, at least not in my opinion.
I should also point out that the only languages I knew prior to that course were Java and SML (which is a functional language, and thus even further removed from assembly, which is imperative), and the same applied to most of my coursemates, so it's not impossible to learn assembly just because you know nothing like it. Actually, since we just had left SML, I found MIPS assembly to be sort of a relief, seeing how it let me put skills in imperative programming I'd learned in Java to use again.
__________________
Engineer Teddy by me. We're refitting this steam locomotive in the spirit of Steampunk, but we need your help designing it: Enter_the_design_competition_today!
(And yes, my avatar is according to scale.)
Oh dear, I'm sorry to hear of your loss. My sympathies to his friends, family, and coworkers.
Quote:
Originally Posted by pendell
Allow me to direct you to Assembla . They provide a repository, trouble ticket management system, a wiki, and a bunch of other stuff. There's a free version for students which provides something like :mumble mumble: storage space in 1 workspace. I've had occasion to use the paid versions, but for which companies and which projects I cannot say.
Respectfully,
Brian P.
Ah, I've actually been looking into setting up a wiki or database that would contain classes and methods I've that I thought were particularly useful; this looks like it could be just what I need. It seems a lot more complex than what I need, but still, learning something new never hurts.
Just to get a bit of a head start though, if all I want is essentially a database of small programs, and brief descriptions of what they do, all I would need for the moment is the git repository, right? And I would essentially be able to set it up like a wiki for myself and others(assuming I set it to public) to access? Or would I just be better off setting up something on wikispaces?
To give you a clue, the things at the beginning of lines ending colons are labels, anything starting with a J is a jump command that will jump to one of those labels depending on conditions (e.g. jnz = jump if non-zero). This might look like the most horrible spaghetti code you've ever seen, but this is the *only* way to code in raw assembler.
Seems scary. What was it supposed to do? What the bigger program is supposed to do?
Quote:
Originally Posted by Skami Pilno
It would legitimately be quicker to learn another language at a lower level and then try to learn assembly, than it would be to just jump to it from Java. At the very least you should know a language that is no higher level than C++ before you start assembly ( C would be even better).
From what I know of C++ syntax, it`s very similiar to that of Java. I don`t see how that could help significantly in learning assembly (anyways I`ll pick something easier then assembly after Java).
Quote:
Originally Posted by Teddy
It might also be prudent to start with another assembly language than x86. We had assembly programming as a part of a computer architecture course last spring, where we were taught MIPS assembly, which wasn't all too hard to grasp, at least not in my opinion.
When I`ll work on learning Assembly, I will work on learning the Assembly leanguage of the computer I`ll have at the time.
Quote:
Originally Posted by Miscast_Mage
Ah, I've actually been looking into setting up a wiki or database that would contain classes and methods I've that I thought were particularly useful; this looks like it could be just what I need. It seems a lot more complex than what I need, but still, learning something new never hurts.
I didn`t look at the website pendell posted, but Java has a built in documentation system - Javadoc.
Also, if your packages are organized well, it saves you a lot of bother. You could create a package named utility and put everything usefull there.
From what I know of C++ syntax, it`s very similiar to that of Java. I don`t see how that could help significantly in learning assembly (anyways I`ll pick something easier then assembly after Java).
Sure, the syntax is pretty similar. It's a type-cased brackets-based language. Java does a lot of hand holding for you though. C/C++ really requires you to have a good working knowledge of memory layout, pointer usage, and so on. There are also a lot of different data structures in the standard library, and knowing which one to use when can be tricky.
Quote:
When I`ll work on learning Assembly, I will work on learning the Assembly leanguage of the computer I`ll have at the time.
I'd strongly suggest you start with a simpler Assembly language (e.g. MIPS, as Teddy suggested). x86 makes me want to smash my head against the wall every night just trying to keep track of all the opcodes, jumps, conditional and unconditional branching, etc.
Miscast, at work, a lot of people had their own established (personal) codebases saved locally. For instance, my mentor didn't like the STL Vector class (think ArrayList in Java), so he wrote his own. It's not uncommon to keep small utility programs around. I do it for Python and C/C++, mostly for image processing. Centroiding and filtering are pretty common operations.
If you find yourself using a lot of the same initialization code, consider just putting together a template program. I have one for OpenCL runtimes, as 90% of the time it's the same cl::getPlatform(), cl::getDevices(&Platform) or something along those lines.
What you don't want to do is make a wiki and just post raw code snippets. Avoid writing a chunk of code and copy/pasting it every time you use it. Consider encapsulating it into an (inline) function if you use it frequently, then import the file.
Seems scary. What was it supposed to do? What the bigger program is supposed to do?
The code snippet there scans a line of input pixels and converts it to an array several times smaller with a count of pixels...so, if you wanted it to be 4 times smaller, you'd get back an array with values from 0-4 in it saying how many "set" pixels were in each 4-pixel block. It was part of a font rendering engine that created anti-aliased text by rendering it several times larger than it needed to be and then scaling it down. Those were the days before proper anti-aliased font handling was built into Windows, of course!
For large code bases, it's not uncommon to have a Wiki or other established comment system (e.g. GitHub commit histories).
Quote:
Originally Posted by pendell
Allow me to direct you to Assembla . They provide a repository, trouble ticket management system, a wiki, and a bunch of other stuff. There's a free version for students which provides something like :mumble mumble: storage space in 1 workspace. I've had occasion to use the paid versions, but for which companies and which projects I cannot say.
Respectfully,
Brian P.
Any thought on how Assembla compares to Trac? Me and a co-worker are planning a new project and we were thinking of using Trac and Git to sync everything.
__________________ IMPORTANT: Back, after a long absence. Apologies to everyone I left wondering where I was.
Quote:
Dumbledore is dead but had a horcrux so might still be alive to it being fake and him dead but not stopping her from using the having a horcrux on you letting you live from a killing curse.
Quote:
Originally Posted by The Glyphstone
Epileptic monkeys. Boxing gloves. Typewriters. That is all.
Ah, I've actually been looking into setting up a wiki or database that would contain classes and methods I've that I thought were particularly useful; this looks like it could be just what I need. It seems a lot more complex than what I need, but still, learning something new never hurts.
Quote:
Just to get a bit of a head start though, if all I want is essentially a database of small programs, and brief descriptions of what they do, all I would need for the moment is the git repository, right?
Correct. Git can store your code, and I supposed you could add documentation in the form of .rtf or text files to the repository as well. I prefer wiki articles for that, but if it's simpler to just use the repository that will work.
Quote:
And I would essentially be able to set it up like a wiki for myself and others(assuming I set it to public) to access?
I believe so, yes. Certainly that's the way I've used it.
Or would I just be better off setting up something on wikispaces?
I can't say I've used Trac or wikispaces. Sounds like a homework assignment for me at some point.
Respectfully,
Brian P.
__________________
"Opportunities to do good are everywhere but the darkness is where the light needs to be".
-- Eliezer Yudkowski, author of "Harry Potter and the Methods of Rationality"
•Where are you and what are you doing in terms of programming? Employment, education or in your spare time?
I'm currently a Hospital Secretary (with a degree in geology no less) so no real programming work there. Taken a couple of classes in C++ and I've been teaching myself Python the past couple of years. Just started the cs50x class posted here so here's hoping something new sticks.
•What language or languages are you using primarily at the moment? What's your favourite, and why?
I'm currently using python as my main language (and favorite so far), although with the class I'm taking I'll be getting to use C, PHP, and Java. I also have experience with C++ but haven't used it in long enough that I'm on the farther side of rusty with it.
•Where do you hope to go with your programming? Any plans for the future, or just waiting to see if anything of interest comes along?
I'd like to one day be a freelance programmer and/or indie game programmer, both of which are sometime in the nebulous future.
•Any projects, personal or otherwise, you're in the middle of? Anything you're really focused on?
I've got a rougelike that I dable with from time to time, need to get back to working on that at some point. Other than that just working on learning as much about programming as I can.
•What environment do you work/prefer to work in? Netbeans/Eclipse/Command line and a text editor?
I generally just use IDLE for a programming enviornment. As for a text editor, I greatly enjoy the look and feel of Notepad++.
•Any problems that are driving you mad? A piece of code not compiling right, or being off by one, or one little syntax error in a sea of code? Not quite grasping the logic of a particular piece of code?
Biggest problem I have right now is making sure I don't have any typos or syntatic errors. I have a tendency to type obnoxiously fast, which causes case errors, and spelling errors more frequently than I would care for.
Oh dear, I'm sorry to hear of your loss. My sympathies to his friends, family, and coworkers.
Thanks. Speaking of assembler, I just remembered that he was the only one who knew how to program in that. There are functions programmed by him in assembler for speed. Let's hope they never need to be debugged or we are so screwed.
Now for my little hobby project: Managed code and my code fit like foot in glove. Seriously, help! I want to use the build-in components like treeview and such. They are all managed and will only work with other managed object. It is borderline harrasment. For example, the treeview has a "tag" property per node which is just a pointer. But it can only point to managed objects. you can't even cast it to the type you want.
It's the same for this list class I'm making. The head class (the form) is managed, so the list must be managed. The elements in the list must thus also be managed. And all the part of the element must also be managed, right down to a 2D vector. Really?
Is this really how it is supposed to be? Everything is on the garbage collected heap now and nothing on the stack?
I guess if you want to use a Microsoft product, you have to program the Microsoft way.
__________________ Bad to the Bone! Miko Miyazaki : Strip #120 - #464 : R.I.P.
Thanks. Speaking of assembler, I just remembered that he was the only one who knew how to program in that. There are functions programmed by him in assembler for speed. Let's hope they never need to be debugged or we are so screwed.
Now for my little hobby project: Managed code and my code fit like foot in glove. Seriously, help! I want to use the build-in components like treeview and such. They are all managed and will only work with other managed object. It is borderline harrasment. For example, the treeview has a "tag" property per node which is just a pointer. But it can only point to managed objects. you can't even cast it to the type you want.
It's the same for this list class I'm making. The head class (the form) is managed, so the list must be managed. The elements in the list must thus also be managed. And all the part of the element must also be managed, right down to a 2D vector. Really?
Is this really how it is supposed to be? Everything is on the garbage collected heap now and nothing on the stack?
I guess if you want to use a Microsoft product, you have to program the Microsoft way.
What exactly is this for? I'm guessing .NET Framework?
Also, why are you using a vector in a list? That seems to defeat the purpose of putting together a list...
There's quite a lot that goes onto the heap now, and rightly so. For large data sets, you probably won't be able to fit it into the stack frame...
Miscast, at work, a lot of people had their own established (personal) codebases saved locally. For instance, my mentor didn't like the STL Vector class (think ArrayList in Java), so he wrote his own. It's not uncommon to keep small utility programs around. I do it for Python and C/C++, mostly for image processing. Centroiding and filtering are pretty common operations.
If you find yourself using a lot of the same initialization code, consider just putting together a template program. I have one for OpenCL runtimes, as 90% of the time it's the same cl::getPlatform(), cl::getDevices(&Platform) or something along those lines.
Hmm, I suppose a template program would be handiest for what I want to do. At the moment I just copy and paste previous classes/methods from previous work that I think would be handy for whatever I'm working on at the moment. I'll have to see about looking into that, thanks.
Quote:
Originally Posted by Neftren
What you don't want to do is make a wiki and just post raw code snippets. Avoid writing a chunk of code and copy/pasting it every time you use it. Consider encapsulating it into an (inline) function if you use it frequently, then import the file.
Ah, I think I've spotted an issue with what I want to do, actually; I've been meaning to do two things, and I've been muddling them together:
Having a database of my own useful methods/classes/etc for my personal use
Having something to show other people in my course if they're having a problem
I was thinking of a wiki to have more an index of useful methods/classes, descriptions of what they do and how, what they take in/return, and what project I have them located in. The advantage to this would be it would useful for me, and for anyone if they wanted to see how snippets of my code worked.
However, now I'm just thinking of having a seperate way of managing my stuff for me, and having a wiki of useful snippets completely separate for other people to look at that would be more the tricky things that we'll have to be aware of in the exam like:
Spoiler
Code:
int
number = 5;
if(++number == 6)
{
System.out.println("Hello.");
}
if(number-- == 5)
{
System.out.println("Goodbye");
}
Or
Code:
int []y[];
Or just plain useful methods like this for sorting arrays
Code:
public static void swap(int [] num, int i, int j)
{
int tmp = num[i];
num[i] = num[j];
num[j] = tmp;
}
public static void sort(int [] num)
{
for(int i = 0; i < num.length - 1; i++)
{
int minIndex = i;
for(int j = i + 1; j < num.length; j++)
{
if(num[j] < num[minIndex])
minIndex = j;
}
swap(num, i, minIndex);
}
}
Quote:
Originally Posted by akma
I didn`t look at the website pendell posted, but Java has a built in documentation system - Javadoc.
Also, if your packages are organized well, it saves you a lot of bother. You could create a package named utility and put everything usefull there.
Amen for organised packages; I organise mine by date(Y/M/D)-subject, e.g. 20121023Sample2DArrays or 20121014CharacterGenerator. It's annoying that there doesn't seem to be a tagging system or even a "ascending/descending according to date made/last edited" option; it makes it a pain to have a coherent yet expansive way of cataloging projects.
Lumping everything useful in one package does sound like a pretty convenient solution, even just for the moment where I don't really have anything huge yet.
Quote:
Originally Posted by pendell
Correct. Git can store your code, and I supposed you could add documentation in the form of .rtf or text files to the repository as well. I prefer wiki articles for that, but if it's simpler to just use the repository that will work.
Hmm, I think I'd prefer if it had some way of keeping the different sections of code inherently with documentation, as opposed to having it is as a separate file, which I can imagine getting messy or being a pain to keep updated.
I'm in a C++ freshman course for my computer engineering degree, and basically for a scholarship I'm working with my professor on stuff outside the normal class things, including going into Python, cgi, and sqlite. It's pretty interesting! I'm working on one big program for the end of the semester that runs an HTML page where students can select a topic to practice coding on, where it'll pull a problem from an sqlite db and then take a form from the user. Then I guess I need to work on saving it as a .cpp file and compiling it through the command prompt (returning errors if there are any). So I may update you guys/ask for help :P
Hmm, I suppose a template program would be handiest for what I want to do. At the moment I just copy and paste previous classes/methods from previous work that I think would be handy for whatever I'm working on at the moment. I'll have to see about looking into that, thanks.
What I'm saying is that you shouldn't copy/paste at all. If it's a code snippet, it's short enough to retype, or regex/text-expand it. Typing it out will help you avoid mistakes (enter the logical fallacy of code found on the internet). If it's some sort of utility method (e.g. templated matrix multiply) that you use on a frequent basis, it should be documented and then compiled into a package.
Code that you use personally and code that you show other people shouldn't be any different. If you maintain a rigorous and neat programming style, your code should be easily understandable to anyone reading it. At that point, it's just a matter of "oh, here's my file, look at it and understand!"
As for some comments on your code... I know a lot of instructors provide cheat sheets on exams. I don't know if yours does the same though. Anyways ...
You should probably avoid performing mathematical operations within conditional statements. Your first code sample will fail if the given number isn't 5. Granted you probably already knew that part.
I'm surprised you (or other people you're helping) found int []y[]; tricky. Well, maybe it's the format you wrote it in. This is more of a pet peeve of mine more than anything else (going back to the Star (Pointer) Wars. It makes much more sense to rewrite that fragment as int[] y[]; (note the spacing). That way, you keep the data type with the container. An integer[array] (of) y[array_size]. Similarly, in C/C++, int* i makes much more sense than int *i, as you would read it as an integer pointer. If in doubt, refer to your style guide (most companies or managed code bases typically have one somewhere).
Also, for the last code example, Bubble Sort (and similar O(n2) algorithms)...? Why do you consider this useful?
Quote:
Amen for organised packages; I organise mine by date(Y/M/D)-subject, e.g. 20121023Sample2DArrays or 20121014CharacterGenerator. It's annoying that there doesn't seem to be a tagging system or even a "ascending/descending according to date made/last edited" option; it makes it a pain to have a coherent yet expansive way of cataloging projects.
A tagging system in what? All modern operating systems can sort by file name and date. Or are you using some IDE?
Quote:
Originally Posted by Leona
I'm in a C++ freshman course for my computer engineering degree, and basically for a scholarship I'm working with my professor on stuff outside the normal class things, including going into Python, cgi, and sqlite. It's pretty interesting! I'm working on one big program for the end of the semester that runs an HTML page where students can select a topic to practice coding on, where it'll pull a problem from an sqlite db and then take a form from the user. Then I guess I need to work on saving it as a .cpp file and compiling it through the command prompt (returning errors if there are any). So I may update you guys/ask for help :P
Compiling via command line is pretty easy. You'll probably learn to use the GNU Compiler (gcc/g++). In Terminal (or shell of choice), you'll enter something along the lines of...
Welp. Forbidden post error. I had something written up here, but the forum won't let me post it (and no, I didn't use the word involving a cat (yes, that word) or a colon followed by two spaces anywhere).
Amen for organised packages; I organise mine by date(Y/M/D)-subject, e.g. 20121023Sample2DArrays or 20121014CharacterGenerator. It's annoying that there doesn't seem to be a tagging system or even a "ascending/descending according to date made/last edited" option; it makes it a pain to have a coherent yet expansive way of cataloging projects.
There is another option - static variables, or maybe even a class with details about a package (if you are going to include one in every package, I recommend naming it $).
Quote:
Originally Posted by Miscast_Mage
Hmm, I think I'd prefer if it had some way of keeping the different sections of code inherently with documentation, as opposed to having it is as a separate file, which I can imagine getting messy or being a pain to keep updated.