mercredi 12 juillet 2023

Using flat structure vs wrapper

We have a function with the below contract, we have data as a wrapper and all user details are inside that other option where data is without wrapper. I would love your view which option would you prefer and why?


export interface IContactSource {
  id: string;
  type: string;
}

export interface IContactSearchAttempt {
  firstName: string;
  lastName: string;
  email: string;
  title: string;
  accountName: string;
  linkedinUrl?: string;
  source: IContactSource;
}

export enum ISearchAttemptOperation {
  "CONTACT_PROFILE" = "CONTACT_PROFILE",
  "ACCOUNT_PROFILE" = "ACCOUNT_PROFILE",
}


// first:
export interface ISearchAttemptBody {
  operation: ISearchAttemptOperation;
  data: IContactSearchAttempt;
  attempt?: number;
}

// second:
export interface ISearchAttemptBody {
  operation: ISearchAttemptOperation;
  firstName: string;
  lastName: string;
  email: string;
  title: string;
  accountName: string;
  linkedinUrl?: string;
  source: IContactSource;  
  attempt?: number;
}

Aucun commentaire:

Enregistrer un commentaire