View Single Post
Join Date: May 2006
Posts: 1,582
Reputation: Infarction has a spectacular aura about Infarction has a spectacular aura about Infarction has a spectacular aura about 
Solved Threads: 52
Infarction's Avatar
Infarction Infarction is offline Offline
Battle Programmer

Re: Object Oriented Programming

 
0
  #4
Jan 22nd, 2007
Originally Posted by indienick View Post
There are two branches of programming: functional, and object-oriented. Functional languages leave the entire language at your disposal without having to import other "classes". The problem that arises with functional languages, is that you end up re-typing out code again and again. For instance, let's say you're creating a program that requires networking protocols like TCP/IP and HTTP. So, you spend the time writing the program, and it works perfectly. Now, you go to write another program, some time later, and you require the TCP/IP and HTTP protocols this time. You are going to find yourself re-typing or copy-and-pasting the code from the old program - this can prove to be time consuming, and perhaps even cause big errors in the code.
That's why we have libraries...

Now, with Object Oriented Programming approaches code importing a little differently. In Java, let's say, you have the option to just use the standard code base, which can keep small programs neat and tidy. But for larger applications, it starts turning into a functional approach to things - and not to mention, some things in Java just aren't possible without importing some classes. Object-Oriented Languages make use of "objects", "classes", "inheritance"...things like that. A class is an object definition, and an object is a creatable/destroyable instance of a class - it's a roundabout definition, but it's the best I can do for the moment. Inheritance allows other classes to keep their inherent functions (or, as Java-heads call them, "methods"), and expand on the number of methods available to the user through that one class.
Or... not. You've sort of described how the language works, but not really touched on why that's important. Object oriented languages (e.g. Java, Smalltalk) provide a way of modeling an environment as a set of objects and methods detailing how the objects interact. There are also ways of representing an objects relation to another (e.g. the stuff about inheritance). As the project grows, the code should not become more functional; it might use many methods, but that's not the same as being functional. Procedural programming (e.g. C), allows you to define a set of procedures (or functions) and run them in a specific order. Some people might make the argument that OOP style is possible in C, but it's messy. Functional programming langauges (e.g. Lisp, Haskell) usually have very terse solutions to problems, but as they usually are non-imperative (i.e. lack side effects such as variable state), they aren't very popular for programs that have to retain state.

For more on this, Wikipedia is always a good reference, and if you would like to get into Object-Oriented Programming, Java would be a good place to start - it teaches you what you need to know about OOP, and without the complexities of operator overloading and pre-processor calls inherent in C++.
Complexities of operator overloading and pre-processor calls? :lol:

You might also consider Python, Ruby, or Smalltalk if you're wanting to try an OO language. Java is widely used, but it's certainly not the flagship language for the OO paradigm...
Reply With Quote