Results 1 to 9 of 9

Thread: Concepts of Programming

  1. #1
    Join Date
    Feb 2012
    Location
    DON'T PM ME ASKING FOR STUFF
    Posts
    2,170
    Mentioned
    38 Post(s)
    Quoted
    423 Post(s)

    Default Concepts of Programming

    Before we start programming or learning the basics at least, I suppose it would be necessary to read up on how a computer works.
    What is a computer?
    According to the Von Neumann theory a computer looks something along these lines:



    It runs in what can be simplified to a basic list of items. Think of this. When you turn on the pc, the CPU is already powered and storing information, it’s just awaiting a signal to boot up and start a line of code. I suppose it could look similar to this:
    • Fetch Instruction
    • Decode
    • Run/Execute
    • Fetch Instruction
    • Decode
    • Run/Execute..
    Essentially a program is just a set of instructions which is written in a format the human eye can read, turned into Hexadecimal and Binary and read by the computer. (To simply put it)

    What is a compiler/interpreter?

    Now we have that out the way, it’s time to start talking about programming itself.
    Well, there are two types of script readers, Interpreters and compilers.
    Interpreters run code in real time, essentially they take a line of code, run it. Take another line of code. Run it.
    Compilers however, read all of the lines of text squeeze it into a format the computer can read and THEN execute it… Clever eh?
    Interpreters are used more than before due to being quicker, think of it this way? An old system back in the 50’s – 60’s running on an interpreter? Reading each line individually then progressing? Would have taken a while if the script was over 1000 lines long
    There are a few different types of ‘script/code’.
    And they are as follows:



    Decision Statements
    If Statement
    The ‘If statement’ responds with anything being true or false. For example:



    If TimeFromMark is Greater than Time then the result is True.

    If else statement
    ‘if-else statements’ are checking the true and the false. For example, the code here (written in c#) will check if the Boolean flagCheck is true. If it is it will execute the first ‘method’(Blue) if not it will execute the second (Green).



    Switch Statements
    A switch Statement allows multi-way branching. To sum it up, it allows you to create a complex collection of if-else statements without writing 100’s of lines. In Pascal we call them cases.



    Recursion

    Now we are going to fall a little deeper into Programming with Recursion. I'm not very good at recursion and the only examples I've seen have been poor. But hopefully I can help.

    So basically, Recursion is a procedure/function/method which calls itself within itself..

    This is the example I have:


    As you can see the recursion here is that it is calling itself until the value set in the parentheses. In this example it is defined as n.

    I highly suggest for a better tutorial on recursion you click this link:
    http://villavu.com/forum/showthread.php?t=98149

    Object Orientated Programming
    OOP is a programming paradigm that represents concepts or identities as objects. The easiest way to grasp this is to dive in and try it yourself. Objects are used to interact with one another.

    So essentially objects are self-contained data structures that consist of 3 things. Properties/Attributes, Methods and events.

    Properties are used to specify the data represented by the object
    Methods specify an objects behavior.

    Classes
    These are best seen as blueprints for an object. They define how the object behaves with the methods within.

    Method
    Methods are the 'important' parts to classes, procedures etc etc.

    The bit highlighted below is a method:


    So essentially Methods is everything between { and } (In Most Languages).

    However, with Pascal we use begin and end.


    Nesting

    Nesting is essentially a method in a method... So in simba you will see it as begin begin end end.

    E.g:



    I've colour coded the nesting, hopefully that will be easier to understand

    For now I am done. I will probably write a tutorial in the future which gets more and more difficult.
    Last edited by xtrapsp; 04-02-2013 at 02:28 PM.

  2. #2
    Join Date
    Jan 2012
    Posts
    369
    Mentioned
    6 Post(s)
    Quoted
    91 Post(s)

    Default

    Nice start mate hope this tutorial gets to cover most of OOP programming in time! Good luck with it, looking forward to seeing it expanded!

  3. #3
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Nice job. Will give indepth response when I get home. Class is about to end for this period. (Villavu is unblocked. >: D)

  4. #4
    Join Date
    Nov 2012
    Posts
    2,351
    Mentioned
    55 Post(s)
    Quoted
    603 Post(s)

    Default

    C#!

    Interesting read xtrapsp <3 would love to see more


    Programming is like trying keep a wall of shifting sand up, you fix one thing but somewhere else starts crumbling

  5. #5
    Join Date
    Feb 2012
    Location
    DON'T PM ME ASKING FOR STUFF
    Posts
    2,170
    Mentioned
    38 Post(s)
    Quoted
    423 Post(s)

  6. #6
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default

    Quote Originally Posted by xtrapsp View Post
    Will keep adding to it ^^
    Liked it, we could have a basic programming course here > Keep it up!

  7. #7
    Join Date
    Dec 2010
    Posts
    89
    Mentioned
    4 Post(s)
    Quoted
    8 Post(s)

    Default

    Hey xtrapsp!

    Great tutorial! Please keep adding more information! It's good stuff.

  8. #8
    Join Date
    Dec 2011
    Location
    Lubbock, Texas
    Posts
    225
    Mentioned
    3 Post(s)
    Quoted
    93 Post(s)

    Default

    Good start. I would also like to see more OOP!
    Previously known as grahambr*SigPic compliments of Clarity
    Spartan Scripts

    Scripts: AutoPlankMake **** AIOEdgeSmelter

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •