I'm working on a project with a MVP architecture.
My program revolve around forms that give rights to people.
There are X differents forms depending on profiles ( so there are X differents profiles)
I have an abstract class which we will call BasicFormClass
.
Each forms has a presentation that inherits from BasicFormClass
The more I work on this project, the more I observe my presentations becoming "fat", especially BasicFormClass
: a lot of functionnality are called and execute by it.
So my question is : Is a presentation potentially a god object?
Asked
Active
Viewed 122 times
1

Freddykong
- 149
- 9
-
This depends on what functionality you put into the presentation classes and the base class. If it is not directly related to the presentation, it should be extracted to separate classes. – JacquesB Apr 18 '18 at 08:46
-
Functionnalities are: crypting content, checking content of fields ,etc. but even if it's in separate class, if the calls are done by the presentation isn't it the same trough the eye of the "god object" problem ? – Freddykong Apr 18 '18 at 09:00
-
Possible duplicate of [What is the real responsibility of a class?](https://softwareengineering.stackexchange.com/questions/220230/what-is-the-real-responsibility-of-a-class) – gnat Apr 18 '18 at 09:11
-
1@Freddykong: It depends if the calls logically belong in the presentation layer or not. You might legitimately have a complex presentation layer, but if it does things like calling the database or a network service, then you haven't separated responsibilities correctly. – JacquesB Apr 18 '18 at 10:27
-
Is it getting fat from low-level statements or because the complexity is increasing? If it is the latter, use a helper class to reduce the bulk. If it is the former, consider refactoring common tasks and handlers to allow handler classes to deal with such things (bonus points if derived classes can make use of them as well). – Neil Apr 18 '18 at 11:18
-
@Neil it is becoming fat because it is performing differents task that are not delegated to other classes (ATM) . I don't know if it answers your question. But even if I do refactor all the tasks that need to be, The presentation will still call thoses functions right? – Freddykong Apr 18 '18 at 12:08
-
@Freddykong You obviously still want to have all that run. The question is simply how many steps does it take conceptually to accomplish those tasks? If the task were making a peanut butter and jelly sandwich, the steps would be, "Get bread. Get peanut butter. Get Jelly. Get Knife" and not "Put left foot in front. Put right foot in front." It helps to reorganize in these terms. – Neil Apr 18 '18 at 12:32
-
@Neil I think i get what you mean, my presentation does actually things that should not be performed by it. So If i create classes and put them as composition of my BasicFormClass and call their functions to performs the appropriate tasks, it will be ok ( still trough the eye of god-object problem) ? – Freddykong Apr 18 '18 at 12:39
-
1@Freddykong BasicFormClass can be heavily involved without doing most of the work. You can create user controls to group logic in its own class, or create an event handler. It's only a god class if it contains most of the logic. Decide what *must* be handled in the BasicFormClass and what can be delegated elsewhere. Does that answer your question? – Neil Apr 18 '18 at 12:44
-
@Neil Yes , Sir. If you want to write it as an answer, I will mark it as the answer of my question. :) Thanks a lot for enlightening me with your lantern ! ( french expression ;) ) – Freddykong Apr 18 '18 at 12:49
-
@Freddykong Happy to help. :) – Neil Apr 18 '18 at 12:56
1 Answers
2
Is it getting fat from low-level statements or because the complexity is increasing? If it is the latter, use a helper class to reduce the bulk. If it is the former, consider refactoring common tasks and handlers to allow handler classes to deal with such things (bonus points if derived classes can make use of them as well).
Your BaseFormClass is only a god class if it contains all the logic. There is nothing wrong with BaseFormClass delegating tasks to other classes, thereby freeing up BaseFormClass to the very basic decisions necessary for your class to work.
Consider creating an event handler or user controls to help separate smaller responsibilities handled in BaseFormClass into their own classes. Good luck!

Neil
- 22,670
- 45
- 76