A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More.
search
AI OnAI Off
Hello all,
I'm interested in your opinions on this one, because Relate+ is implemented one way, and in the documentation (Developers handbook, by Netstar) recommends extending your objects (Blog, User, Image etc.) with new, inherited objects, for use in your project. Today Relate+ is using a lot of extension methods that are great for some uses, but I'm not convinced it is the best way to go about when you are using Attributes on a user.
So, what are your experiences and advice?
Examples:
Today the way of getting a users attribute for Region is implemented with an extension method
public static string GetRegion(this IUser user) { string s = user.GetAttributeValue("Region"); if (string.IsNullOrEmpty(s)) { return string.Empty; } return s == "-1" ? string.Empty : s; }But would it not be more correct to utilize inheritance and good OO practice to har your own User object that implements those methods as Properties like this?
public class CustomUser : EPiServer.Common.Security.User { public string JobTitle { get { string s = this.GetAttributeValue("Jobtitle"); if (string.IsNullOrEmpty(s) || s == "-1") return string.Empty; return s; } set { this.SetAttributeValue("JobTitle", value); } } }and then use
and be happier?
Go debate! :)