DDD Entity Example
This program models DDD entity.
Problem Statement
Write a Java program where Customer is an entity with identity.
Source Code
| 1 | class Customer { |
| 2 | String id; String name; |
| 3 | Customer(String i,String n){ id=i; name=n; } |
| 4 | } |
| 5 | public class DDDEntity { |
| 6 | public static void main(String[] args) { |
| 7 | System.out.println("Eduinq DDD Entity"); |
| 8 | Customer c=new Customer("C001","Arun"); |
| 9 | System.out.println("Customer: "+c.id+", "+c.name); |
| 10 | } |
| 11 | } |
Program Output
Eduinq DDD Entity Customer: C001, Arun
Explanation
Entity has identity and attributes. - Identity distinguishes entity across lifecycle. - This models DDD entity concept. Conclusion: Shows DDD entity example.