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.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Jack1590
Reel Rookie

Builder pattern in brightscript

Hi

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
1 REPLY 1
atc98092
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. 🙂

Dan

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
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.