vb.net - Pass-through methods vs. accessing nested objects directly -



vb.net - Pass-through methods vs. accessing nested objects directly -

what have object contains list of objects each contain list of objects have properties , such.

currently utilize pass-through methods able add together nested objects, in extremely simplified example:

public class clsa private objb list(of clsb) = new list(of clsb) public sub new() objb.add(new clsb) end sub public sub addint(byval bindex int32, byval cindex int32, byval number int32) objb(bindex).addint(cindex, number) end sub end class public class clsb private objc list(of clsc) = new list(of clsc) public sub new() objc.add(new clsc) end sub public sub addint(byval cindex int32, byval number int32) objc(cindex).addint(number) end sub end class public class clsc private lstnum list(of int32) = new list(of int32) public sub addint(byval number int32) lstnum.add(number) end sub end class

it seems proper coding standards tell me right compared to:

public class clsd public obje list(of clse) = new list(of clse) public sub new() obje.add(new clse) end sub end class public class clse public objf list(of clsf) = new list(of clsf) public sub new() objf.add(new clsf) end sub end class public class clsf public lstnum list(of int32) = new list(of int32) end class

are there instances either method acceptable? or pass-through setup preferred?

public class form1 dim oa clsa = new clsa dim od clsd = new clsd private sub button1_click(sender object, e eventargs) handles button1.click oa.addint(0, 0, 3) od.obje(0).objf(0).lstnum.add(3) end sub end class

think how it's done throughout .net framework. collection should assigned private field , exposed via public read-only property.

public class thing private _stuff new list(of thing) public readonly property stuff() list(of thing) homecoming _stuff end end property end class

the caller can access collection straight phone call add method, etc, cannot assign whole new collection. there examples everywhere: control.controls, listbox.items, combobox.items, listview.items, dataset.tables, dataset.relations, datatable.rows, datatable.columns, etc, etc, etc.

vb.net coding-style standards

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -