Mailinglist Archive: opensuse-buildservice (176 mails)

< Previous Next >
Re: [opensuse-buildservice] Proposal to use service objects in models
On 14/03/17 13:45, Henne Vogelsang wrote:

Well service objects tend to grow to have many responsibilities, while interactors are by definition limited to one responsibility. This means they are harder to extract but people do not end up "just" moving code around to make complexity metrics happy.


"while interactors are by definition limited to one responsibility"

This is not true, there is nothing to stop you putting too many responsibilities in one interactor. Take a look at the code for the interactor class, its just a service object which uses an Openstruct for the arguments and includes a hooks module:

I think we are comparing apples and oranges here. The interactor gem uses service objects as a way of organising code but gives you a few extra things like context objects and hooks. So I think we have two questions now in the discussion:

1. Do we want to use service objects?
2. Do we want to use a gem to organise our service objects and potentially other kinds objects?

My answer to #1 is of course yes.

As for #2 I think thats also a yes but I would say there are several other gems that give you more structure to your rails app which we should consider.

For example the rectify gem looks good to me as well, it includes 3 other design patterns too:

A third gem which offers a structure to organise code is TrailBlazer. Its quite a bit more radical in its approach than interactor and rectify though..

Though maybe question #2 should be done in a seperate discussion? Keep in mind that the service object I coded can be easily turned into an interactor object or and rectify command object should we choose to use one of those gems.

I've never used any of these gems myself though, does anybody have any experience using something like this?

Evan Rolfe
Full Stack Web Developer
SUSE Linux GmbH, Maxfeldstr. 5, D-90409 Nürnberg
Tel: +49-911-74053-0; Fax: +49-911-7417755;
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard,
Graham Norton, HRB 21284 (AG Nürnberg)

To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse-buildservice+owner@xxxxxxxxxxxx

< Previous Next >