MarimerLLC / cslaforum

Discussion forum for CSLA .NET
https://cslanet.com
Other
31 stars 6 forks source link

Inheriting a Parent #451

Open CrossSlide opened 7 years ago

CrossSlide commented 7 years ago

My OOP knowledge is a little weak. I have a Parent read-only object that has several child objects I’ll call it MyBaseObj. I want to create a new class (MyNewObj) that inherits MyBaseObj. I need to be able to bind to most of the MyBaseObj’s properties but MyNewObj needs to combine, transform, or hide other properties.

What’s the best way to go about this?

It’s a WPF application, thanks!

Chicagoan2016 commented 6 years ago

@CrossSlide , did you get a chance to download Visual Studio item templates for CSLA? I would use ReadonlyList template for my parent object and 'ReadonlyChild' for child objects.

jonnybee commented 6 years ago

The easiest way to do achive inheritance is to create a generic base class with the common properties, f.ex: MyBase with an interface definition for the common properties/methods. This will make it easier to create MyObj1 and MyObj2 types that inherit from the base class.

You cannot "hide" properties/methods from the parent object (altho' you can use the new keyword to provide another implementation but it is not considered best practice).

CrossSlide commented 6 years ago

Thanks @Chicagoan2016, @jonnybee. I'm thinking instead of a new class I may be better off handling my needs in a separate View, ViewModels.

Chicagoan2016 commented 6 years ago

@CrossSlide , if you end up using one of the MVVM frameworks like MvvmLight , Prism etc. please share your experience with us.

Regards