You are not logged in.

Announcement

#1 2014-06-30 14:33:42

darkelfqueen
The Mod Squad
From: Where everything else meets
Registered: 2012-03-21
Posts: 51772

Let's Code!

I've been talking to many ladies lately that expressed interest in learning programming. As many of you know (or not know?), that happens to be my major, hobby and passion. That's why I thought to myself, "hmmmm .... Why don't we start something where we could learn about this together? That sounds like fun, right?"

You know how they show the programmer experts in movies typing lines and lines of complicated code to hack into some system or another? It's not THAT complicated!!! It's actually pretty easy and I'd love to give everyone a taste of it. Who knows? You might end up liking it!


Section 1: What is Computer Science? Why Programming?

Before we move forward, I wanted to make one point clear. Computer Science is not about programming. Programming is just a tool that you use to do your work as a software engineer/ computer scientist. Astrologists have their telescopes, Doctors have their stethoscopes (among other things) and Computer Scientists have their programming! Computer Science is actually about ideas. About how we think about idea. How to handle and analyze information. CS actually existed before computer ever did. Most of the original Computer Scientists were actually Mathematicians and Physicists.

Now, one thing that many universities nowadays do is teach everyone, no matter what their major is, programming. Why? Well, software is everywhere! No matter what you end up working on, knowing how to program should make things easier! So, no matter what your goal in life is, make sure to try programming for a while. It will be beneficial.

Section 2: The trick behind programming

Most professors, teachers, tutors, etc. dive into programming languages right away. That always confused me. "What in the world are we writing and why?" was the question I always had. Until one professor taught us a trick, that is. The trick to learn programming and to understand software development is to realize that your computer is dumb. It doesn't understand anything. It merely follows what you tell it to do, so you better tell it what you want step by step.

Explaining a process step by step is called an "Alogrithm". When I say, give me an algorithm for brushing your teeth, it should be something like:

1. Take out toothbrush
2. Take out Toothpaste
3. Open Toothpaste
4. Put some toothpaster on the toothbrush
5. Brush your teeth using the toothbrush
6. Clean the toothbursh
7. Close the toothpaste
8. Wash your mouth with water.
9. Repeat step 8 until all paste is out

So, any time we face a problem, we need to think what the algorithm for solving it should be like. That's what Computer Science is mainly about. Solving problems.

Section 3: What do we need?

One last thing before we actually start coding. I'll need to specify the programming language we're going to start with (There are many, but we'll start with one) as well as any tools that are going to be needed.

We're going to be using Java. Java is very easy to learn and what's good about it is that in most cases, it can run on any operating system, so no matter what your computer is using, you should be good.

Now what do I need?
1. Java JDK - the latest one should be good. If you search for it, the Oracle website will be most probably your first result. This will add the java framework to your computer so we can use the JAVA programming language to write programs.
2. Eclipse IDE - Probably Eclipse Standard 4.4: This is a text editor that's especially made for programming in Java. We need it to actually write the programs.

If you have any trouble finding either of these, let me know and I'll help you.


Download those two and install them and we should get ready to rock. In the next tutorial that is. I'm writing it out right now, so hopefully very very soon.

Oh and before I forget, if you have any questions about the major, the courses, other languages or about technology, in general, feel free to ask here. We can discuss it all together.

Last edited by darkelfqueen (2014-06-30 14:34:28)



#2 2014-06-30 16:14:31

malu
Members
From: Hogwarts
Registered: 2010-02-18
Posts: 29741

Re: Let's Code!

Whoa!

Well, this is useful! :D


Snapchat: amalmooon
Insta: mal.mooon
 

#3 2014-06-30 18:28:28

angelfire
Members
From: The world I created in my head
Registered: 2010-08-12
Posts: 21425
Website

Re: Let's Code!

I'm so excitteeedddd!!! gai Thanks darky!


http://i.imgur.com/TYm0f7i.png
Twitter|Tumblr|Howrse|MCL|dA: angelfire2197          Wysp|YouTube|Elitedollz: angelfire
Art Portfolio: livininart.tumblr                                   Tumblr: askmyocsstuff
 

#4 2014-07-05 23:05:56

laurabow
Members
Registered: 2010-11-30
Posts: 992

Re: Let's Code!

Looking forward to more of this.  :-)

Many players on OMD might not realize it, but they're coding already with a basic form of HTML.  Those buttons above for Bold, Italics, Images, etc.?  Yep, that's code.  Those fancy Who Am I pages that some players have with tables, scrollbars, and different fonts/colors are more coding.  (I really wish there was an HTML button on the WAI box so we could see what we're coding as we put them together.)  It doesn't have to be complex, but it sure looks that way sometimes.

 

#5 2014-07-08 14:04:33

darkelfqueen
The Mod Squad
From: Where everything else meets
Registered: 2012-03-21
Posts: 51772

Re: Let's Code!

@angel and malu: I sure can't wait to start this either. I'm hoping that after we cover some of the basics we can start coding a game or an applet together :)

@laurabow: Exactly! People don't realize that they are already doing lots of coding everywhere. For example, if you're playing Project Spark or Little Big Planet, that has the same techniques as coding. it's not hard!

Anyways, finally, I got to start this. I had a very stressful weekend and week so I am so excited to start.

Before we move forward, I thought it might be fun to have an XBox like achievement system. So here's the deal, there'll be challenges in each tutorial.  If you solve those and take a snapshot of the code and send it to me in a PM (or email -- you can ask me about that if you want to), I'll award you a badge for that achievement. I'll be keeping track of those on one of my alts (which one is still to be decided) and later we can use those for contests and games and the like.

Anyways, let's get coding!

We're going to need Eclipse for this tutorial, so if you haven't downloaded it and the JDK yet, this might be a good time to do that. Let me know if you're having trouble with that, 'kay?

[b]Chapter Two: A Codess is born!

Section 1: How to work with Eclipse

First things first, we'll take a quick look into how Eclipse works.

Eclipse as I mentioned before is the tool that people use to write Java applications. There are others, but Eclipse has proven to be the most popular. Not to mention that it's free and will offer great plugins and tools for the future.

When you download eclipse, you'll get a zip file. Once you unzip that, you'll see the .exe file. Double clicking on it will launch Eclipse. There's no installation required for this, so we're ready to go!

On double clicking the .exe, you'll get this screen
http://i60.tinypic.com/280mvbo.png

Basically it's asking you for a directory (or a folder) that it's going to be using as a "workspace". Any code that you're going to create will get added in that folder. This way it's easier to find things. It's preferable to create an empty folder and choose that as your workspace. This way you know you won't ruin other things later ;) Don't use any folder that has important files in it.

Once you click on Ok, it will take you to a landing page since this is our first time opening Eclipse. Just ignore it for now. See that close (x) button next to the "Welcome" name of the tab? Just close it from there.

http://i57.tinypic.com/27xfebr.png

Weeeell, here we are. Our new home. This, ladies, is the view we'll always see when coding.
http://i59.tinypic.com/192ide.png

http://i59.tinypic.com/123qjgo.png

I drew rectangles around the two main portions of the screen. The coding area is where we'll be writing our code. The Output and errors will be showing in the portion at the bottom, so we'll keep an eye out for that.

And now, we'll actually start coding. Who's with me!?

Section 2: Hello, OMD World!

What we're going to do right now is write a small program that basically says "Hello, OMD World!". Every coder has to start with the Hello World program, no matter what programming language they're using. It's like the birth certificate for coders.

1. We'll create a new project. A project is a collection of code that works together to create a software, a game, an app, etc. Different programming libraries call them differently, but "project" is what most people use. And it makes sense kinda, right?

Now, how do we do that? Go to the "File" menu at the top left of the screen, then choose "New" and then "Java Project".

http://i57.tinypic.com/8vz29k.png

Now, we're going to name our project. That's what the screen you're going to get will make you do.

http://i60.tinypic.com/2qmd6ht.png

In the text area for Project Name, write "LessonOne". Notice that there are no spaces in the name. We'll explain that later.

Also notice that the first letter of each word is capitalized. That's to make it easier to read.

One thing you should know about Java is that it's case sensitive. Meaning writing "cat" vs "Cat" is actually talking about two totally different things. That's why make sure to write the words exactly as we talk about them here.

Click "Finish" and voila! We have a project.

You'll see it pop up in the left portion of the screen. If not, just let me know and I'll tell you how to get it to pop up.

2. We'll create a new class. I'm not going to go too deep into what a Class is since this is more complicated than needed at the moment. For now, know that a class is a file that holds the code we're going to be running. Eclipse makes creating those a piece of cake. Wanna see?

http://i59.tinypic.com/333l6ad.png

Again, go to the "File" menu, choose "New", but this time, choose "Class".

Again this time, you'll get a screen to name the new Class.

http://i59.tinypic.com/1znvcpu.png

In the Name textbox, write "HelloWorld", then Click "Finish" and now we have a class! If you look to the left of the screen, you should see the project. If you expand it, you'll see our class "HelloWorld" written under it. The class is now part of that project.

http://i59.tinypic.com/302xdex.png


When we created the class, you should now see a new tab in the middle portion/window of the screen.

http://i59.tinypic.com/1191fm1.png
http://i61.tinypic.com/2ymev75.png

In that new tab, you'll see this code:

public class HelloWorld{

}

What this does is basically create the class. Eclipse automatically wrote that for us. Notice that the name of the class is the same as the one we wrote in the textbox.

What happened is Eclipse went ahead and created a file with the same name as that of our class "HelloWorld.java" and then wrote that code inside it. The name written next to "public class" has to match that of the file.

3. Write our code!

Now, where do we write our code? Well, we're going to do that inside our class. To write it inside the class you go and write it between "public class HelloWorld {" and the closing curly braces "}". That indicates that it belongs there.

See below:
http://i62.tinypic.com/28re79j.png

What I did there is I added a comment into our file. A comment is any text you don't consider to be Java code but you want to include in the file say to explain something, note something to someone else reading the code, remind yourself of something, so on.

To write a comment, you write "//" and then your text. This "//" sign indicates that anything written on that line is not Java and shouldn't be run.

Now inside the class, we'll write the following:

http://i60.tinypic.com/2s66dmd.png

What in the world is this? Well ... this is called a "Main" method. We'll talk about methods later, but think of it like this. When the program runs, it goes into your class and looks for a portion of the code known as "Main" and start running the code that's there. For now, the best thing is to memorize that code as weird as it sounds. Don't worry, you'll write it a lot that you'll know it by heart in no time.

Now inside the curly braces of that method (similarly to the class), we're going to start writing the code that prints to our output the "Hello, OMD World." statement.

To write something to the output, you need to write "System.out.println" and between "(" and ")" we write the text we want to write. This is read out loud as System.Output.PrintLine and your text. It's basically as it sounds. it tells the system to print your text to the output and write it on its own line. Meaning it will automatically pretend you pressed "Enter" at the end of the text.

http://i62.tinypic.com/5clqa8.png


While writing you'll notice that Eclipse will start showing you suggestions like the one I'm showing in the top. This helps a lot! You'll see!

Now what we're missing is write our text between the "()". Notice that we have to write our text between quotation marks. Basically this is telling the system, print this out and don't care what's inside it.

Also, very important. Every time we write a line of code, we end our statement with ";". This symbol tells Java that you're done with this statement. That it reached the end of this statement and should start executing it.

Now you should have something like this:

http://i58.tinypic.com/2mebal1.png

Now, don't forget to save. You can find "Save' under the "File" menu or you can just press on Ctrl+S. You'll find the shortcut easier later when we start writing long code.

Nooooow, we run our program! Are you ready?

To run the program, notice that play button under the "File" menu and the other menus?

http://i57.tinypic.com/2lxdrps.png

*Drum Roll* The program will run in less than a second. Yes, this is how fast it is.
If you look down, at the output area, you'll see *gasp* our output!

http://i60.tinypic.com/xgd5ys.png
http://i61.tinypic.com/kbzo5c.png

CONGRATULATIONS! You're officially a codess!!!!

If you write this code and send me the snapshot, you'll get:

http://i60.tinypic.com/ofts8x.png

You've unlocked the "A Codess is born" achievement.

I was planning to talk about more, but felt this might take time to get eclipse running for the first time, so I'll stop at this. The next tutorial will probably up in a day or two. I already have it written out, but still need to upload the snapshots and so on. Next time we're going to talk about numbers and operations in Java. So, stay tuned! And start coding ;)

As always, if you have any questions, post them here or PM me.

Last edited by darkelfqueen (2014-07-08 14:08:03)

 

#6 2014-07-09 07:38:21

anela
Members
Registered: 2009-10-26
Posts: 8

Re: Let's Code!

Oh yeah i wanna be a programer .. I started to learn to code .. If u want to,the page to learn is codeacademy.com


Forget the haters,cuz somebody loves ya !
 

#7 2014-07-13 20:15:37

xemoxrockerx
Members
From: Land of Storms and Sunshine
Registered: 2010-05-15
Posts: 4092
Website

Re: Let's Code!

This is sweeeet. I get to review/not forget my Java coding whilst I re-learn C language in school.

Oh, and random tidbit, if you wanna "learn" how to code, or the very very basic mechanics of coding there's this cute little game it's called "Hour of Code - Lightbot" and it's cute and has very basic coding mechanisms in it. It does help you get into the mindset of creating a program though. :)


http://4.bp.blogspot.com/-DUQ5qc0D02A/VFrBeTyyrxI/AAAAAAAACG8/_w5ujDpgwR4/s1600/Emorocker1-sig-01.png
|Older Art. Updated: 10/17/14| Instagram : p2ionics |
| Twitter : psionic_nerd | Tumblr Writing Blog : under-latest-nostalgia |
Thanks for the ava/sig shadowchild03!
 

#8 2015-04-23 15:36:02

esah
Members
Registered: 2013-05-26
Posts: 2

Re: Let's Code!

I loveee coding, i think this will be my job :))

 
 

Board footer