Skip to content

About entity issues #53

Open
Open
@Jay-57blocks

Description

@Jay-57blocks

I read your article
Entity: The business objects of the application, they are the least likely to change when external things change
Model: Inherit and extend Domain layer Entity, realize json conversion and more needs

Generally speaking, business requirements have some additional fields, such as isSelected and isComplete, which are related to UI state
I don't know whether these attributes are placed in the Domain layer or in the Presentation layer to create a new model

I am very confused and hope to wait for your reply

Thanks

Domain:

class QuestionEntitie {
  final int id;
  final String category;
  final String question;

 /// Should it be declared here?
  final bool isSelected;
  final bool isComplete;
}

OR Presentation:

class QuestionItem {
  final QuestionEntitie item
  /// or declare here ?
  final bool isSelected;
  final bool isComplete;
}

Data:

class QuestionModel extends QuestionEntitie {
  QuestionModel({
    required super.id,
    required super.category,
    required super.question,
  });

  factory QuestionModel.fromJson(Map<String, dynamic> json) {
    return QuestionModel(
      id: json['id'],
      category: json['category'],
      question: json['question'],
    );
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions