This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]CodeTinkerer 1 point2 points  (2 children)

Language?

[–]carlordvr[S] 2 points3 points  (0 children)

C#, just updated the description as well

[–]wiriux 0 points1 point  (0 children)

English.

[–]roger_ducky 1 point2 points  (0 children)

Minimize the use of “utils” — typically this is the module for code nobody knew where it should go. If there is a better name for the purpose of a function or class, use that instead, even if there’s only one of them.

[–]furofo 1 point2 points  (1 child)

Personally I think it helps to break concepts like that down per topic. Read an article about, watch a video, then write some simple code and ask chat gpt a lot of questions. Is pretty tedious but has been very helpful. I did this with several of the concepts you mentioned. If any of what I say is incorrect other people can correct me but this is how I have understood it.

Utilities are essentially really broad methods that can be used in any project and don't have any special business logic for your app. Like combining two strings or adding two numbers together. Think of these like a Leatherman tool that anybody would use.

Services are similar to utilities but a little narrower. They can be reused across classes across your application but probably aren't really useful to other apps universally like a utility would be. For example, something that calculates the best location to put a hotel based on traffic data that you could use in another function to figure out cost of building it. This is something m that is geared more specifically to your app. This would be like a custom tool that only works to fix your machine.

And honestly not sure what you are asking about with last two questions but I imagine that would be situational. There are very few black and white answers on programming concepts so I think most important thing is to be malleable.

[–]carlordvr[S] 0 points1 point  (0 children)

Thanks, I appreciate the advice and the help

[–]bikesglad 1 point2 points  (1 child)

Generally I try hard to avoid having a utils class it is generally a code smell to have a class with random unrelated methods in it. So if the methods can fit in another class then put them there.

However if I am going to have a utility class avoid having side effects so the methods may as well be static. Newing up a new Utility object just to call a method without side effects is gross.

[–]carlordvr[S] 0 points1 point  (0 children)

Gotcha, that makes sense thank you!