1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[Journal] Advice and Tutorials of a Software Developer

Discussion in 'BlackHat Lounge' started by Senotaru, Dec 24, 2011.

  1. Senotaru

    Senotaru Registered Member

    Joined:
    Jan 17, 2011
    Messages:
    67
    Likes Received:
    11
    Hello everyone,

    This is my second attempt at this style of thread. I enjoy helping out the community here and am here to answer any questions you have about programming in the SEO industry along with some commentary on my own software that I'm working on.

    I've been in the software business since I've been 16. I was originally given an internship at a local language company which deals in software very similar to Rosetta Stone. At 18, I was promoted to lead developer in the mobile department, where I overseen the development of the mobile version of said software. I did this for a year until I decided it was time to move on. I went from there and started designing point-of-sales software for small to medium sized business in my local area. This was fun, but its a lot of work and not much money, so I've since moved on to working as a software consultant for medium to large sized businesses in the northeastern region of the United States. This is what I currently do, while developing SEO software in my off-time.

    With that being said, the goal of this thread is to answer any programming or software-business related questions you may have. My main language is C#, but I'd be happy to help with any PHP or Java problems you may be having. The intent here is to inspire more people to get into software and toy around with their computers and make them do what they want. This thread may get technical at times, but that is not intended to discourage anyone from starting. I am here for the professional programmer as well as the newbie. If you ask a question, I'll do my best to give you some insight into the solution. This will be a mutually beneficial thread, since people who know nothing about software will have a chance to learn to program, and I might stumble upon some concepts which I haven't had the chance to explore.

    This post should be seen as an introduction to what is to come. I will type up a response about some software I've been toying with for the last few days and walk through step-by-step on how I plan and execute my ideas for programs. While I'm typing up these responses, I welcome any questions you guys may have about programming or business. Hopefully this thread sticks around and people can learn from it.

    Here are some great resources to check out for the beginning developer:

    Quicksort Visualization - A visual Introduction to Computer Algorithms

    Download C# Express Edition:


    More posts to come,
    -Seno
     
    • Thanks Thanks x 1
  2. Senotaru

    Senotaru Registered Member

    Joined:
    Jan 17, 2011
    Messages:
    67
    Likes Received:
    11
    Basic Rundown of Concepts

    This is just a SUPER basic introduction to programming. I have some SEO stuff to immediately follow this, but I want people who know nothing of computer programming to be involved as well. Computer programming now-adays has boiled down to object-oriented programming. This is a simple way of passing around objects which interact with other objects. You can pass objects via name, and declare them as types.

    Think of it like this: If I have a toolbox full of different types of Hammers called Toolbox A, and a toolbox full of Wrenches called Toolbox B:

    [​IMG]

    If I wanted to tell you to go and get a toolbox and get me a hammer to do some work, how would I tell you to do this? First, I'd tell you to get Toolbox A, then, in the hammers section, to get me the Claw Hammer. Current day programming languages work in a similar manner. Except rather than a toolbox, we call our 'boxes' classes.

    When you're writing a program, you break up bits of useful and reusable code into these classes, which we name.

    In the above example, the code would appear something like this:

    Code:
    Toolbox toolBoxA = new Toolbox();
    toolBoxA.Hammers.ClawHammer();
    
    The first bit of code: "Toolbox" tells the compiler what type of object to expect. So, we're saying we expect a toolbox to fill this area. "toolBoxA" is naming that area, so we can reference it later. the "= new Toolbox();" is setting that object to equivalent to something. So at that moment, we have a new toolbox called "toolBoxA" Then, we interact with that toolbox we created. To open a drawer in this toolbox, you just use a period. So toolBoxA.Hammers opens that specific area of code. When we call ClawHammer, we're grabbing something out of the box. Understanding objects is key to current-day programming. Feel free to ask a question if this doesn't make sense thus far. The rest of the posts in this thread and any questions past this point will hinge on understanding basic classes and interacting with them; making a new toolbox, opening a drawer, and interacting with them.

    Putting This to Use
    Tutorial: Very Basic Difficulty

    Lets say you want to make your first program. Lets go beyond simple "Hello World!" examples, you can find that on your own and there are thousands of examples of this. Lets make a toolbox -- a class.

    Make a new project in Visual Studio. Select Windows Forms Application.
    On the left-hand side, you'll find your Toolbox. Locate the button control and add 3 buttons. Set the Text of the bottons in the Properties window to "Claw Hammer", "Ball Pein", and "Cross Pein" respectively:

    [​IMG]

    Double click your first button. This will generate the code that fires when we interact with the button. We're going to want to create a new class outside of the partial class form1. Go under the second to last bracket and type: Public class Hammers { }. Your code will look something like this at this point:

    Code:
    namespace BHW_Example_1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
    
            }
        }
    
        public class Hammers
        {
        }
    }
    
    Now we're going to want to make Hammers do something. In the Hammers class, make a String type and name it "currentHammer". Your code should now look as follows:
    Code:
        public class Hammers
        {
            String currentHammer;
        }
    
    Now we're going to want to interact with this a little bit. We're going to make blocks of reusable code which can be called at a later time. We're going to add 4 methods. Methods have 4 things to them. Their modifier, their return type, their name, and their parameters. :

    Code:
        public class Hammers
        {
            String currentHammer;
    
            public void getClawHammer()
            {
            }
    
            public void getBallPeinHammer()
            {
            }
    
            public void getCrossPeinHammer()
            {
            }
    
            public void showCurrentHammer()
            {
            }
        }
    
    • The modifier tells us who can see it. Public allows classes outside of that specific class see the method. Private means only methods within the class can see it. There are others, but we'll reserve those for another tutorial.
    • The return type is what is returned when the method is called. We don't want to return anything with out methods, so we just put void.
    • The name is what we're calling that tool. This is how we will call that block of code later in the program.
    • The parameters are what we're giving that block of code. We're not going to give anything to our methods, so we will love them blank.
    Now, when these blocks of code are called, we want them to do something. We want to change the CurrentHammer that we have selected, so in each one of the methods, set currentHammer to a value, and call showCurrentHammer:


    Code:
        public class Hammers
        {
            String currentHammer;
    
            public void getClawHammer()
            {
                currentHammer = "Claw Hammer";
                showCurrentHammer();
            }
    
            public void getBallPeinHammer()
            {
                currentHammer = "Ball Pein Hammer";
                showCurrentHammer();
            }
    
            public void getCrossPeinHammer()
            {
                currentHammer = "Cross Pein Hammer";
                showCurrentHammer();
            }
    
            public void showCurrentHammer()
            {
            }
        }
    Finally, we want to display our hammer to the user. Currently if we run this, nothing will happen, so in showCurrentHammer, lets display a messagebox to the user:

    Code:
            
    public void showCurrentHammer()
            {
                MessageBox.Show(currentHammer);
            }
    MessageBox is a class with the Method show, it asks for a String type parameter, so we give it our currentHammer, which is also a string.

    Great! Now we have a class which does something, complete with reusable code. Now, we're going to want to interact with this class. In the Form1 class, above the public Form1() method, type

    Hammers toolBoxA = new Hammers();

    this makes a type in memory called toolBoxA and sets it to a new version of the Hammers class. Now go back to your form1 design and double click on all of the buttons. This will generate basic code that will fire every time you click a button. Now, we want to interact with our toolbox, so in every one of those new blocks of code, you're going to want to call to appropriate method. The final code will look like this:

    Code:
    namespace BHW_Example_1
    {
        public partial class Form1 : Form
        {
            Hammers toolBoxA = new Hammers();
    
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                toolBoxA.getClawHammer();
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                toolBoxA.getBallPeinHammer();
            }
    
            private void button3_Click(object sender, EventArgs e)
            {
                toolBoxA.getCrossPeinHammer();
            }
        }
    
        public class Hammers
        {
            String currentHammer;
    
            public void getClawHammer()
            {
                currentHammer = "Claw Hammer";
                showCurrentHammer();
            }
    
            public void getBallPeinHammer()
            {
                currentHammer = "Ball Pein Hammer";
                showCurrentHammer();
            }
    
            public void getCrossPeinHammer()
            {
                currentHammer = "Cross Pein Hammer";
                showCurrentHammer();
            }
    
            public void showCurrentHammer()
            {
                MessageBox.Show(currentHammer);
            }
        }
    }
    
    Now hit f5 and compile and run your program. Click some of the buttons and see what happens. There you have it. You made your first program, and interacted with classes with reusable code.

    [​IMG]


    Conclusion
    This was just a basic run down for what is to come. The reason I do this tutorial is because programming is all about types, classes, and interacting with them. Everything we do from this point forward will follow interacting with classes. You have to have a basic understanding of how to create and interact with classes before you can understand how to do anything beyond this. I will get into SEO tutorials after this. If you ever need anything explained better, let me know and I will try to better explain what is happening. I'm not sure at what pace to go at, so if I'm moving too quickly, let me know and I'll revisit something. Like I said, the goal here is to get as many people interested as possible. If you want to learn, feel free to just ask.
     

    Attached Files:

    Last edited: Dec 24, 2011