Forum lessons?

Perhaps we should make a certain subject on here to touch on and maybe we could have an in-depth look at it and learn everything about it.

I don't know what subject would be good to touch on though, how can we start this? I thought it couldn't hurt to post something every week and have discussions on it for the purpose of education?

Maybe we could start on TCP/IP and just go with the basics, then get more in depth as the discussion goes?

explain the 3-way handshake

The TCP state-transition diagram can be somewhat intimidating, because it has to take into account many obscure scenarios, such as links breaking down in the middle of opening a connection. Here we show the normal process of opening a connection, called the three-way handshake.

sorry i dont have anything to add as far as knowledge goes but i think that this is a great idea.
hope we can end up doing it.

" The TCP state-transition diagram can be somewhat intimidating"

The red-x is always intimidating!!

damn the red x!

Someone teach a network lesson, schedule a time. I'll do a .NET lesson, someone else can teach Java or something.

basic Java. I'm rusty, I haven't used Java for a bit. been messing with C. may confuse the two, they are quite similar in some respects.

Java gurus, correct me if I fuck up.

the formatting is stupid for Java code, but mma.tv's text parser is stupid.

--

import org.blah.smackity.library;

public class ITForumBullshit {

public static void main(String[] args) {

//put comments into your code

/* another way to put comments in your stuff,
like blocks of info. All the information in here
is not interpreted by the program, just like with
the above comment "put comments into your code".
*/


//print stuff about Outkast

System.out.println("In the immortal words of Outkast, 6 minutes Dungeon Family!!!!! /n");

}

}


---

analysis.

1. import org.blah. - this is how you import classes into Java. this class importation works sort of like header files in C.

All classes in Java must have a different name.. since web names for an organization are unique, many Java libraries use them- for instance, org.blah.(all that other stuff) would be a class distributed by blah.org. The rest denotates what grouping of library the library is in and what it does.

the ; signals the end of a line of code. This is mandatory in all C-derived languages (C, C++, Objective-C, Java, C#)

you don't actually use anything from this library, so don't worry about it for now.


2. public - refers to access control.

Unlike C, which is based on functions, Java is totally based on object-orientation. Objects are conglomerations of data and functions (what C would call them)/methods (what Java calls them). Programming in Java without a knowledge of object orientation is pretty much hopeless if you want to do anything real, and while object orientation is not a ultra-tough concept, it's more than I can adequately explain well here. I'll try, but if you have questions do some outside reading.

anyway, classes are like the blueprints for objects. Just as a function definition is for a function in C. You create classes, then call the class to create an object ("instantiation" of a class = object). just like you use a typedef to define a data structure in C from primitive data types, only objects are mixed data and code, and they are one of the few times it's smart to mix the two. all data in Java is ultimately created from primitive types, just like in C, but objects are consider "data" as well and work as abstractions over the primitive data types underlying them.

Java uses basically the same primitive types as C, except it has a native String class like C++.. and because Java runs on a Java Virtual Machine (JVM), it uses the same values for it's primitive types everywhere... for instance, an integer (int) is always the same size, on any platform, unlike C.

also, Java isn't picky where you put the source code for objects unlike C and function definitions, as long as it's outside another classes's source (with the exception being inner classes, you'll learn about that later)... you can put it anywhere, but it's traditional to put them below the class containing the main() function.

an object "is a member of a" class. An object inherits from it's class, and any "superclasses" which are classes hierarchically above it's class and which the lower class (subclass) class is in part based on.

classes contain methods, which are basically the same as functions in C. not entirely true as you get to more advanced concepts, but close enough for now. They can also contain class variables, which can be used in any method within the class.

a public class is one that, when an object is created from it (inherits it), can be affected by an object or method from any other class, which can observe and modify. there are also "protected" classes and "private" classes. Protected classes can be used by the class containing it and any classes that inherit the class. Private classes cannot be observed or modified by any other member of any other class.. There are also "final" classes, which cannot be modified, although this is not primarily intended as access control and is different from the public-private part, it can be used as access control. You put the "final" after the public, etc. part.

and that's Java's fundamental access control. If Java didn't have, your code could be modified anywhere. Note that these controls can be overridden by malicious people in some cases, so don't count on it solely for your security.

3. class - explained above. In Java, EVERYTHING is part of a class, just as everything instantiated is therefore an object.. except for primitive types...

you cannot have functions/methods or variables outside of a class.

every class/object in Java inherits from the class/object Object.

4. ITForumBullshit - name of the class. you should pick a more expressive name in your programs, but this is just a bad example.

5. { denotes the beginning of a class body block, function body block, or an associated group of code.

ex. empty class body block- public class hello {

}

ex. empty function body block-

public int square(int tobesquared) {

}

ex. associated code block-

if (blah == false) {

blah = nozzing;

whut = blah + blah;

}

6. this starts a method.

public - you can also define functions/methods and variables as public, protected, or private. public methods can be used outside the class, private methods can only be used within the class, protected can only be used by the class and inheriting classes. A private class cannot have public methods, etc. (edit- Java geeks, am I correct on this, or wrong? I'm tired and don't want to crack open a book)

private variables can only be used in the method that declared them.. etc. you get the idea.

7. static - static is a little confusing, and different from static in C.

variables and methods can be static.

a static variable in a class is a single variable in memory shared by all methods in a class, in every object in or derived from that class (subclass).

a static method is a single method in memory that is shared by all instances of the class.

public static void main

8. void- unlike in C, where main() returns a integer value generally as a success or failure code, a Java program returns nothing in that manner. (void)

9. main( )- method where execution of a program begins and ends. very similar to main() in C. If you read main( ), you should have a good general idea of the execution flow of the program.

10. (String args[]) - equivalent to (int argc, char[] argv) in C.

you are telling the method to accept a String args[] as it's argument, it's input.

String is a built in object type. args[] is an single-dimensional array of String objects (which are basically just "strings" of letters, numbers, characters... only they are interpreted like the written word) containing the arguments passed to this program on the command line, since it is a command line program.

unlike C, you can declare an array like this - String[] args - or like this - String args[]. The first example is for "backwards compatability" with old C programmers. You should do it Java style, with the [] after args.

arrays are kind of like matrices in linear algebra... each can hold a value or a reference. Members of an arrays can hold references to another array, and so on, which is how you get multi dimensional arrays in Java.

you don't give the program any arguments, so it doesn't matter.

11. { - start of a method code block.

12. //put - this is a way of commenting something in Java. // means one line of text will be considered comments for the programmer and are ignored by the compiler.

13. /* another - this is a different way of commenting, used for large blocks of text as opposed to a single line usually, though that's not required, and it is the way it was originally done in C and ANSI C89... everything in the block is commented and ignored by the compiler.

14. */ - ends a block of commented information that is started with /*.

15. System.out.println() - the method println, from the class out, which a subclass of the superclass System, is being called to do something. System.out.println will print a String or numeric values given to it as a String to the screen. It will also print and move the screen cursor to a new line after execution.

16. "In the..../n" - you are giving System.out.println a String (anything enclosed in " " is a String) to print to the screen. It will print everything just as you typed it... except for the /n. the / is an escape character, and allows to embed formatting information into a String. The /n will not be printed. the /n tells the method to create a new line after it.. so you get two new lines after the message String is printed by System.out.println().

17. ; - end of line.

18. } - end of method body

19. }- end of class body.

this is gonna rock.. thanks guys

Java uses basically the same primitive types as C, except it has a native String class like C++Blasphemy! C++ has no native string. There's the string from the standard library but you still have to include it.a static variable in a class is a single variable in memory shared by all methods in a class, in every object in or derived from that class (subclass).a static method is a single method in memory that is shared by all instances of the class. Right. We have to emphasize, static methods and variables are not part of the object, they are part of the class. Every instance can reference them, but they do not need an instance of an object to exist. A good example is Math.random(). You get a random double from 0 to 1 by saying double foo = Math.random(). You don't need to create an instance of the Math class. Static methods can't access local instance variables, because they are not associated with any instance, only with the class as a whole. A good use for a static variable would be if you had a cow class and a bunch of cow objects, and you wanted to know which cow object shat the most today. Because that is information about the class, not the individual objects, it is a perfect use for static.

Andrew- you're right about C++, I was tired when I wrote all that.

still, anyone with any sense uses the template strings.

and, you're right, I needed to be a little more careful how I said that about static stuff.