Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
C0D4669025yYou lost me at "thematic helpers" and "whole app" , there's something not quite right about calling a helper function / method from a global layer.
-
Lyniven44535yI guess you can have a Helpers namespace for a framework, such as Laravel that have its Str and Arr classes.
For an app, and all of it? Why is my question -
Leonid165yBad idea) you wouldn't be able to reuse your code in future and it's look messy, just get best from OOP and SOLID it will help you in future projects
-
I may have not expressed my self properly.
Lets say you create a class ServerRequest, that encapsulate the android AsyncHttpRequest from loopj.
In the constructure u create the client et configure it.
In the private fields u have the host url and all api endpoint as statis constants.
And some public methods for post and get request.
And an empty public overridable method called "processresponse".
So far this is the normal oop i use.
But my idea in " thematic helpers" is that, since that class manage connection between my app and the backend why cant i make it manage more of the things related to that app-backend connexion ? ?
Like for example adding a static method that takes Context in arg and check internet connectivity and redirect user to android setting page ?
This helper may be used outside of the only purpose of the class itself,
Dunno if i am bit more clearer -
Leonid165y@devapsarl Having all stuff in single class may break single responsibility principle, but since it's an Android app I'm not think it's so critical when you don't have large enterprise solution with bunch of devs and testers who will work and test your code. Otherwise, it is better to build right practice as habit, it will help in future
-
@Leonid
Thx mate for the advice.
Can u clarify what this single responsabiliy principe is made for ? To avoid what scenarios ?
What it is its pros and cons -
Leonid165y@devapsarl single responsibility is just one of 5 principles of object oriented design known as S.O.L.I.D
you should read this article for more information about all of them with examples in Java (if you use it for your android apps) http://blazorhelpwebsite.com/Blog/...
Related Rants
What do u think guys about the generic idea to add static methods in a class that will be some sort of "thematic helpers" that will be used in the whole app ?
question
java
php