Tuesday, December 28, 2010

Application Classes in Peoplesoft - Reference sheet

Application Classes in Peoplesoft – Reference sheet / Points remember



Importing packages or classes
::<…>:



Class Extensions represents the “is-a” relationship.
When a class extends another class, it’s called a subclass of that class.



No Multiple inheritances or Concept of interface in Application classes.


Instance variables in the class are accessible in all the objects of that class.


Application programs generally pass parameters by value, which is not the same as for existing functions.


Parameter passing with object data types is by reference.


When the objects are passed to method and it reassign the object with new object it will not reflected in the calling method.


Application Programs use the out specifier to pass a parameter by reference.
Method increment (&Value as number out); rem passed by reference.



Create is the key word used to create the class object.
Local MyObjectClass &o1 = Create MyobjectClass (‘A’);

Local MyObjectClass &o1 = Create Test: Examples: MyobjectClass (‘A’);



If parameter in a method is having out specifier then parameter should be a variable and cannot be constant.


A class that extends another class must have constructor, and in the constructor it must initialize its super class.
To initialize a superobject, an instance of the superclass is assigned to the keyword %Super in the constructor for the subclass.



Class Example extends ExampleBase

Method Example ();

End-class;



Method Example

%Super = create ExampleBase ();

&BaseStrin = ¤tBaseString;

&Slashstring = &BaseString;

End-Method;



Before the constructor runs, the instance variables for the class are set by default takes on their declared types.


An application class doesn’t have destructors, that is, a method called just before an object is destroyed. The People code runtime environment generally cleans up any held resources.


When application class properties and instance variables are used as the argument to functions or methods, they are always passed by value, never by reference.


%This is can be used to self reference. This is to refer the same object.


%Super = %This – this should never be done it will go to an infinite loop.


Import Fruit:* - imports all the classes in the application package.


Import statements are validated when you save the Peoplecode.


Peoplesoft recommends that you use read-write or ready only properties instead of creating methods name GetXxx and SetXxx.


Getter and Setter syntax
Get Propertyname

---

End-get;



External Functions Declarations are allowed in application classes, in the global and component variable declarations, after the class declaration (after the end-class) and before the method definition.


%Super is only required to access superclass members that are hidden by overriding members in the current time.


Downcasting is the process of determining if an object is of a particular subclass type. If the object has that subtype (either the object is of that subtype, or is a subtype of it), a reference to the subject is returned, otherwise Null is returned. In either case, the type of the resulting value is compatible with the name subclass type.


Class Fruit
Property number fruitcount;

End-class;



Class Banana extends Fruit

Property number BananaCount;

End-Class;



Local Banana &MyBanana = Create Banana ();

Local Fruit &MyFruit = &MyBanana; /* Okay, Banana is a subtype of Fruit */

Local number &num = & MyBanana.BananaCount;



&MyBanana = &MyFruit as Banana; /* &MyFruit is currently a Banana at runtime */

&Num = (&MyFruit as Banana).BananaCount; /* same as &MyBanana.BananaCount */

&MyFruit = Create Fruit ();

&MyBanana = &MyFruit as Banana; /* Assigns Null - &Myfruit isn’t a Banana */



/* */ and /** */ comments are allowed. Comments enclosed in /** -- */ are potentially be used to generate API documentation.


Method header comments are uses some tags which helps in API documentation
Some of the tags are

· @Parameter N

· @exception name

· @return type

Class header comments contains tags

· @version X (value of version)

· @author name



Example



/**

* Class header comments

* @Version 1.0

* @author Ganesh

*/



Import PWWPack: ExampleBase



Class Example extends ExampleBase

Method Example (); /*Constructor*/

Method NumToStr (&Num As number) Returns string ();

Method AppendSlash ();

Property number SlashCount get; /*Get properties */

Property number ImportantDayofWeek get set; /*Get and set properties */

Property string Slashstring readonly; /* values can be assigned in constructor */

Property date ImporantDate;

Private

Method NextDayofWeek (&Dow As number) returns date;

Constant &Sunday = 1; /*Constants */

Instance string &Basestring; /* Instance variables are like static variable */

End-class;



Declare function getusername Peoplecode FUNCLIB_PP.STRING_FUNCTIONS FieldFormula;



/**

* Method header comments example

* @param Dow is a number parameter

* @exception it throws Invalid day exception if the number is negative.

* @return it is returns the date as of that week.

*/

Method NextDayofWeek (&Dow)

---------

---------

End-method;



/* get block */



Get SlashCount

Return (Slashcount);

End-get;

1 comment:

  1. "Great blog created by you. I read your blog, its best and useful information. You have done a great work. Super blogging and keep it up.php jobs in hyderabad.
    "

    ReplyDelete