Jump to content

Programing Practice

Windows7ge

At my college despite it being unrelated to my major I had to take a Computer Science course. Knowing nothing about programming I tried to learn a little about Java of which I could not wrap my head around at all. Then I tried Visual Basic (Half way through the course I was informed that it is a rather old/dead unpopular language) and actually found it rather enjoyable and relatively speaking easy to understand (starting out I couldn't understand any of it) now I want to pick up programming as a hobby. I'm a slow learner and I like being hand on so I figure the best way for me to learn more is to write small programs that most novices should be able to achieve or perhaps something a little more challenging to force me to think.

 

If anybody thought TL:DR:

I'm looking for ideas of small programs I can write to practice Visual Basic. It's just for fun and the tools (programs) can be useful from time to time but I've run out of my own ideas.

Link to comment
Share on other sites

Link to post
Share on other sites

I find the best thing to do is automate a task for do daily. 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, M.Yurizaki said:

Learn some basic algorithms, like those for sorting, those for compression/decompression, or reading through a text file and picking something out of it.

 

Or you could try to make some basic games like Tic Tac Toe or Klondike Solitaire.

When I took the class he went over basic sorting although I could use a refresher. I think it's worth looking up. Compression/decompression I wouldn't even know where to start. I only have theories as to how compression works but it's something I can try looking into. I get the feeling in my research i'll get a large number of things thrown in my face that I have no understanding of so I might get overwhelmed trying to understand it. I like the idea for a program that can open and search a text document then pull data from it or maybe even insert a line of data. I'll look into it.

 

We did make Tic Tac Toe in the class but never tried Solitaire. Something I have yet to attempt is a calculator. Near the beginning of the semester he had us create a basic calculator interface but we didn't put any code behind it. I might attempt it but I don't know if I know enough yet to make it work smoothly.

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, vorticalbox said:

I find the best thing to do is automate a task for do daily. 

That idea was among the first programs I made. Anything that was a very repetitive task I made a program for. An example is I made a simple program that could convert any character with a Decimal value between 0 - 255 and have it output the characters Hex, Dec, and Binary equivalent. Unfortunately I don't know how to directly convert the input to those 3 outputs so instead of some type of converter the program simply acts as a dictionary and compares the input against the available characters in a large case statement then each case option has the values manually entered in. If a match is found the entries in the case are output to a list box on the main form.

Link to comment
Share on other sites

Link to post
Share on other sites

10 hours ago, Windows7ge said:

I'm looking for ideas of small programs I can write to practice Visual Basic.

Don't bother with VB. If you want a more relevant equivalent then focus your efforts on C#.

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

5 hours ago, Windows7ge said:

An example is I made a simple program that could convert any character with a Decimal value between 0 - 255 and have it output the characters Hex, Dec, and Binary equivalent. Unfortunately I don't know how to directly convert the input to those 3 outputs so instead of some type of converter the program simply acts as a dictionary and compares the input against the available characters in a large case statement then each case option has the values manually entered in. If a match is found the entries in the case are output to a list box on the main form.

I am doing the dame program in C#, very simmilar to VB, and the hardest thing is just the way you convert it. If you are testing it for each of the 255 values, its painfully unefficent. If you try concerting 8 bit numbers ( up to 65 535) it would take quite a long time. Try to make methos that take the number to convert as a parameter and outputs the result (each one converting to hex or binary). Then simply call them for one decimal number. Nothing hard if you know how to convert numbers, if you want, try to do it without the dictionary :)

Link to comment
Share on other sites

Link to post
Share on other sites

6 hours ago, Windows7ge said:

That idea was among the first programs I made. Anything that was a very repetitive task I made a program for. An example is I made a simple program that could convert any character with a Decimal value between 0 - 255 and have it output the characters Hex, Dec, and Binary equivalent. Unfortunately I don't know how to directly convert the input to those 3 outputs so instead of some type of converter the program simply acts as a dictionary and compares the input against the available characters in a large case statement then each case option has the values manually entered in. If a match is found the entries in the case are output to a list box on the main form.

I did a similar thing in college, the data class we had had questions on converting numbers two and from binary and hex which we had to show working.

 

and seeing as the test was open book, i made a programme to do it all for me. I finished that test 100% in like 10 mins and most of that was writing the step down lol

 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

10 hours ago, Nuluvius said:

Don't bother with VB. If you want a more relevant equivalent then focus your efforts on C#.

I have considered looking into more relevant popular languages but I wouldn't know where to start. I have a basic enough grasp on VB. If C# is written in a similar way then I might find the transition kind of easy but if it's completely different then I might as well be back at step 1.

 

Maybe you could give me an example of how C# is written? How would you write the example code below in C#?

 

Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
	Dim inputOne as String
	Dim inputTwo as String
	Dim output as Decimal

	inputOne = txtInputOne.Text
	inputTwo = txtInputTwo.Text

	'Check inputOne for validity

	If String.IsNullOrEmpty(inputOne) Then
            MessageBox.Show("Input One is empty.")
            txtInputOne.Focus()

	ElseIf Not IsNumeric(inputOne) Then
            MessageBox.Show("Input One is not a number.")
            txtInputOne.Clear()
            txtInputOne.Focus()

	ElseIf inputOne < 0 Then
            MessageBox.Show("Input One cannot be less than 0")
            txtInputOne.Clear()
            txtInputOne.Focus()
                       
    'Check inputTwo for validity
      
    If String.IsNullOrEmpty(inputTwo) Then
            MessageBox.Show("Input Two is empty.")
            txtInputTwo.Focus()

	ElseIf Not IsNumeric(inputTwo) Then
            MessageBox.Show("Input Two is not a number.")
            txtInputTwo.Clear()
            txtInputTwo.Focus()

	ElseIf inputTwo < 0 Then
            MessageBox.Show("Input Two cannot be less than 0")
            txtInputTwo.Clear()
            txtInputTwo.Focus()
    Else
      		output = CInt(inputOne) + CInt(inputTwo)
      		txtOutput.Text = output
      
End Sub

 

Link to comment
Share on other sites

Link to post
Share on other sites

17 minutes ago, Windows7ge said:

I have considered looking into more relevant popular languages but I wouldn't know where to start. I have a basic enough grasp on VB. If C# is written in a similar way then I might find the transition kind of easy but if it's completely different then I might as well be back at step 1.

 

Maybe you could give me an example of how C# is written? How would you write the example code below in C#?

 

 

 
void btnCalc_Click(object sender, RoutedEventArgs e)
{
    string inputOne,inputTwo;
    decimal output;
    
    inputOne = txtInputOne.text
    inputOTwo = txtInputOne.text
    if(String.IsNullOrEmpty(inputOne))
    {
        MessageBox.Show("Input One is empty.");
        txtInputOne.Focus();
    }else if(String.IsNullOrEmpty(inputTwo))
    {
        MessageBox.Show("Input Two is empty.");
        txtInputOne.Focus();
    }else if(inputOne <= 0)
    {
        MessageBox.Show("Input One cannot be less than 0");
        txtInputOne.Clear();
        txtInputOne.Focus();
    }
}

you get the Idea :)

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

11 hours ago, Merkey said:

If you are testing it for each of the 255 values, its painfully unefficent. If you try concerting 8 bit numbers ( up to 65 535) it would take quite a long time

I know, I know. It's reasons like these as to why I'm not cocky about knowing a fraction of an unpopular programming language. If I knew how to do a direct conversion not only would there be far less code but it'd be much more efficient. Although according to what I was told in a case statement it only reads up until it finds a match so it doesn't go though all 256 options (0 - 255) every time (Actually less than that. It's only 189 because a lot of those options are nothing but white spaces) 

 

11 hours ago, Merkey said:

Try to make methos that take the number to convert as a parameter and outputs the result

You might as well be talking to a toddler right now because I didn't understand half of that. As I said I'm a very slow learner. I took the class and finished it with either a 89% or 91% (can't remember which) but that's because I tried my freaking heart out and the professor was going really easy on us. Right now how much I know I would compare to a person who knows how to build a computer but doesn't know what any of the components are called. I have probably used methods, used conversions, and parameters, but I have no idea what code it was where I used them.

Link to comment
Share on other sites

Link to post
Share on other sites

11 minutes ago, vorticalbox said:

void btnCalc_Click(object sender, RoutedEventArgs e)
{
    string inputOne,inputTwo;
    decimal output;
    
    inputOne = txtInputOne.text
    inputOTwo = txtInputOne.text
    if(String.IsNullOrEmpty(inputOne))
    {
        MessageBox.Show("Input One is empty.");
        txtInputOne.Focus();
    }else if(String.IsNullOrEmpty(inputTwo))
    {
        MessageBox.Show("Input Two is empty.");
        txtInputOne.Focus();
    }else if(inputOne <= 0)
    {
        MessageBox.Show("Input One cannot be less than 0");
        txtInputOne.Clear();
        txtInputOne.Focus();
    }
}

you get the Idea :)

I actually have errors in my code (I typed it up in about 30 minutes). I have to read my code several times over before it's correct.

 

C# is definitely different but I can see the similarities. I could probably start by rewriting programs I have made already from VB to C# that would probably be the best introduction to the language for me.

Link to comment
Share on other sites

Link to post
Share on other sites

14 minutes ago, Windows7ge said:

You might as well be talking to a toddler right now because I didn't understand half of that. As I said I'm a very slow learner. I took the class and finished it with either a 89% or 91% (can't remember which) but that's because I tried my freaking heart out and the professor was going really easy on us. Right now how much I know I would compare to a person who knows how to build a computer but doesn't know what any of the components are called. I have probably used methods, used conversions, and parameters, but I have no idea what code it was where I used them.

Ah yes, the lingo programming languages use. I suppose this could be useful as a tutorial topic.

 

But the gist of it is:

  • Symbols, variables, fields, properties, and members are typically referring to the same thing: a name for some data.
  • Subroutines, functions, procedures, and methods are typically referring to the same idea: a group of instructions that you want to invoke without having to copy and paste them over and over.
  • Arguments: What you pass into a function. e.g., if you call sin(x), x is the argument.
  • Parameter: In the function, it's the input variable(s) of that function. e.g., when you're looking at the function sin(float x), x is the parameter.
    EDIT: A quick read I just did made me find out "argument" and "parameter" is used interchangeably, but this is how I distinguish it. So it may be different for other people.

Multiple names for the same thing came about for different programming paradigms. For example, members and methods are usually something you talk about in classes for OOP capable languages.

 

Anywho, I did attempt another tutorial topic if you want to read it:

 

Edited by M.Yurizaki
Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Windows7ge said:

Maybe you could give me an example of how C# is written? How would you write the example code below in C#?

Noted that it's been done already but if it were me then I'd throw all of that out and start again. It's a mess of if elses and moreover you're coupling View to ViewModel and all of that is just bad.

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

@M.Yurizaki

The class I took definitely went over most if not all of that however it was not really explained what each of these words meant or represented. It was an introductory course but the professor spoke as if he expected us to already know what most of these things were. I'll definitely read your guide when I find the time.

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, Nuluvius said:

Noted that it's been done already but if it were me then I'd throw all of that out and start again. It's a mess of if elses and moreover you're coupling View to ViewModel and all of that is just bad.

I threw that together in about 30 minutes as an example and after posting it I noticed I screwed up the elseif list with just an if. I have to proof read things many times over before I get it right.

 

"View to ViewModel" I have no idea what this is. Also as an introductory course (minus my own errors) this is more or less how he taught us to do it for simple input, error checking, and output.

Link to comment
Share on other sites

Link to post
Share on other sites

6 minutes ago, Windows7ge said:

"View to ViewModel" I have no idea what this is. Also as an introductory course (minus my own errors) this is more or less how he taught us to do it for simple input, error checking, and output.

Yeah they don't really give you much in the way of doing things right or caring about good design principals... That's part of the reason why the majority of graduates know absolutely nothing when entering industry.

 

Here you go:

 

Principals, Practices and Patterns

Methodologies

Paradigms

Be Aware of

Learn as much of that as early as you can, I suggest that you do so in parallel with your syntax play.

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

@Nuluvius

That's quite the list. I'll read into it but like I said in my original post programming is only going to be a hobby not a carrier. Programming isn't part of my college major the college just forced me to take at least one programming related course despite how unlikely I'll ever use it in my field of interest.

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, Windows7ge said:

I'll read into it but like I said in my original post programming is only going to be a hobby not a carrier.

Even so I'm an advocate of always doing a thing properly and to the best of one's ability.

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Nuluvius said:

Even so I'm an advocate of doing a thing properly and to the best of one's ability.

Ditto, with my field of interest I've seen setups slapped together in such a way that "It works." but it's done so far off from proper that it pisses me off that they even tried.

Link to comment
Share on other sites

Link to post
Share on other sites

Yeah, I suggest you switch to something else as well. C#'s basically Java done right although it's frusterating how C# is more or less tied to Microsoft stuff. Python's pretty good for learning too so maybe consider trying to learn that instead.

Link to comment
Share on other sites

Link to post
Share on other sites

30 minutes ago, ElfFriend said:

Yeah, I suggest you switch to something else as well. C#'s basically Java done right although it's frusterating how C# is more or less tied to Microsoft stuff. Python's pretty good for learning too so maybe consider trying to learn that instead.

If I'm going to switch languages then I'd like to move to one that is similar enough to where I can gradually compensate for the differences as oppose to jumping into something that is so different that it's a slap in the face. The example C# code that vorticalbox showed me looks like something I could work with. It's clearly different from VB but appears similar in many ways. Transitioning between the two is something I think I can do given enough time.

 

I tried looking up a snippit of Python code and I had no idea what I was looking at.

Link to comment
Share on other sites

Link to post
Share on other sites

Then yeah I suggest learning C# and then trying to maybe pick up C/C++ or Java. Once you know C# learning the other 3 I mentioned shouldn't be too much effort. If this wasn't just for a hobby I'd suggest learning Python, Haskell, Assembly, etc. at some point too but for hobby purposes, even just knowing C# would be sufficient.

Link to comment
Share on other sites

Link to post
Share on other sites

27 minutes ago, ElfFriend said:

Then yeah I suggest learning C# and then trying to maybe pick up C/C++ or Java. Once you know C# learning the other 3 I mentioned shouldn't be too much effort. If this wasn't just for a hobby I'd suggest learning Python, Haskell, Assembly, etc. at some point too but for hobby purposes, even just knowing C# would be sufficient.

I cannot list them all because I can't remember them but a student from one of my college classes mentioned that he had learned several different programming languages and was pursuing a carrier in programming. Good for him. I'm pursuing computer networking but if I can learn one programming language that'd be great. To transition from VB to C# seems doable but even if I pull it off I don't know if how I write my code is or would be good or bad. According to Nuluvius even my VB code isn't well written. If I convert to C# out of habit I'd still write my programs similarly.

 

The only solution I have to that is to post the code for a program on here that I wrote and ask for criticism. If there's one thing I know the forum is good for it's receiving criticism but so long as it's constructive and intended to help then I won't mind.

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, Windows7ge said:

I cannot list them all because I can't remember them but a student from one of my college classes mentioned that he had learned several different programming languages and was pursuing a carrier in programming. Good for him. I'm pursuing computer networking but if I can learn one programming language that'd be great. To transition from VB to C# seems doable but even if I pull it off I don't know if how I write my code is or would be good or bad. According to Nuluvius even my VB code isn't well written. If I convert to C# out of habit I'd still write my programs similarly.

 

The only solution I have to that is to post the code for a program on here that I wrote and ask for criticism. If there's one thing I know the forum is good for it's receiving criticism but so long as it's constructive and intended to help then I won't mind.

I'd also suggest looking at design patterns and the like but if you're just writing code for yourself and without the intention of modifying it in a few years, it's quality doesn't really matter that much.

 

Anyway here's a good resource for learning about code quality. It's the course website for the software engineering class I took during winter. https://hcitang.github.io/seng301/?_escaped_fragment_=a1.md#!index.md

(Hopefully Tony's fine with me linking to it. After all it can be found via google, although the search terms have to be rather specific. Anyway Tony's an awesome prof so I really can't see why he wouldn't be fine with his notes being used for "the greater good")

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×