• Call us: +977-980 116102

OOP

Object-oriented programming (OOP) is a style of programming that focuses on using objects to design and build applications. Think of an object as a model of the concepts, processes, or things in the real world that are meaningful to your application.  These objects would work together (and with many other objects) to provide the functionality that you want your project management application to have.
 
ActionScript 3 is an object-oriented language. Almost everything you will need to build an application using ActionScript 3 is an object—Sprite, MovieClip, TextField, Array, and the like. Understanding objects and knowing how to work with them is key to developing any application using ActionScript 3. This article is the first of many that will focus on object-oriented programming concepts within ActionScript 3. In it, you will learn what an object is, what a class is, how to instantiate an object, and how to work with objects using dot notation.

Object-Oriented Programming (OOP) is a type of programming added to php5 that makes building complex, modular and reusable web applications that much easier.
The two main important part of OOP are:
i) Class
ii) Object
These are the important parts for writing the OOP programs.

i>Class:

A class is the blueprint of an object. A class is simply a representation of a type of object. You can think of a class as a template for making many instances of the same kind (or class) of the object.
The class is composed of normally three things:
a)A name
b)attributes
c)methods

ii>Objects:

Objects are the instance of a class. An individual instance of the data structure defined by a class. Object is that thing that can perform a related activity.

Examples of Class and Objects:

1.Creating Class
<?php

class CalculateSum{ // Creating Class

//defining member properties
public $sum = 0.5;

//method
public function calculate($a,$b){
//Accessing properties inside the class
//$this-> yo class vitra ko
$this->sum = $a + $b ;
}

}

?>
2.Object in PHP
<?php

require ‘Calculate.php’;

//Declaring an object for class Calculate
$obj = new Calculate();

//accessing method through outside class
$obj->sum(20,30);
//accessing properties through outside class
echo ‘the sum is ‘.$obj->result.'<br>’;
?>

Objects

In programming terms, an object is a self-contained component that contains properties and methods needed to make a certain type of data useful. An object’s properties are what it knows and its methods are what it can do. The project management application mentioned above had a status object, a cost object, and a client object, among others. One property of the status object would be the current status of the project. The status object would have a method that could update that status. The client object’s properties would include all of the important details about the client and its methods would be able to change them. The cost object would have methods necessary to calculate the project’s cost based on hours worked, hourly rate, materials cost, and fees.
 
 For particular operations to be standardized across different types of objects. You will learn more about these important capabilities in Object-oriented concepts: Encapsulation.
 
Objects are the fundamental building blocks of applications from an object-oriented perspective. You will use many objects of many different types in any application you develop. Each different type of object comes from a specific class of that type.

Classes, instances, and instantiation

class is a blueprint or template or set of instructions to build a specific type of object. Every object is built from a class. Each class should be designed and programmed to accomplish one, and only one, thing. (You’ll learn more about the Single Responsibility Principle in Object-oriented programming concepts: Writing classes.) 
 
Think about classes, instances, and instantiation like baking a cake. A class is like a recipe for chocolate cake. The recipe itself is not a cake.  That edible cake is an instance of the chocolate cake class.
 
Author
Yashu Sthapit

it's me...........

Post a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.