best practise for scripting

44
© 2006 Oracle Corporation – Proprietary and Confidential

Upload: jeevananthamg

Post on 02-Apr-2015

235 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Page 2: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

<Insert Picture Here>

Agenda

• The Problem• Possible Solutions• Design Time Decisions• Declarative Alternatives• Optimization Techniques• Release 7.8 and 8.0 Enhancements• Question and Answer

Page 3: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

• Siebel CRM internal benchmarks show that, depending on the Release, an application with a moderate amount of script can be affected as follows:

CPU Utilization 80% increase

Memory Utilization 19% increase

Response Time 65% decrease

Scripting Cost to Performance

• There is a strong correlation between the probability of one of our customers being in a “red” status and the amount of script in that customer’s repository.

Page 4: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

<Insert Picture Here>

Agenda

• The Problem• Possible Solutions• Design Time Decisions• Declarative Alternatives• Optimization Techniques• Release 7.8 and 8.0 Enhancements• Question and Answer

Page 5: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Possible Solutions

• In view of the performance cost of script, there are three possible courses of action that we can take:• Envision and Define to avoid script• Use declarative alternatives instead of script• Use performance friendly techniques in

script

Page 6: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

<Insert Picture Here>

Agenda

• The Problem• Possible Solutions• Design Time Decisions• Declarative Alternatives• Optimization Techniques• Release 7.8 and 8.0 Enhancements• Question and Answer

Page 7: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Cut Script at Design Time or Before

• Include a knowledgeable Siebel technical resource in the early stages (planning, scope, design phases) of the project methodology.• Employees of your Organization who understand the standard

application.

• Many times the application design stage is seen as only being between business owners and business analysts.

• Myth: Developers are paid by the number of lines of code they write.

Page 8: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

<Insert Picture Here>

Agenda

• The Problem• Possible Solutions• Design Time Decisions• Declarative Alternatives• Optimization Techniques• Release 7.8 and 8.0 Enhancements• Question and Answer

Page 9: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Replace Script with Declarative Alternatives

• For many functional requirements there is a configuration technique available that requires no script.

• Knowing these configuration techniques, one can make better decisions about whether to write script in the first place.

Page 10: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Example: Field Data Validation

Requirement: Field Validation

if (fieldname == “Activation Date”){ if(this.GetFieldValue(“Expiration Date”) != “”) { if(this.GetFieldValue(“Activation Date”) >

this.GetFieldValue(“Expiration Date”)) { throw(“Activation Date must be less than Expiration Date, if

Expiration Date has been filled in”); } }}

Page 11: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Configuration Alternative

Solution: use BC Field Validation Property

Page 12: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Configuration Alternative

• Additional properties introduced in Release 8.0• Validation Message with Symbolic String support

• Message Display Mode

Page 13: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Example: Setting Field Values Based on Field Changes

‘SetFieldValue eventif (fieldname == “Product Serialized Flag”){ if(this.GetFieldValue(“Serial Number”) == “” && this.GetFieldValue(“Product Serialized Flag”) == ‘Y’) { this.SetFieldValue(“Serial Number”, this.GetFieldValue(“Asset

Number”)); }}

Page 14: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Configuration Alternative

• On Field Update Set User Property

Page 15: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Example: Responding to Write Events

function BusComp_WriteRecord()

{

if(this.GetFieldValue(“Account Status”) == “Followup”)

{

var bc = TheApplication().GetBusObject(“Action”).GetBusComp(“Action”);

bc.NewRecord(NewAfter);

bc.SetFieldValue(“Description”, “Account Followup”);

bc.SetFieldValue(“Due”, Today());

bc.WriteRecord();

}

}

Page 16: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Configuration Alternative

• Runtime Events• Bigger complement of events than available in script

Page 17: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Example: PreCanInvokeMethod

function Applet_PreCanInvokeMethod(MethodName,&CanInvoke){ if(MethodName == “Submit”) { CanInvoke = “TRUE”; return(CancelOperation); }}

Page 18: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Configuration Alternative

• Applet Named Method User Property

• New in Release 8, CanInvokeMethod User Property

Page 19: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Other Configuration Alternatives - Profile Attributes

• Dynamic versus Static Profile Attributes• Ex: ActiveViewName

• Static Profile Attributes based on Personalization Profile BC• GetProfileAttr

• Is Employee• GetProfileAttrAsList

• Ex: GetProfileAttrAsList(“User Responsibilities”)

Where can they be used to avoid code?• Search Specification (BC and Applets) • Calculated fields to be referenced in User Properties• Personalization• Pre Default Value and Post Default Values

Page 20: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Other Configuration Alternatives

Functions in Calculated Expressions• LoginName, PostionId, etc

User Properties• Required• Named Method to invoke a Bus Service• Configuring Data-Driven Read-Only Behavior

Page 21: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Other Siebel Alternatives to Script

• State Model

Page 22: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Other Siebel Alternatives to Script

• Audit Trail

Page 23: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

<Insert Picture Here>

Agenda

• The Problem• Possible Solutions• Design Time Decisions• Declarative Alternatives• Optimization Techniques• Release 7.8 and 8.0 Enhancements• Question and Answer

Page 24: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

The First Rule of Script Optimization

The Fastest Script You’ll Ever Write…

is the Script that You Never Write

Page 25: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

The Keys to Optimization – Choices

• There is no silver bullet for scripting performance

• Improving performance is about making many small choices over time. It is about discipline and making the right small choices over and over again.

• Generally, the earlier in the implementation methodology we start thinking about the impact of scripting on performance the better.

“There are always two choices. Two paths to take. One is easy. And its only reward is that it is easy”- Anonymous

Page 26: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Do Not Script The BusComp_PreGetFieldValue Event

• The BusComp_PreGetFieldValue event is for every field that is retrieved in a SQL SELECT statement, so it is fired very, very frequently.

• Any script in this event causes a severe penalty in performance.

• Siebel CRM has numerous cases of customers with severe performance problems that have been tracked down almost exclusively to the use of this one event.

• In Release 2000, there were a few legitimate uses for this event. In Release 7, we have yet to see a necessity for using the event.

Page 27: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Frequently Fired Events

• Other events that fire frequently are:• ChangeRecord• ShowControl

• PreCanInvokeMethod

• Use care when scripting these events.

Page 28: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Minimize Browser to Server Roundtrips

• Performance Key: Minimize Server Roundtrips• In BrowserScript, these are caused by:

• Referencing Profile Attributes• Calling Server-Side Business Services• Using the “Immediate Post Changes” field property

Page 29: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Algorithmic Improvements

• No Need to Query Child Business Components In Loops

bcOrder.ExecuteQuery( ForwardOnly ); if ( bcOrder.FirstRecord() ) { do {

bcOrderLineItems.ExecuteQuery(ForwardOnly);

… } while ( bcOrder.NextRecord() ); }

Page 30: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Use Indexed Columns For Searching

• Script should use indexed columns in its search and sort specifications.

• Failure to use indexed columns in search and sort specifications leads to queries that use temporary tables or produce sequential table scans. Both of these are detrimental to performance.

Example:

bc.SetSearchSpec(Name, theName);

bc.SetSearchSpec(CustomField, theField);

bc.SetSearchSpec(SomethingElse, theElse);

Page 31: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Use The Correct Cursor Mode

• For the ExecuteQuery() method, use the ForwardOnly cursor mode wherever possible.• Improves performance• Can only traverse forward from first to last record• Does not create a buffer to hold records when they have been scrolled

past. (Memory Savings)• Does not have to keep a linked list up to date when scrolling through

record set. (CPU savings)

• Unless ForwardBackward is required• Moves in both directions• Required to show records in applet• Using DB2 UDB for z/OS and OS/390 (Siebel Tech Note 592)

Page 32: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Field Activation

• Setting field property ‘Force Active’ to True unnecessarily causes performance issues in both configuration and script.

• Especially true for Joined and Multi-valued fields.

• A business component field is “Active” when:

• It is exposed and visible on the currently displayed applet.• Field's Link Specification property is set to TRUE• Field's Force Active property is set to TRUE• Business component's Force Active property is set to TRUE

Page 33: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Remove Debugging Code

• Debugging code should be removed before going into production

• This does not apply to TheApplication().Trace() TheApplication().Trace() statements may be left in the code in production as long as TraceOn() is removed or commented out.

Page 34: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Avoid Run-time Business Services in Production

• Run-time Business Services do not perform well• They are not pre-compiled to intermediate code• They must be interpreted from scratch on execution• They are great for prototyping• They are terrible in Production• Also, they are not very amenable to source code control

Page 35: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

<Insert Picture Here>

Agenda

• The Problem• Possible Solutions• Design Time Decisions• Declarative Alternatives• Optimization Techniques• Release 7.8 and 8.0 Enhancements• Question and Answer

Page 36: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Siebel Scripting Features Timeline

• Siebel CRM Release 6 and prior: • Support for SVB and eScript

• Release 7.x: • BrowserScript and ServerScript

• Release 7.7.2.3 and 7.8: • Introduction of the ST eScript Engine

• Release 8.0: • Enhancements to the ST eScript Engine

• Enhancements in Tools Configuration to assist and reduce scripting

Page 37: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

How to Turn on the New Script Engine

• Tools and client cfg files[Siebel]

RepositoryFile = siebel_sia.srf

ApplicationName = Siebel Tools

ApplicationTitle = Siebel Tools

ApplicationSplashText = Siebel Tools

Vertical = sia

ComponentName = Siebel Tools Client

DataSource = Local

EnableCLIScripting = TRUE

Page 38: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

7.8 Scripting Highlights

• Improved Performance – Higher throughput with a lower CPU and memory footprint in cases where customers have implemented a significant amount of script.

• Improved Scalability – Lower footprint per user for CPU and memory use.

• New Functionality – Added support for ECMAScript Edition 4 compliant strong typing. Using strongly typed objects will get both better functional scripts and performance.

Page 39: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Preliminary Performance/Scalability results

CPU reduction• 18-20% reduction in CPU usage per user in heavily OM dependent

script scenarios (100 connected users)• 25-35% reduction in CPU usage per user in low OM dependent script

scenarios (100 connected users)

Memory footprint reduction• 20-30% memory footprint reduction per user (100 connected users)

Page 40: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Another 7.8 Performance Enhancement

• Introducing the CountRecords method• This new method can be used in place of any current code that loops

through recordsets to determine the number of records.

Page 41: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Late and Early Binding Class Support

• Late Binding:var a = new Date ();

a.toString();

Binding will happen at runtime, since a is not strongly typed.

• Early Binding:var a : Date = new Date ();

a.toString();

Binding will happen at compile time.

Page 42: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

8.0 Scripting Highlights Enhancements to the ST eScript Engine

• Repository Based Script Assist

• Script Libraries• Can call business service functions directly after declaring a

business service. No need to declare property sets and make an InvokeMethod call.

• Modular, reusable, upgradeable components can now be written.• Use is optional: All code written prior to 8.x is still supported

• Script Assist Favorites

• Fix and Go

Page 43: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

Enhancements in Tools Configuration to Assist and Reduce Scripting

Script Editor Syntax Highlighting • VB and eScript support

Debug Window Global support • VB and eScript support

Enabling buttons declaratively • Most applet class support

Customizable messages for Field Validation property

Page 44: Best Practise for Scripting

© 2006 Oracle Corporation – Proprietary and Confidential

The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions.The development, release, and timing of any features or functionality described for Oracle’s products remain at the sole discretion of Oracle.