LastExceed
06/11/2021, 8:25 AMUserProfile
class email
and about_me
are different types ? I know its overkill but i cant help itandylamax
06/11/2021, 8:29 AMdiesieben07
06/11/2021, 8:33 AMuserProfile.email.isValid
can certainly have value.LastExceed
06/11/2021, 8:35 AMCLOVIS
06/11/2021, 8:38 AMandylamax
06/11/2021, 8:39 AMLastExceed
06/11/2021, 8:54 AMWhen you have no reason to add a method or property to iti actually use functions or additional properties in value classes quite rarely. my main use case is just disambiguation. eg im working with an api of a video game trading website and there's
UserId
ItemId
OrderId
ChatId
TransactionId
ect... in total 15 kinds of ids that all have the same format (16 digit random generated hex string) so i wrapped them all in different value classes with no additional members just to make sure that you dont accidently try to use an id in the wrong context
it's a oneliner and it's not going to impact performance in any measurable wayi was more thinking about how annoying it would be if you constantly had to do
.value
everywhere. but then again i now realize that you don't always need things as their underlying type... maybe i should just try it and see how it goesPetter Måhlén
06/11/2021, 9:15 AMId<T>
class. That might save you a bit of redundancy while still ensuring that you can write method signatures like fun fetchUser(id: Id<User>): User
, so that someone might not accidentally pass in an order id there instead.LastExceed
06/11/2021, 9:16 AMCLOVIS
06/11/2021, 9:44 AMtypealias
for the IDs, but that's only so it's easy to read the documentation, you can't use it for verificationLastExceed
06/11/2021, 9:45 AMephemient
06/11/2021, 10:00 AMandylamax
06/11/2021, 10:31 AM