Mailinglist Archive: opensuse-buildservice (63 mails)

< Previous Next >
[opensuse-buildservice] Proposal to use decorator classes in frontend
Hi, another proposal here :)

In this PR I have introduced a new app directory for decorator classes.

https://github.com/openSUSE/open-build-service/pull/2610

Please speak up if you have any alternative ideas or objections to using this pattern. If you're unfamiliar with decorators this article is pretty good but the main advantages are:

https://robertomurray.co.uk/blog/2014/decorators-presenters-delegators-rails/

- they seperate presentation logic from models and views
- they can be unit tested
- they are classes so you get all the OOP advantages to organise and re-use code as opposed to helper methods which usually end up like spaghetti code

These are the two new classes I've created in the PR: BaseDecorator and MaintenanceStatisticDecorator:

https://github.com/evanrolfe/open-build-service/blob/e6c8bc4dcdb2169d542b432a3ea604bd822f1d89/src/api/app/decorators/base_decorator.rb
https://github.com/evanrolfe/open-build-service/blob/e6c8bc4dcdb2169d542b432a3ea604bd822f1d89/src/api/app/decorators/statistics/maintenance_statistic_decorator.rb

Let me know what you think.

Thanks

--
Evan Rolfe
Full Stack Web Developer
SUSE Linux GmbH, Maxfeldstr. 5, D-90409 Nürnberg
Tel: +49-911-74053-0; Fax: +49-911-7417755; https://www.suse.com/
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 >
This Thread
  • No further messages