您的位置:首页 > 移动开发 > Objective-C

两种DP描述方法的比较

2010-01-01 12:20 381 查看
使用
DP

Descriptive Programming
)时,可以使用两种方法,一种是直接描述的办法,另外一种是使用
Description
对象来存储描述:

 

Method
1 – Using String Description


Browser("Browser").Page("Google").WebButton("type:=Submit",
_

       

"name:=Google Search", "html tag:=INPUT").Click

 

Method
2 – Using Object Description


Set oGoogleSearch = Descrition.Create

oGoogleSearch("type").Value =
"Submit"

oGoogleSearch("name").Value =
"Google Search"

oGoogleSearch("html tag").Value =
"INPUT"

Browser("Browser").Page("Google").WebButton(oGoogleSearch).Click

 

 

 

这里做了个对比:

String Description


Object Description


Uses less memory as strings are
used
(因为使用字符串描述,内存用得少些)

Requires more memory as objects
are created. Object creation is as such a overhead
(由于使用了对象,需占用较多内存)

Increases statement length in
case more than one property is to be used
(如果要描述多个属性,则语句长度会增加)

Increase lines of code due to
object creation overhead and property assignment
(增加的不是语句长度,而是代码行数)

 

Preferred when property value
have regular expression characters which needs to be treated literally
(如果属性描述中包含正则表达式,则采用这种方法更好)

 

参考:

http://knowledgeinbox.com/articles/qtp/descriptive-programming/dp-part-2-converting-or-based-scripts-to-dp/

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息