Untitled attachment
https://cdn.social.linux.pizza/v1/AUTH_91eb37814936490c95da7b85993cc2ff/sociallinuxpizza/media_attachments/files/110/892/348/369/635/553/original/8843636fd08983a1.png
@kaia I don't know the language you're working in but yea... that is generally the way to go.
Functions help keeping your code "DRY" ("Don't Repeat Yourself").
Classes can help with SRP ("Single Responsibility Principle") where 1 class does 1 thing and is very good at it.
As for the "how do you know what each returns: In most languages, you can define that and most editors will be able to show it.
In the screenshot here, my function returns an instance of the "ReponseBuilder".
GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.
All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.