Language: 
To browser these website, it's necessary to store cookies on your computer.
The cookies contain no personal information, they are required for program control.
  the storage of cookies while browsing this website, on Login and Register.

User

Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Select language:

Community



Stats

  • *Total Members: 4391
  • *Latest: birmanto

  • *Total Posts: 16125
  • *Total Topics: 2451
  • *Online Today: 7
  • *Most Online: 157
(27.08.09, 03:54:53)
  • *Users: 0
  • *Guests: 2
  • *Total: 2

Author Topic: [WIP] PMx coding technique - Part I (basics)  (Read 4860 times)

0 Members and 0 Guests are viewing this topic.

Offline feline

  • CO PortaMx corp.
  • Administrator
  • *
  • Posts: 5688
  • Gender: Female
[WIP] PMx coding technique - Part I (basics)
« on: 24.03.10, 05:52:39 »
Todays we start our PMx coding technique with the part I (OOP basics).
More informations about OO Programming you can find at Wikipedia or other sites (also PHP).

Comparison with procedural programming and object-oriented programming
The focus of procedural programming is to break down a programming task into a collection of variables, data structures, and subroutines, whereas in object-oriented programming it is to break down a programming task into objects with each "object" encapsulating its own data and methods (subroutines). The most important distinction is whereas procedural programming uses procedures to operate on data structures, object-oriented programming bundles the two together so an "object" operates on its "own" data structure.

Nomenclature varies between the two, although they have much the same semantics:
object-oriented   procedural
method   function
object   module
message   function call
attribute   variable

Fundamental concepts and features
Class
A class defines the abstract characteristics of a thing (object), including the thing's characteristics (its attributes or properties) and the thing's behaviors (the things it can do, or methods, operations or features). One might say that a class is a blueprint or factory that describes the nature of something. For example, the class Dog  would consist of traits shared by all dogs, such as breed and fur color (characteristics), and the ability to bark and sit (behaviors). Classes provide modularity and structure  in an object-oriented computer program.

Object
A pattern (exemplar) of a class. The class Dog defines all possible dogs by listing the characteristics and behaviors they can have; the object Lassie is one particular dog, with particular versions of the characteristics. A Dog has fur; Lassie  has brown-and-white fur.

Instance
One can have an instance of a class; the instance is the actual object created at runtime. In programmer jargon, the Lassie object is an instance of the Dog class. The set of values of the attributes of a particular object is called its state. The object consists of state and the behavior that's defined in the object's class.

Method
An object's abilities. In language, methods (sometimes referred to as "functions") are verbs. Lassie, being a Dog, has the ability to bark. So bark() is one of Lassie's methods. She may have other methods as well, for example sit()  or eat() or walk() or save(timmy). Within the program, using a method usually affects only one particular object; all Dogs can bark, but you need only one particular dog to do the barking.

Inheritance
"Subclasses" are more specialized versions of a class, which inherit  attributes and behaviors from their parent classes, and can introduce their own. For example, the class Dog might have sub-classes called Collie, Chihuahua, and GoldenRetriever. In this case, Lassie would be an instance of the Collie subclass. Suppose the Dog class defines a method called bark() and a property called furColor. Each of its sub-classes (Collie, Chihuahua, and GoldenRetriever) will inherit these members, meaning that the programmer only needs to write the code for them once.

Abstraction
Abstraction is simplifying complex reality by modeling classes appropriate to the problem, and working at the most appropriate level of inheritance for a given aspect of the problem. For example, Lassie the Dog may be treated as a Dog much of the time, a Collie when necessary to access Collie-specific attributes or behaviors, and as an Animal (perhaps the parent class of Dog) when counting Timmy's pets.

To be continued ...

Fel
Many are stubborn in relation to the path, a few in relation to the target.