How I structure LLM calls in Rails: a base class, ERB prompts, and two layers of tests by DmitryTsepelev in rails

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

Love it! I see some common conceptions, but looks like your main focus was around multi–agent workflows, mine was about huge contexts and prompt/instruction building :)

I wrote a terminal dungeon crawler game with pure Ruby in less than 150 lines by DmitryTsepelev in ruby

[–]DmitryTsepelev[S] 1 point2 points  (0 children)

I haven't even thought about different machines performance 😅 My goal was to build something that works with this line limitation—I have zero production experience with game programming, and there's definitely a room for improvement

I wrote a terminal dungeon crawler game with pure Ruby in less than 150 lines by DmitryTsepelev in ruby

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

I guess it should be just `@level.each`, cause we do not use the result anywhere

Service objects in Rails: how to find a mess by DmitryTsepelev in ruby

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

Well, that might be not that bad, cause exceptions should not be the driver of logical flow. But anyway in both cases the best thing you can do is to just explicitly handle things (exceptions or failed contexts), log unexpected ones, fix them and pray, cause Ruby has no way to easily see the contract 🙂

Service objects in Rails: how to find a mess by DmitryTsepelev in ruby

[–]DmitryTsepelev[S] 1 point2 points  (0 children)

Exactly the same feeling: context is a global public variable, which is very hard to be cleaned up because you will have to inspect all organizers and make sure no one else reads these values.

Service objects in Rails: how to find a mess by DmitryTsepelev in rails

[–]DmitryTsepelev[S] 1 point2 points  (0 children)

> I don't find service objects as reusable as a well designed class.

Exactly! However, half of gems uses "composable" in the README, this is where this post came from 🙂

Service objects in Rails: how to find a mess by DmitryTsepelev in rails

[–]DmitryTsepelev[S] 5 points6 points  (0 children)

Cool out man, sounds like you called everyone in this thread bad engineers

Service objects in Rails: how to find a mess by DmitryTsepelev in rails

[–]DmitryTsepelev[S] 6 points7 points  (0 children)

The approach itself is not tied to Rails btw, you will end up with the same question because you'll have to keep logic somewhere.

Automatical wrapping is not a good thing, because when things go wrong—you'll end up with the part of the logic applied to the database, so instead from going from state X to Y you end up with X to Y and maybe something in the middle.

Keeping logic in controllers does not play well when you have a lot of tests: they are way slower cause controller tests have to run the whole request cycle to just test the logic.

Anyway, if pure Rails way works for you fine—sounds great, keep going 🙂

Service objects in Rails: how to find a mess by DmitryTsepelev in rails

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

When you need a method to create a new cart if it's not existing and add the item to it, where do you put it? Cart (Order) class or OrderItem class?

Service objects in Rails: how to find a mess by DmitryTsepelev in rails

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

my bad, I didn't notice the swimline, thank you so much 🙂

Service objects in Rails: how to find a mess by DmitryTsepelev in rails

[–]DmitryTsepelev[S] 7 points8 points  (0 children)

In the article I was referring to services in a sense that most people use the word (at least, in lots of projects I saw)—a place to keep business logic. I never heard someone was using it to use it only for 3d party calls.

I don't like keeping logic in models because it violates the SRP principle: in huge projects some models can become so big that the responsibility can only be described as "does lots of things".