Let's guess I have class on server like
class MyData {
String statusA;
String statusB;
String statusC;
...
Something field20;
boolean canDoX() {
return statusA.equals('z') && statusB.equals('y')
}
}
It is mapping from DB entity. Now for optimization was created new class
class MyDataWithHalfOfFields {
String statusA;
String statusB;
String statusC;
...
Something field10;
}
How should I replace canDoX so that it will be according to clean architecture?
Lang is Java but not really matter
Update
Why it is optimization. Designer wants 2 pages in frontend
- Group of objects with data from array of MyDataWithHalfOfFields
- Page of MyData
May be it won't be a big problem to get unnecessary fields for one object but for list it already more consuming
I dont have xp with java, but i guess the question is more about oop than clean arch. But if java classes accept inheritance and abstract classes, or just inheritance, you can make a class with the specific behavior (canDoX()) an then extends in both classes. But, have a chance to use the MyData class instead MyDataWithHalfOfFields?