Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Level 7

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
Level 21

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. Smiley Happy

Dan
Roku Stick (3600), Ultra (4640), Ultra (4670), Ultra (4800), Premiere (3920), Insignia 720p Roku TV, Sharp 4K Roku TV, Nvidia Shield, Windows 10 Pro x64 running Serviio and Plex on a wired Gigabit network.
0 Kudos