OOP vs Procedural

There are some very real reasons to do object oriented programming the way it’s intended, in class files. Things like public and private have very real meanings, and when used properly they make your life a whole lot easier - especially when working with multiple developers or sharing classes between multiple projects.

It’s hard to understand the power of OOP until you’ve spent some good time using it, and seeing how much time it saves you over the course of a few projects.

[quote=Anogar;2340517]There are some very real reasons to do object oriented programming the way it’s intended, in class files. Things like public and private have very real meanings, and when used properly they make your life a whole lot easier - especially when working with multiple developers or sharing classes between multiple projects.

It’s hard to understand the power of OOP until you’ve spent some good time using it, and seeing how much time it saves you over the course of a few projects.[/quote]

Yeah, that’s another thing that the Java developers I work with tell me…OOP makes working on large team projects immensely easier. Especially if all the developers are working on different, but related chunks of code.

It’s also very helpful when you want to reuse a class between projects. The whole thing is really more about ways to make your projects easier over the long run.

I do every Flash project solely with AS3 (I don’t even own CS3, wtf right) so without OOP it would be freaking redic. One of the cool things about AS3 is helper classes. It allows you to fully utilize OOP but without having to create a billion different classes which you’ll never ever use again in a million years.

Take this for example:

package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import jm.geom.Point3D;
	public class ShiftingNodeNetwork extends Sprite {
		private var nodes:Array = new Array();
		private var maxDistance:Number;
		public var axisRotations:Object = new Object();
		public function ShiftingNodeNetwork(width:Number, height:Number, depth:Number, distance:Number, ease:Number, numNodes:Number) {}
		public function start():void {}
		public function stop():void {}		
		private function connect(evt:Event):void {}
	}
}

import flash.display.Shape;
import flash.events.Event;
import jm.geom.Point3D;
import jm.math.Random;
class RandomNode extends Shape {
	private var coord:Point3D;
	private var targCoord:Point3D;
	private var ease:Number;
	private var wc:Number;
	private var hc:Number;
	private var dc:Number;
	public function RandomNode(w:Number, h:Number, d:Number, e:Number) {}
	private function move(evt:Event):void {}
	public function get location():Point3D {}
	public function start(evt:NodeEvent):void {}
	public function stop(evt:NodeEvent):void {}
}

That’s just a snippet from one of my experiments with mose of the code removed for clarity. I used the RandomNode as a helper because when would I ever need that class again? Now the classes in there that I do use between multiple projects (like NodeEvent, Point3D) have there own class file so I can import them for another project.

After a while you can start making your own library, organized into packages, that you can access from any file. Saves you from having to search through multiple timelines of code to find what you’re looking for.