So, I started a little pet project, just to have something to work on, but since last time I worked comercially I learnt some things about patterns and so on. So when I stumbled upon having to convert simple DTO to also simple model that holds its values in program I started to wonder - what would be best practice to convert it?
To calrify - I have something like this:
public class LoggedInDTO
{
public String Token;
public String Name;
}
And I want it to be converted to LoggedInUser
like below:
public class LoggedInUser
{
private String _token;
private String _name;
}
(of course Logged in user will be a little bigger than that, the point is to not use DTO for anything other than transfer, and to have more specialized classes) Now, how to properly convert one to another to achieve best clarity and/or testability? I thought of just passing DTO to constructor and then just copying values, but my concern is that it will be "tightly coupled", which is thing that all websites are telling as horror story of programming. From the other side, one is the base of another, so why not? Or maybe converter to have everything in one place?
What would be the best practice for that? Or maybe I am overthinking everything and should not concern myself with such?