wtorek, 14 marca 2017

The architecture of the project

I have not been journalist and director more then five times. The reason was: ambition. 
Hate that word, hate that mind condition, when you have belief that you are perfect one to change the world. Everyone is equal, nobody's perfect. When I decided to cure out of my ambition I felt happy. Ambition for me is synonyms of expectations, but not mine. Expectations from each other, and I can't feel free with that. Kill every ambitions as soon as possible. No matter what are you doing, developing apps or directing films. Ambition kills you like a cancer, and wasting your time and life. I even think that it causes often suicide especially in the artistic class. That it is a primary reason why I'm stopped with films and started with programming.

So..., I don't want to be the best RoR and JS developer in the world, the life may be boring when you're the best. I have a lots of fun when I make a mistake. Sometimes it's funny. But... I'm going to present you how my RoR app looks like.

At first... I should not use MVC architecture in Rails app

So I'm convinced that rails app should have many layers. Not only three. It will be simple and chaotic. My app structure also has:

1) Models: only for validations, callbacks and extra methods. I don't like business logic in the models. 2) Validators: for every validator which includes with many models. 3) Interactions - for interactions with database, CUD methods (create, update, destroy) - without R (read). For every business logic. I'm using Active Interaction gem. In the interaction you can also use validations through models. 4) Providers: for 'R' method from CRUD - filtering and ordering data. Simple ruby functions. 5) Queries: for SQL queries. 6) Controllers (building with GRAPE gem): Endpoints without business logic. In the controllers I also run the interactions, providers or queries. Sometimes simple active record queries like .all or .first. I'm convinced that more then 2-3 lines of business logic in the controllers is too much. I know, it's a philosophical issue. The grape endpoints can validate params with type. It's a big plus. 7) Entities: for grape endpoints, using grape-entity gem. 8) Specs: I'm TDD fan. I'm testing everything using RSpec. APIs (quasi integrations tests), Interactions (business logic), queries, providers and models. Remember, do happy and unhappy path. I'm also using factory girl gem, and spring. 9) Workers: for sidekick workers. 10) Mailers: for mailers. 11) Sometimes others i.e. helpers, matchers for rspec etc.


Views & Rails Controllers
Views are also different frontend app. Sorry rails views, I don't need you. 
Rails controllers? What it is? :)


Brak komentarzy:

Prześlij komentarz