I guess this can go into many OO languages. I build my domain objects and don’t know where the best place is for interfaces and abstract classes.
If I have a pet pack with different implementations of the abstract APet class: should it live side by side with them or in the parent pack?
What about interfaces? It seems that they should almost live above the parent package implementations, since there may potentially be other subpackages that implement it, although there seems to be a stronger correlation between one abstract class and the subpackage.
eg.
com.foo com.foo.IConsumer (interface) com.foo.APet (abstract) com.foo.pets.Dog extends APet implements IConsumer
OR
com.foo com.foo.IConsumer (interface) com.foo.pets.APet (abstract) com.foo.pets.Dog extends APet implements IConsumer
or something else?
. , factory. , , .
, - .
, ( , ) , final , - ". Impl". , Pets Bird, Fish, Mammal Reptile , , , . Pets.Impl Goldfish, Canary, Collie, . , Bird , , , , .:)
final
Pets
Bird
Fish
Mammal
Reptile
Pets.Impl
Goldfish
Canary
Collie
, . , , . :
com.foo.APet (Abstract Class) com.foo.pets.ADog extends com.foo.APet (Also Abstract) com.foo.pets.impl.Westie extends ADog (not abstract).
In this case, the APet is at the top because it provides features common to all pets. ADog is definitely a pet, but it contains those things that are common to all DOGS. Classes in the impl package are manufactured using factory or whatever, and specialize in breed-based.
Source: https://habr.com/ru/post/1749637/More articles:Android - How to upload a txt file to a website? - javaRemote-server-timeout exception when I try to connect to the server - javaSmack API gives error when logging in to Tigase Server locally - androidПроблема создания JPA EntityManager в Spring Контекст - springAdding the Include path for a module to a simple Perl tutorial - moduleError binding WPF menu to ItemsSource - c #Android Float To Int - androidLog 2 N general comparison tree - comparisonSqlCE Flush Interval - Will the default cause damage? - sql-serverhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1749642/rpg-compiler-converts-type-s-to-type-p&usg=ALkJrhg79px98heaUmtwaR_ya3kvmV2zxQAll Articles