Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Builder pattern in brightscript


i'm planing to create a library which received a config to enable or disable features. this config object has several fields so I wonder if it is useful to have a builder pattern as scenegraph objects have default values for its fields maybe it's not needed to have a builder

for instance 

Builder Implementation

configBuilder = createObject("roSGNode", "ConfigBuilder")
configBuilder.callFunc("withAppId", "rew4324123")
configBuilder.callFunc("withAds", true)

config = configBuilder.callFunc("build")

myLib = createObject("roSGNode", "MyLib")
myLib.callFunc("start", config)

Plain Object Implementation

config = createObject("roSGNode", "Config")
config.appId = "rew4324123"
config.adsEnabled = true

myLib = createObject("roSGNode", "MyLib")
myLib.callFunc("start", config)


Which approach do you think it's better for br?

0 Kudos
Community Streaming Expert

Re: Builder pattern in brightscript

You need to post this on the developer's side of the forum. This area is for end users, and very few people here will have any idea what you're talking about. 🙂


Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee, just another user.
0 Kudos