I have a question regarding good practices/principles when it comes to Helper/Utility classes in OOP.
I have read online that helper/utility classes are a bad practice and go against what OOP is about (Ex: This SO Question), but I am unable to find helpful alternatives to these classes.
I will get more in depth to my problem to specify why I'm asking this question in hopes of getting some advice to go forward with. I am a new software developer who wants to develop my knowledge of design patterns and practices as that aspect of development has always been important to me (how to create good code rather than code that just works).
I am currently working on an ASP.NET MVC application. For simplicity sake, I will refer to the first two stages of the application, each with its own controller. Originally, Stage 1's controller had a bunch of methods that were to retrieve lists from SharePoint. I am implementing new functions of the application that now requires Stage 2's controller to also retrieve information from these same SharePoint lists. Following the DRY Principle, I do not want to include these methods in both stage's controller classes. Instead I was initially going to create a new helper/utility class that would include all these (static) methods to retrieve the information from the SharePoint lists that all controllers could use (helpful for the future of the application to promote code reuse).
Seeing these articles saying that this helper/utility class is going against OOP and an anti-pattern, I would like some advice on how I should go about this problem.
Thanks!
EDIT
I have realized that a solution that will come to most people's minds would be to pass the list information from Stage 1's controller to Stage 2's controller, but the list information is only necessary in specific scenarios that will be known only during Stage 2 of the application. I would like to avoid the overhead of passing the list information from Stage 1 to Stage 2 and only access the SharePoint lists when needed during Stage 2.
Thanks again!
Aucun commentaire:
Enregistrer un commentaire