If you know anything about programming, then you've probably heard of object oriented programming. It's the probably the accepted standard in commercial programming right now. Previously, the accepted standard was procedural programming.
What is Object oriented programming. Object oriented programming is a way to encourage groups of like code to be self-contained. Objects try to emulate real world things. For example, if you were writing a racing game, you would have a car object. This car object would be made up of methods and instance variables. An instance variables is data that you store that is important to the object. So a car might have instance variables for mileage, current speed, and fuel level.
Of course, during a game, this data will change. That is what a method does. Methods perform actions on data. So most of your code will be contained in methods, with each performing a specific action. For example, One method for the car object might be getCurrentSpeed(), which would retrieve the value of the object's current speed. Another method might be calculateFuelLevel(), which could take the speed and mileage to determine how much fuel was used and adjust the fuel level variable accordingly.
Objects are great because it forces programmers to have their code contained in one object from which other objects can access the information they need. This cuts down in duplicating code and makes it easier to maintain code. Objects are a good thing.
Friday, August 10, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment