Thursday, February 17, 2011

First C# post

Want me to be honest? I have no clue if this blog setup will work with the coding i'm going to be doing, hell, i don't even think they have code tags, so ill prolly use the quotes :P

Ok, so C#, Its one of the easier to learn languages, it follows a pretty simple pattern. One of the harder things to learn about c# is Object Oriented Programming. Its somewhat hard to explain, but lets say you have a Mixed case of soda. And each can of soda is of a different Brand and Flavor. In c# and other object oriented languages, you can make what are called "objects", an object being a reference to anything. In this case the cans of soda. so the object is the box that the sodas are in. An object holds different variables (settings) that can be set for each instance (an instance is, in this case, 1, specific, can of soda).

So far we have A Box, and 12 cans inside that box.
The box represents the object, and the cans represent specific instances of that object.

Inside the object for the cans (each instance) has settings that can be independent from all the other cans. For this analogy were going to give each can two settings, A brand, and a Flavor.

Our analogy now looks something like this:
  • Box
    • Can1
      • Brand
      • Flavor
    • Can2
      • Brand
      • Flavor
    • Etc
So you can see how each can has its own settings. In c# we can access these settings very easily. Assuming that all your names are the same as what we have here, you could simple use Can1.Brand or Can1.Flavor to get the setting that you need for a specific can.

The code is almost just as easy, one way to do it would be to make a list (more on that later) of the cans in the "box", and the code to get the "brand" of the first "can" (Cans is the lists the cans)


That would give you the brand of the first can in the list. Really, its that easy (That's just accessing the variables, the coding of the Objects itself isn't too hard, nor is actually making the instances.)

You will find that the "hard" part of coding comes in managing large projects, and making everything in a large project work nicely together. Most programmers would agree that the absolute worst thing that can happen while programming (often worse then losing 2-3 hours of code due to a crash or something) is getting an obscure bug that cripples your code. But that cant be replicated 100% of the time. It can take a long time to find something as small as a single character typo (an x to a y for example)

Anyone whom read both of my first posts will realize that i didn't follow suit and write a hello-world tutorial. I thought it was more beneficial if i wrote something to help people grasp the concept of object oriented programming first, though I'm not sure how well I did, I would hope not too bad for a first try.

My Blog

I wanted to make my blog, not as a blog of my life and actions (though there may be some of that in here) but about Programming, specifically a blend of Html PHP C# and XNA (also c#)

This first blog post i wanted to be about me, for two reasons:
  • 1. I'm not really really good at expressing my thoughts (of any kind) in any form. Such as over the internet, its not that i don't want to, I just don't generally know how to express my thoughts into an understandable form.
  • 2. I thought it would be nice to start off with a little intro about myself.

I wanted to tell any one that reads this that i may ramble about meaningless things from time to time, I do that a lot. Just ask my friends :P

I love to program, in general, i have a few specific projects im currently working on, My main project is my Minecraft Classic server (StormCom), and the secondary project is a Map Editor for WFTO (War for the Overworld ~name subject to change)

But i thought that I might be able to do more good to the community in general if i shared my knowledge of programming, and the concepts behind the different languages. Don't get me wrong, I dont claim to be an expert, and there are a great number of things that i haven't even begun to understand. But i do think that i'm a decent programmer.

I can't learn very easily from tutorials that other people write, I don't know if it's just me or what, but i find that I have to learn things on my own, through trial and error, usually. And i think its because the tutorials that are out there assume that you already know the basics, like how to load an object, or create a list. When it could be your first time ever touching code. Often enough I get frustrated and stop trying to learn a specific topic if no one has gone back to the basics and attempted to explain every detail of what they did in a way that i could understand. Thats what im going to try and do in this Blog, assuming that i can keep up the motivation to continue posting here.

I also dislike tutorials that take up 10 minutes of your time to explain to you WHAT something like C# is, when all you REALLY want to know is how to make some sweet ass form for a program, or draw some 2d sprites in XNA, If you want to know who made C# or when or why, your in the wrong place, thats not why im here.

Without further ado, Ill call this post quits, and maybe start writing up the basic tutorial for C#, a simple Hello world program that we will work into a simple form application, and from there, perhaps a file-editor, or simple chat program, who knows, certainly not me, at least, not yet.

If someone reading these blogs would like to specify a specific topic for me to explain, even if its WAY off course of what were working on at the time, then by all means, let me know, and ill see what i can do :D