Unofficial Programming Thread

Post » Thu Sep 23, 2010 8:20 am

I'm preparing for an interview tomorrow for a graduate software engineering job with a company that makes software for investment banks and hedge funds and the like. I'm going to spend some time tonight brushing up on some things (I have a technical test and a group discussion of some kind as well), and I was wondering if you guys have any suggestions of things that would be worth reading up on to impress the most?
User avatar
jessica Villacis
 
Posts: 3385
Joined: Tue Jan 23, 2007 2:03 pm

Post » Thu Sep 23, 2010 11:54 am

So I have not been writing any code for awhile and I went to look at the checksum generator/verifier I had written and I feel it is really complete enough for me. I could allways clean up the code or add different things but I don't see it as nessesary since I really don't think I will release it tot he public (though I could use some beta testers still). I am now trying to come up with more ideas for programs. I want to keep going with my C# book but at the same time I feel its more useful to just work on projects I am interested in and learn that way.

Anyone have any good project ideas that I could pick from? I am still in the beginning stages but I know a few more advanced things such as reading and writing text files and, even though I am still working on understanding it better, XML reading and writing.
User avatar
Nick Pryce
 
Posts: 3386
Joined: Sat Jul 14, 2007 8:36 pm

Post » Thu Sep 23, 2010 4:21 pm

Alright guys looking for some quick input on a small problem.

I have a folder I want to write somethign to switch its Hidden attribute. Now I have already doen a VBScript and C# console application to do this but was considering a batch file as well, but it doesn't seemt o have the proper decision logic to support this. What would be the best way to approach this issue? What would be most efficient? It is just one folder and the path is similar on the two machines I will run the script.

I guess on a side note would it be better to use batch files (if possible), VBScripts, or small .NET applications for simple and small tasks? Right now I have a small batch file for launching three applications at once, a script to hide/unhide a folder, and then small applications for various other things so that is why I am curious. Would it best just to use a bunch of small VBScripts and then create a .NET interface for them?
User avatar
Catharine Krupinski
 
Posts: 3377
Joined: Sun Aug 12, 2007 3:39 pm

Post » Thu Sep 23, 2010 10:44 am

Is anyone who has 200 rep on stackoverflow able to upvote http://stackapps.com/questions/1141/stacked-odds-finding-the-questions-that-you-can-answer?

Anyone have any good project ideas that I could pick from? I am still in the beginning stages but I know a few more advanced things such as reading and writing text files and, even though I am still working on understanding it better, XML reading and writing.

A simple tic tack toe game? With things like a high scores table etc
User avatar
Matt Bee
 
Posts: 3441
Joined: Tue Jul 10, 2007 5:32 am

Post » Thu Sep 23, 2010 9:12 am

So the other night I spent a couple hours writing a small version of the game High-Low using six sided dice. Came out well I think, very simple and maybe some of my code could have been better but it works. It also took some of my time up when I was bored. Now to add a win/lose/draw counter somewhere in it. Maybe some options for higher number dice such as ten or twenty sided.
User avatar
suzan
 
Posts: 3329
Joined: Mon Jul 17, 2006 5:32 pm

Post » Thu Sep 23, 2010 5:23 pm

First post as a "new" member! Well not really, I had to make a new account cause i couldn't remember my login.

Well on topic. So today was the first day of sophomore year, and my Software 101 teacher tells us we are going to be learning BASIC. I don't know which one exactly, but I think we will be using QBASIC.

So anything I should know about programming and has anyone else here worked with BASIC?
User avatar
leni
 
Posts: 3461
Joined: Tue Jul 17, 2007 3:58 pm

Post » Thu Sep 23, 2010 4:01 pm

First post as a "new" member! Well not really, I had to make a new account cause i couldn't remember my login.

Well on topic. So today was the first day of sophomore year, and my Software 101 teacher tells us we are going to be learning BASIC. I don't know which one exactly, but I think we will be using QBASIC.

So anything I should know about programming and has anyone else here worked with BASIC?

If you are learning QBASIC, that's great. QBASIC is a nice little language - it fits the description "basic" well, so its good to learn off, and isn't bogged down by the unnecessary complexity of .net like later iterations of BASIC. Once you've got the concepts down you can move on to more modern or more complex languages much more easily :D



As for me, I decided it was time I learnt c#, so decided to write a fallout 3 mod manager, which is working quite well. Suffers from similar hiccups to FOMM, in which sometimes ticking a mod on or off just won't hold, but whatever. My real issue is actually ticking them little ticky boxes on and off. I have a CheckedListBox that is initially populated from every *.es? file in \data (Speaking of, what's the registry key that holds fo3's location?), but as for checking them on and off I've yet to find a decent way. If I check "Check on click" then dragging the mods to reorder them becomes a pain, if I don't its irritating to have to double click, and if I implement it manually using MouseDown and the x position of the mouse to make sure you're over the box, the regular checking behaviour gets in the way! Any tips?
User avatar
Portions
 
Posts: 3499
Joined: Thu Jun 14, 2007 1:47 am

Post » Thu Sep 23, 2010 10:52 am

First post as a "new" member! Well not really, I had to make a new account cause i couldn't remember my login.

Well on topic. So today was the first day of sophomore year, and my Software 101 teacher tells us we are going to be learning BASIC. I don't know which one exactly, but I think we will be using QBASIC.

So anything I should know about programming and has anyone else here worked with BASIC?

Ohh.. Yes, I have. Basic has some peculiar features in it compared to other languages, or maybe I'm too influenced by the .Net variations, Visual Basic. The inequality comparison operator is <>. Equality and assignment are the same thing =. In C for example, assignment is =, but is separated from equality ==. If you move from Basic to C later, you'll have to keep an extra eye on that or your comparisons will fail to do what you intended, although the compiler might warn you about typos.

This may be VB specific but arrays can start from any index and end in another. You can define an array from 2 to 5 if you so insist. However, after you have first given the array size, you can't shrink the array back to 0 elements. It'll always have at least one element in it. But, an uninitialized array can be empty. The resizing operator is ReDim. Usually, all the variables are defined using Dim. As in, "Dim lNum As long".

Well, that's a start.. Learn the basics well, no pun intended, and it'll be easier to learn other languages.
User avatar
Breanna Van Dijk
 
Posts: 3384
Joined: Mon Mar 12, 2007 2:18 pm

Post » Thu Sep 23, 2010 3:55 pm

Equality and assignment are the same thing =. In C for example, assignment is =, but is separated from equality ==. If you move from Basic to C later, you'll have to keep an extra eye on that or your comparisons will fail to do what you intended, although the compiler might warn you about typos.


That could be a big pain. That still catches me out from time to time and I never learned BASIC. Most of the time the compiler won't point it out, so it can be very hard to spot in a big program.
User avatar
tannis
 
Posts: 3446
Joined: Sat Dec 09, 2006 11:21 pm

Post » Thu Sep 23, 2010 8:20 pm

That could be a big pain. That still catches me out from time to time and I never learned BASIC. Most of the time the compiler won't point it out, so it can be very hard to spot in a big program.

I always find it a good idea to go if (constant==variable), so if I -do- make the mistake I'll find myself with a compile failure, not a nasty crash.
User avatar
Rusty Billiot
 
Posts: 3431
Joined: Sat Sep 22, 2007 10:22 pm

Post » Thu Sep 23, 2010 9:25 pm

I'm very interested in programming so I may be making this thread very active.

My teacher said the form of BASIC we'd be using is free and he would give us a copy or a link for the download. I don't know if Qbasic is free though. Is it?

Edit: Also, if it is, where can I get it from?
User avatar
Laura Samson
 
Posts: 3337
Joined: Wed Aug 29, 2007 6:36 pm

Post » Thu Sep 23, 2010 8:16 am

Visual Basic 2010 Express version is free... VB has some user interface components built in like the rest of the "Visual" product line. thinBasic seems to be another one. XBLite. Microsoft SmallBasic (.NET). FreeBasic (compatible with QBasic). You can google more with key phrase "basic interpreter for windows". There are quite a few..

QBasic came with old MSDOS and Windows versions. At least according to wiki QBasic is also freeware these days.
User avatar
Erika Ellsworth
 
Posts: 3333
Joined: Sat Jan 06, 2007 5:52 am

Post » Thu Sep 23, 2010 11:38 am

So this is my first real "program". IT took me about 3 hours to write and get some kinks out. It's defininetly not perfect. It's small and my first true attempt. So tell me what you think please.
Spoiler

Written in QBASIC
CLSCOLOR 4 'RedPRINT "NO USE OF CAPITAL LETTERS!!"COLOR 2 'GreenishINPUT "What's your name"; N$SELECT CASE N$        CASE "melanie" ''OR "Melanie"                PRINT "Well hello there pretty lady!"        CASE "mom"                PRINT "Hello mom"        CASE "austin"                COLOR 4                PRINT "oh great...you..."                SLEEP 2        CASE "larry"                PRINT "Hello dad"        CASE ""                PRINT "okay then...."        CASE "goose"                PRINT "Hello, Stone"        CASE "ryan"                PRINT "Hello, Goosey"        CASE ELSE                PRINT "Hello, "; N$END SELECTSLEEP 119 INPUT "Would you like to guess the secret number, yes or no"; Q$SELECT CASE Q$        CASE "yes"          GOTO 31        CASE "no"          SLEEP 1          PRINT "Fine! Leave!"          END        CASE ELSE          PRINT "What?"          SLEEP 1          GOTO 19END SELECT31       INPUT "Enter a number between 1 and 100"; SN           IF SN > 0 AND SN < 10 THEN                SELECT CASE SN                        CASE 54                          PRINT "Good job!"                          END                        CASE ELSE                          PRINT "Wrong!"44                            INPUT "Would you like to guess again, yes or no"; A$                                SELECT CASE A$                                        CASE "yes"                                                GOTO 31                                        CASE "no"                                                GOTO 63                                        CASE ELSE                                                PRINT "What?"                                                GOTO 44                                END SELECT                                ' IF A$ = "yes" THEN ' HAVE TO TURN THIS INTO A CASE                                '  GOTO 31                               ' IF A$ = "no" THEN                               '   GOTO 49                               ' END IF                END SELECT            END IF  IF SN >= 100 THEN    GOTO 31  END IF49 IF Q$ = "no" THEN        COLOR 463                PRINT "Well fine! I didn't want you to anyways!"END IFSLEEP 1PRINT "Thank you for playing."END


User avatar
Nana Samboy
 
Posts: 3424
Joined: Thu Sep 14, 2006 4:29 pm

Post » Thu Sep 23, 2010 8:33 pm

So this is my first real "program". IT took me about 3 hours to write and get some kinks out. It's defininetly not perfect. It's small and my first true attempt. So tell me what you think please.
Spoiler

Written in QBASIC
CLSCOLOR 4 'RedPRINT "NO USE OF CAPITAL LETTERS!!"COLOR 2 'GreenishINPUT "What's your name"; N$SELECT CASE N$        CASE "melanie" ''OR "Melanie"                PRINT "Well hello there pretty lady!"        CASE "mom"                PRINT "Hello mom"        CASE "austin"                COLOR 4                PRINT "oh great...you..."                SLEEP 2        CASE "larry"                PRINT "Hello dad"        CASE ""                PRINT "okay then...."        CASE "goose"                PRINT "Hello, Stone"        CASE "ryan"                PRINT "Hello, Goosey"        CASE ELSE                PRINT "Hello, "; N$END SELECTSLEEP 119 INPUT "Would you like to guess the secret number, yes or no"; Q$SELECT CASE Q$        CASE "yes"          GOTO 31        CASE "no"          SLEEP 1          PRINT "Fine! Leave!"          END        CASE ELSE          PRINT "What?"          SLEEP 1          GOTO 19END SELECT31       INPUT "Enter a number between 1 and 100"; SN           IF SN > 0 AND SN < 10 THEN                SELECT CASE SN                        CASE 54                          PRINT "Good job!"                          END                        CASE ELSE                          PRINT "Wrong!"44                            INPUT "Would you like to guess again, yes or no"; A$                                SELECT CASE A$                                        CASE "yes"                                                GOTO 31                                        CASE "no"                                                GOTO 63                                        CASE ELSE                                                PRINT "What?"                                                GOTO 44                                END SELECT                                ' IF A$ = "yes" THEN ' HAVE TO TURN THIS INTO A CASE                                '  GOTO 31                               ' IF A$ = "no" THEN                               '   GOTO 49                               ' END IF                END SELECT            END IF  IF SN >= 100 THEN    GOTO 31  END IF49 IF Q$ = "no" THEN        COLOR 463                PRINT "Well fine! I didn't want you to anyways!"END IFSLEEP 1PRINT "Thank you for playing."END




You can use the LCASE$ and UCASE$ functions to return a version of a string entirely in lower or upper case - so you don't have to do things like if (n$="word" OR n$="Word"), otherwise it looks good!
User avatar
Lori Joe
 
Posts: 3539
Joined: Tue Jun 20, 2006 6:10 am

Post » Thu Sep 23, 2010 3:45 pm

So this is my first real "program". IT took me about 3 hours to write and get some kinks out. It's defininetly not perfect. It's small and my first true attempt. So tell me what you think please.
Spoiler

Written in QBASIC
CLSCOLOR 4 'RedPRINT "NO USE OF CAPITAL LETTERS!!"COLOR 2 'GreenishINPUT "What's your name"; N$SELECT CASE N$        CASE "melanie" ''OR "Melanie"                PRINT "Well hello there pretty lady!"        CASE "mom"                PRINT "Hello mom"        CASE "austin"                COLOR 4                PRINT "oh great...you..."                SLEEP 2        CASE "larry"                PRINT "Hello dad"        CASE ""                PRINT "okay then...."        CASE "goose"                PRINT "Hello, Stone"        CASE "ryan"                PRINT "Hello, Goosey"        CASE ELSE                PRINT "Hello, "; N$END SELECTSLEEP 119 INPUT "Would you like to guess the secret number, yes or no"; Q$SELECT CASE Q$        CASE "yes"          GOTO 31        CASE "no"          SLEEP 1          PRINT "Fine! Leave!"          END        CASE ELSE          PRINT "What?"          SLEEP 1          GOTO 19END SELECT31       INPUT "Enter a number between 1 and 100"; SN           IF SN > 0 AND SN < 10 THEN                SELECT CASE SN                        CASE 54                          PRINT "Good job!"                          END                        CASE ELSE                          PRINT "Wrong!"44                            INPUT "Would you like to guess again, yes or no"; A$                                SELECT CASE A$                                        CASE "yes"                                                GOTO 31                                        CASE "no"                                                GOTO 63                                        CASE ELSE                                                PRINT "What?"                                                GOTO 44                                END SELECT                                ' IF A$ = "yes" THEN ' HAVE TO TURN THIS INTO A CASE                                '  GOTO 31                               ' IF A$ = "no" THEN                               '   GOTO 49                               ' END IF                END SELECT            END IF  IF SN >= 100 THEN    GOTO 31  END IF49 IF Q$ = "no" THEN        COLOR 463                PRINT "Well fine! I didn't want you to anyways!"END IFSLEEP 1PRINT "Thank you for playing."END




A few points that will help once you get into larger projects. Make sure to document your code properly, put comments before significants blocks explaining what they do and how. It will help you manage the code better and keeps you from forgetting what is it you've done and where. Besides that, try and avoid any usage of the GOTO command. It doesn't help readability and is bug-prone.
User avatar
Alexander Lee
 
Posts: 3481
Joined: Sun Nov 04, 2007 9:30 pm

Post » Thu Sep 23, 2010 7:43 pm

A few points that will help once you get into larger projects. Make sure to document your code properly, put comments before significants blocks explaining what they do and how. It will help you manage the code better and keeps you from forgetting what is it you've done and where. Besides that, try and avoid any usage of the GOTO command. It doesn't help readability and is bug-prone.

qbasic's functions are... very unwieldly. As much as I hate being attacked by raptors, it's much nicer to write qbasic using gotos - though I agree in other languages its much better to not use them.
User avatar
~Sylvia~
 
Posts: 3474
Joined: Thu Dec 28, 2006 5:19 am

Post » Thu Sep 23, 2010 1:04 pm

Yes, it would be a good practice to take for example upper case string of the input and then do the comparisons on that string. That way, usability is improved as the user could type MeLanIe and it would still be caught by one of the clauses in your select statements.

I know Basic has been designed to allow goto statements, but some languages have taken the approach of not allowing or encouraging it. Especially if you are forced to use line numbers and not named tags. It's possible to code so that you don't need goto statements. Loops and subroutines help, but sometimes in Basic you may have to resort to one goto anyways, I know. Good start, Shaker25.
User avatar
steve brewin
 
Posts: 3411
Joined: Thu Jun 21, 2007 7:17 am

Post » Thu Sep 23, 2010 6:15 pm

I always find it a good idea to go if (constant==variable), so if I -do- make the mistake I'll find myself with a compile failure, not a nasty crash.

<_<

(Good) modern compilers will display a warning if you do
if ( foo = bar )


I just find it really strange reading
 if ( constant == variable )

User avatar
sexy zara
 
Posts: 3268
Joined: Wed Nov 01, 2006 7:53 am

Post » Thu Sep 23, 2010 3:59 pm

Has anyone here ever used Flex? I have a technical test for a job on Wednesday and I also have to prepare a short presentation on Flex (which I've been reading up on). From what I can gather, it's very similar to WPF. If anyone has used it, is there anything in particular you think I should know about it?
User avatar
ANaIs GRelot
 
Posts: 3401
Joined: Tue Dec 12, 2006 6:19 pm

Post » Thu Sep 23, 2010 11:58 am

<_<

(Good) modern compilers will display a warning if you do
if ( foo = bar )


I just find it really strange reading
 if ( constant == variable )


It is quite strange reading that, you get used to it. I started doing it when I was writing PHP, which obviously has no compiler at all, and is far too lenient with what it allows for its own good.
User avatar
Alex Blacke
 
Posts: 3460
Joined: Sun Feb 18, 2007 10:46 pm

Post » Thu Sep 23, 2010 8:16 pm

Wrote a short (I think) enough program for generating the values of the Fibbonaci Sequence the other night. Didn't realize to count from 1 in my loop when 0 caused an error. Here is what I came up with, which probably isn't really the best but was also done at 11pm:
using System;using System.Collections.Generic;namespace conFibonacciSequence{    class Program    {        static void Main()        {            int SequenceCount = DetermineSequenceLength();            if (SequenceCount >= 2)            {                GenerateSequence(SequenceCount);            }            else            {                Console.WriteLine("Invalid input.");                Main();            }        }        static int DetermineSequenceLength()        {            int Value;            Console.Write("How many values would you like to calculate (min: 2): ");            Value = http://forums.bethsoft.com/index.php?/topic/1092028-unofficial-programming-thread/int.Parse(Console.ReadLine());            return Value;        }        static void GenerateSequence(int Count)        {            List FibNumber = new List();            int FibSum = 0;            for (int i = 1; i < Count; i++)            {                if (FibNumber.Count == 0)                {                    FibNumber.Add(0);                    FibNumber.Add(1);                }                FibSum = FibNumber[i] + FibNumber[i - 1];                FibNumber.Add(FibSum);            }            for (int i = 0; i < FibNumber.Count; i++)            {                Console.WriteLine(FibNumber[i].ToString());            }            Console.ReadLine();        }    }}

User avatar
Hella Beast
 
Posts: 3434
Joined: Mon Jul 16, 2007 2:50 am

Post » Thu Sep 23, 2010 1:19 pm

So I've started using Just BASIC because QBASIC was just too time consuming to run on Windows 7 64 bit with DOSBox.

I was wondering where and how I would use LCASE$ and UCASE$?
User avatar
Darren Chandler
 
Posts: 3361
Joined: Mon Jun 25, 2007 9:03 am

Post » Thu Sep 23, 2010 9:49 pm

I need help with this little calculator program I'm making. I'm using an array within a loop so that you can perform multiple calculations (Although it is still rudimentary, as calculations from before do not carry over). Forgive any silly looking mistakes, I'm just a beginner.

I'll just post the code then describe my problem:
#include #include #include #include #include using namespace std;int main(int argc, char *argv[]){    float x = 0;    float y = 0;    char dmas;for (;;){do {    cout<<"Divide (/), multiply (*), add (+), or subtract (-)? Press q to quit.\n\n";    cin>> dmas;        switch (dmas)    {           case '/': cout<<"\nInput a number to be divided.\n\n";                   cin>> x;                   cout<<"\nInput a number to divide by.\n\n";                   cin>> y;                   if (y == 0){                   cout<<"\nYou can not divide by zero.";                   y = 1;}                   cout<<"\n" << x / y << "\n\n";                break;                           case '*': cout<<"\nInput a number to be multiplied.\n\n";                   cin>> x;                   cout<<"\nInput a number to multiply by.\n\n";                   cin>> y;                   cout<<"\n" << x * y << "\n\n";                break;                           case '+': cout<<"\nInput a number to be added.\n\n";                   cin>> x;                   cout<<"Input a number to add.\n\n";                   cin>> y;                   cout<<"\n" << x + y << "\n\n";                break;                           case '-': cout<<"\nInput a number to be subtracted from.\n\n";                   cin>> x;                   cout<<"Input a number to subract.\n\n";                   cin>> y;                   cout<<"\n" << x - y << "\n\n";                break;                           case 'q':break;                         default: cout<<"\nThat isn't a valid entry.\n\n";                    break;    }}while (dmas != 'q');}    return 0;}


Now, when I type 'q' at any time, its SUPPOSED to break the loop, then, because after the loop the program reads that dmas = q, then it doesn't re-enter the loop, and then the program closes.

For some reason, it used to work, but now it does not. I suppose one tiny change messed SOMETHING up, what that is I do not know, but I can no longer close my program with 'q'.
User avatar
Angela Woods
 
Posts: 3336
Joined: Fri Feb 09, 2007 2:15 pm

Post » Thu Sep 23, 2010 6:11 pm

I need help with this little calculator program I'm making. I'm using an array within a loop so that you can perform multiple calculations (Although it is still rudimentary, as calculations from before do not carry over). Forgive any silly looking mistakes, I'm just a beginner.

I'll just post the code then describe my problem:

Now, when I type 'q' at any time, its SUPPOSED to break the loop, then, because after the loop the program reads that dmas = q, then it doesn't re-enter the loop, and then the program closes.

For some reason, it used to work, but now it does not. I suppose one tiny change messed SOMETHING up, what that is I do not know, but I can no longer close my program with 'q'.

Do you use Visual Studio as your IDE? If so just put ina breakpoint and step through the code and check all your variables. Though I really do not know much C++ your for loop seems like it would go on forever and it surrounds that dowhile. Again I don't really know C++ so I could be wrong or it could be by design but I would look into it.
User avatar
Nathan Maughan
 
Posts: 3405
Joined: Sun Jun 10, 2007 11:24 pm

Post » Thu Sep 23, 2010 4:27 pm

EDIT: nvm, I read the while at the end wrong, I'm not used to seeing it put on the next line after the closing brace.
User avatar
Farrah Barry
 
Posts: 3523
Joined: Mon Dec 04, 2006 4:00 pm

PreviousNext

Return to Othor Games