Skip to main content
deleted 26 characters in body; edited title
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

Is it bad practice to pass Passing a DTO into a static domain 'Create' method?

I've gotI'm wondering if it's bad practice to couple my DTO to my domain object like this and pass the following code:object itself into Create(). Is it better to just give the parameters needed to perform the creation?

public static Playlist Create(PlaylistDto playlistDto, IUserManager userManager, IPlaylistManager playlistManager)
{
    Playlist playlist = new Playlist
        {
            Id = playlistDto.Id,
            Items = PlaylistItem.Create(playlistDto.Items, playlistManager),
            Sequence = playlistDto.Sequence,
            Title = playlistDto.Title,
            User = userManager.Get(playlistDto.UserId)
        };

    return playlist;
}

I'm wondering if it's bad practice to couple my DTO to my domain object like this and pass the object itself into create. Is it better to just give the parameters needed to perform the create?

Is it bad practice to pass a DTO into a static domain 'Create' method?

I've got the following code:

public static Playlist Create(PlaylistDto playlistDto, IUserManager userManager, IPlaylistManager playlistManager)
{
    Playlist playlist = new Playlist
        {
            Id = playlistDto.Id,
            Items = PlaylistItem.Create(playlistDto.Items, playlistManager),
            Sequence = playlistDto.Sequence,
            Title = playlistDto.Title,
            User = userManager.Get(playlistDto.UserId)
        };

    return playlist;
}

I'm wondering if it's bad practice to couple my DTO to my domain object like this and pass the object itself into create. Is it better to just give the parameters needed to perform the create?

Passing a DTO into a static domain 'Create' method

I'm wondering if it's bad practice to couple my DTO to my domain object like this and pass the object itself into Create(). Is it better to just give the parameters needed to perform the creation?

public static Playlist Create(PlaylistDto playlistDto, IUserManager userManager, IPlaylistManager playlistManager)
{
    Playlist playlist = new Playlist
        {
            Id = playlistDto.Id,
            Items = PlaylistItem.Create(playlistDto.Items, playlistManager),
            Sequence = playlistDto.Sequence,
            Title = playlistDto.Title,
            User = userManager.Get(playlistDto.UserId)
        };

    return playlist;
}
edited tags
Link
200_success
  • 145.6k
  • 22
  • 191
  • 481
Source Link
Sean Anderson
  • 1.8k
  • 2
  • 13
  • 23

Is it bad practice to pass a DTO into a static domain 'Create' method?

I've got the following code:

public static Playlist Create(PlaylistDto playlistDto, IUserManager userManager, IPlaylistManager playlistManager)
{
    Playlist playlist = new Playlist
        {
            Id = playlistDto.Id,
            Items = PlaylistItem.Create(playlistDto.Items, playlistManager),
            Sequence = playlistDto.Sequence,
            Title = playlistDto.Title,
            User = userManager.Get(playlistDto.UserId)
        };

    return playlist;
}

I'm wondering if it's bad practice to couple my DTO to my domain object like this and pass the object itself into create. Is it better to just give the parameters needed to perform the create?