You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think the only time where I would consider it a mandatory requirement to have a class is for input validation where you need a specific type of object with a specific set of properties. I would also include a constructor that can take any PsCustomObject provided it has the right properties (and would otherwise throw an error), as well as one that simply takes all necessary properties as input.
As for combining objects, I believe Join-Object is capable of this regardless. If you wanted this join to result in a different class, you could do the join in a constructor.
Activity
OCram85 commentedon Nov 23, 2017
This post from @Xainey really helped me understanding classes and develop an own style.
But I always struggle about things like this:
So maybe it's worth thinking about a style guid for the syntax and a best practice for the usage itself?
vexx32 commentedon Apr 20, 2018
I think the only time where I would consider it a mandatory requirement to have a class is for input validation where you need a specific type of object with a specific set of properties. I would also include a constructor that can take any PsCustomObject provided it has the right properties (and would otherwise throw an error), as well as one that simply takes all necessary properties as input.
As for combining objects, I believe
Join-Objectis capable of this regardless. If you wanted this join to result in a different class, you could do the join in a constructor.