java - POJOs (Entities?) with differnt amount of properties but same "meaning" (like being an Article). How to design that? -


i give small example:

we have simple architecture that:

gui -> domain <- dal

with gui , dal pointing towards domain in terms of dependency.

now domain contains entities, let's following "order" entity:

public class order {     private string name;     private collection<article> articles;     ...getter setters etc } 

now imagine 2 scenarios, 1 need articles (say gui layer asks list of orders , needs order details except articles) , 1 don't need them (one order it's articles).

how best design that? 2 pojos? inheritance?

in cases it's smart use 2 (or more) interfaces class. if entities in same database table, want limit usage, there's not really (technically speaking) several types of entities.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -