Saiba como não deixar seu model tornar-se um ameaçador colosso em sua app Rails. Dicas sobre como não deixar seu model cheio de responsabilidades, seguindo o SRP e refactories usando PORO dentre outras técnicas. Vamos ver alguns anti-patterns em models e soluções para resolvê-los. Também será apresentado alguns bad smells que podem estar dizendo que nosso model pode estar se tornando um colosso.
Aprendendo com projetos open source @ RubyConf 2015Mauro George
Normalmente utilizamos de livros, cursos, blog posts entre outros para aprendermos. Nesta palestra veremos como podemos aprender, de forma colaborativa, com projetos open source.
Veremos:
- A primeira contribuição;
- Como proceder quando um Pull Request seu não for aceito;
- Não tenha medo de expor seu código;
- Acompanhando projetos;
- Ritmo sustentável;
- Não critique projetos, contribua e melhore-os!
- Abrace os projetos já existentes;
- O que ganhamos com isso tudo.
O cliente e o time juntos por um só objetivo! @ CONADEV 2014Mauro George
Por que investir em times multidisciplinares? Qual a importância de manter uma boa comunicação entre o time e o cliente? Onde começa e termina o papel do cliente no projeto? Por que o time deve quebrar e pontuar tarefas conjuntamente? Qual a importância de desenhar as telas junto ao cliente? Por que o código deve ser coletivo? Qual é a importância das retrospectivas? Por que testes automatizados e integração contínua são indispensáveis para o projeto? Um pouco de como lidamos com agile no dia-a-dia da HE:labs.
Uma breve história sobre como pequenas ações podem mudar a cultura de uma empresa. A aplicação de princípios ágeis no dia-a-dia e como isso influenciou na criação da tradição Hackathon no Walmart.com.
Aprendendo com projetos open source @ RubyConf 2015Mauro George
Normalmente utilizamos de livros, cursos, blog posts entre outros para aprendermos. Nesta palestra veremos como podemos aprender, de forma colaborativa, com projetos open source.
Veremos:
- A primeira contribuição;
- Como proceder quando um Pull Request seu não for aceito;
- Não tenha medo de expor seu código;
- Acompanhando projetos;
- Ritmo sustentável;
- Não critique projetos, contribua e melhore-os!
- Abrace os projetos já existentes;
- O que ganhamos com isso tudo.
O cliente e o time juntos por um só objetivo! @ CONADEV 2014Mauro George
Por que investir em times multidisciplinares? Qual a importância de manter uma boa comunicação entre o time e o cliente? Onde começa e termina o papel do cliente no projeto? Por que o time deve quebrar e pontuar tarefas conjuntamente? Qual a importância de desenhar as telas junto ao cliente? Por que o código deve ser coletivo? Qual é a importância das retrospectivas? Por que testes automatizados e integração contínua são indispensáveis para o projeto? Um pouco de como lidamos com agile no dia-a-dia da HE:labs.
Uma breve história sobre como pequenas ações podem mudar a cultura de uma empresa. A aplicação de princípios ágeis no dia-a-dia e como isso influenciou na criação da tradição Hackathon no Walmart.com.
Testes automatizados o time e o cliente saem ganhando! @ Agile Vale 2014Mauro George
Entenda por que devemos ter testes automatizados em qualquer sistema, independente do seu tamanho. Por que teste automatizado é um investimento. Conheça o TDD e o BDD. Saiba qual o valor gerado pelos testes automatizados para o time e para o cliente. Como vender os testes automatizados ao vender o seu projeto.
Nesta palestra veremos:
- Boas práticas ao escrever testes utilizando o RSpec
- Como escrever testes que acessam rede utilizando o VCR e o WebMock
- Apresentando o factory_girl, comparando com as fixtures. E diversas dicas do factory_girl
- Testes que dependem de data utilizando o timecop
- Coverage de testes com o Simplecov e se devemos ou não atingir os 100% de cobertura de testes
- Evitando repetições durante os testes utilizando de matchers
As dificuldades da adoção do ágil em um ambiente nada convencional.
O Walmart.com passou por um crescimento alucinante no quadro de
funcionários em um curto período de tempo e grandes desafios como a
mudança do nosso modelo de negócio e duas black fridays.
Como conseguimos nesse ambiente complexo criar o nosso DNA ágil próprio:
cultura, ambiente, framework, princípios e valores e manter um clima de
startup. Qual o segredo?
A busca incessante em melhorar e aprender com os próprios erros nos ajudam
a nos tornar quem somos. Toda dificuldade gera uma oportunidade e com
criatividade e colaboração driblamos problemas até então desconhecidos.
Git para iniciantes v1.3.0 @ PHP Conference Brasil 2012Mauro George
Apresentada em 30/11/12 na PHP Conference Brasil 2012. Na palestra você verá uma introdução aos sistemas de controle de versão, passando pelos modelos centralizado e distribuído. Um pouco da história do git, a instalação e GUIs para Mac, Linux e Windows. As configurações e o fluxo básico para o dia a dia. Além de alguns comandos e dicas que ajudarão no dia a dia com o git, inclusive para quem já usa o git no seu dia a dia
RSpec Best Friends @ TDC São Paulo 2014Mauro George
Nesta palestra veremos:
- Boas práticas ao escrever testes utilizando o RSpec
- Como escrever testes que acessam rede utilizando o VCR e o WebMock
- Apresentando o factory_girl, comparando com as fixtures. E diversas dicas do factory_girl
- Testes que dependem de data utilizando o timecop
- Coverage de testes com o Simplecov e se devemos ou não atingir os 100% de cobertura de testes
- Evitando repetições durante os testes utilizando de matchers
RSpec Best Friends @ TDC Florianópolis 2014Mauro George
Nesta palestra veremos:
- Boas práticas ao escrever testes utilizando o RSpec
- Como escrever testes que acessam rede utilizando o VCR e o WebMock
- Apresentando o factory_girl, comparando com as fixtures. E diversas dicas do factory_girl
- Testes que dependem de data utilizando o timecop
- Coverage de testes com o Simplecov e se devemos ou não atingir os 100% de cobertura de testes
- Evitando repetições durante os testes utilizando de matchers
Testes automatizados o time e o cliente saem ganhando! @ Agile Vale 2014Mauro George
Entenda por que devemos ter testes automatizados em qualquer sistema, independente do seu tamanho. Por que teste automatizado é um investimento. Conheça o TDD e o BDD. Saiba qual o valor gerado pelos testes automatizados para o time e para o cliente. Como vender os testes automatizados ao vender o seu projeto.
Nesta palestra veremos:
- Boas práticas ao escrever testes utilizando o RSpec
- Como escrever testes que acessam rede utilizando o VCR e o WebMock
- Apresentando o factory_girl, comparando com as fixtures. E diversas dicas do factory_girl
- Testes que dependem de data utilizando o timecop
- Coverage de testes com o Simplecov e se devemos ou não atingir os 100% de cobertura de testes
- Evitando repetições durante os testes utilizando de matchers
As dificuldades da adoção do ágil em um ambiente nada convencional.
O Walmart.com passou por um crescimento alucinante no quadro de
funcionários em um curto período de tempo e grandes desafios como a
mudança do nosso modelo de negócio e duas black fridays.
Como conseguimos nesse ambiente complexo criar o nosso DNA ágil próprio:
cultura, ambiente, framework, princípios e valores e manter um clima de
startup. Qual o segredo?
A busca incessante em melhorar e aprender com os próprios erros nos ajudam
a nos tornar quem somos. Toda dificuldade gera uma oportunidade e com
criatividade e colaboração driblamos problemas até então desconhecidos.
Git para iniciantes v1.3.0 @ PHP Conference Brasil 2012Mauro George
Apresentada em 30/11/12 na PHP Conference Brasil 2012. Na palestra você verá uma introdução aos sistemas de controle de versão, passando pelos modelos centralizado e distribuído. Um pouco da história do git, a instalação e GUIs para Mac, Linux e Windows. As configurações e o fluxo básico para o dia a dia. Além de alguns comandos e dicas que ajudarão no dia a dia com o git, inclusive para quem já usa o git no seu dia a dia
RSpec Best Friends @ TDC São Paulo 2014Mauro George
Nesta palestra veremos:
- Boas práticas ao escrever testes utilizando o RSpec
- Como escrever testes que acessam rede utilizando o VCR e o WebMock
- Apresentando o factory_girl, comparando com as fixtures. E diversas dicas do factory_girl
- Testes que dependem de data utilizando o timecop
- Coverage de testes com o Simplecov e se devemos ou não atingir os 100% de cobertura de testes
- Evitando repetições durante os testes utilizando de matchers
RSpec Best Friends @ TDC Florianópolis 2014Mauro George
Nesta palestra veremos:
- Boas práticas ao escrever testes utilizando o RSpec
- Como escrever testes que acessam rede utilizando o VCR e o WebMock
- Apresentando o factory_girl, comparando com as fixtures. E diversas dicas do factory_girl
- Testes que dependem de data utilizando o timecop
- Coverage de testes com o Simplecov e se devemos ou não atingir os 100% de cobertura de testes
- Evitando repetições durante os testes utilizando de matchers
One does not simply "Upgrade to Rails 3"testflyjets
A talk given at the February SD Ruby meeting in San Diego, covering the issues one might face when upgrading a Ruby on Rails application from version 2.3 to 3.2.
Covers items deprecated or eliminated between versions, testing strategies, pain points, gotchas and general suggestions for making the transition across major versions of the Rails framework.
Web APIs have revolutionized all kinds of products and services, and still continue to do so. Nowadays the most relevant architecture is REST along with the JSON media type. Furthermore, lots of specifications to serialize those media types are appearing. JSON API has released its first version last May.
Python RESTful webservices with Python: Flask and Django solutionsSolution4Future
Slides contain RESTful solutions based on Python frameworks like Flask and Django. The presentation introduce in REST concept, presents benchmarks and research for best solutions, analyzes performance problems and shows how to simple get better results. Finally presents soruce code in Flask and Django how to make your own RESTful API in 15 minutes.
(QCon London, 2007)
"One of the most important and useful aspects of the Rails framework is it's ability to be extended using plugins. Thanks to the flexibility and power of Ruby, almost any aspect of Rails can be altered to suit the needs of a particular application.
"This presentation will help give developers the boost that's often required to get up to speed developing plugins. We'll cover the hooks that Rails' plugin mechanism makes available, and how to put them to best use in practice with practical examples.
"Once we've covered the groundwork, we'll start to look at more advanced programming techniques for sharing code (and other files) between Rails applications. With a few key programming techniques under our belt, we can use plugins to alter and enhance the Rails framework itself."
On February 18th, 2010 was O'Reilly's "Exploring Rails 3" online conference and these are Gregg Pollack's slides. They are by no means a complete record of improvements in Rails 3, but they should serve to get your appetite wet.
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
Generating a custom Ruby SDK for your web service or Rails API using Smithyg2nightmarescribd
Have you ever wanted a Ruby client API to communicate with your web service? Smithy is a protocol-agnostic language for defining services and SDKs. Smithy Ruby is an implementation of Smithy that generates a Ruby SDK using a Smithy model. In this talk, we will explore Smithy and Smithy Ruby to learn how to generate custom feature-rich SDKs that can communicate with any web service, such as a Rails JSON API.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
Neuro-symbolic (NeSy) AI is on the rise. However, simply machine learning on just any symbolic structure is not sufficient to really harvest the gains of NeSy. These will only be gained when the symbolic structures have an actual semantics. I give an operational definition of semantics as “predictable inference”.
All of this illustrated with link prediction over knowledge graphs, but the argument is general.
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
7. Seu model, um grande colosso
Rails 15 minutes blog
MVC
Rails way
Aplicações grandes
37 Signals stack
ERB
MySQL
MiniTest
Fat Models, Skinny Controllers
Prime stack
Haml
PostgreSQL
Rspec/Cucumber
Skinny models, controllers, and a service layer
8. AR quebra o SRP
Alto acoplamento
Callback
Observer
Finders
Falta de coesão
Persiste dados
Envia e-mail
Acessa Api externas
10. Anti-pattern: Model gerando conteudo para a view
app/models/user.rb
class User < ActiveRecord::Base
Alto acoplamento
# ...
def info
%Q{
<ul>
<li>#{name}</li>
<li>#{email}</li>
</ul>
}
end
end
Falta de coesão
11. Solução: Decorator
app/decorators/user_decorator.rb
require 'delegate'
class UserDecorator < SimpleDelegator
def info
%Q{
<ul>
<li>#{name}</li>
<li>#{email}</li>
</ul>
}
end
end
# Exemplo
user = User.find(1)
user_decorator = UserDecorator.new(user)
user_decorator.info
user_decorator.name
Baixo acoplamento
Alta coesão
12. Anti-pattern: Model gerando conteudo para a view
app/models/user.rb
class User < ActiveRecord::Base
# ...
def wrote_post?(post)
if post.user_id == id
"<p>O post #{post.title} foi escrito por #{name}</p>"
end
end
end
Alto acoplamento
Falta de coesão
Método de Post
ou User
13. Solução: Presenter
app/presenters/writter_post_presenter.rb
class WritterPostPresenter
def initialize(user, post)
@user, @post = user, post
end
Baixo acoplamento
Alta coesão
def post_is_wrote_by_writter?
if wrote_post?
"<p>O post #{post.title} foi escrito por #{user.name}</p>"
end
end
private
attr_reader :user, :post
# Exemplo
def wrote_post?
user == post.user user = User.find(1)
post = Post.find(1)
end
writter_post_presenter = WritterPostPresenter.new(user, post)
end
writter_post_presenter.post_is_wrote_by_writter?
14. Presenters, decorators, exhibit, View Objects e
helpers???
Helpers
Procedurais
Decorators
Para uma única entidade
Presenters
Para multiplas entidades
16. Anti-pattern: Model Callbacks
app/models/post.rb
class Post < ActiveRecord::Base
Alto acoplamento
# ...
after_save :notify_users
# ...
private
def notify_users
NotifyMailer.delay.notify(self)
end
end
Falta de coesão
Testes lentos
17. Solução: PORO model
app/models/post_creator.rb
class PostCreator
def initialize(post)
@post = post
end
def save
post.save && notify_users
end
private
attr_reader :post
def notify_users
NotifyMailer.delay.notify(post)
end
end
Baixo acoplamento
Alta coesão
Testes rápidos
18. Solução: PORO model
app/controllers/posts_controller.rb
class PostsController < ApplicationController
# ..
def create
@post = current_user.posts.new(post_params)
if @post.save
PostCreator.new(@post).save
redirect_to posts_path, notice: "Post criado com sucesso!"
else
render 'new'
end
end
end
20. Anti-pattern: Model salvando N models
app/models/user.rb
class User < ActiveRecord::Base
Alto acoplamento
# ...
accepts_nested_attributes_for :posts
end
Falta de coesão
21. Solução: Form Object
app/models/app/models/user_with_post.rb
class UserWithPost
include ActiveModel::Model
attr_accessor :user_name, :user_email, :post_title, :post_content
validates :user_name, :user_email, :post_title, :post_content, presence: true
def save
return false unless valid?
user = User.create(name: user_name, email: user_email)
user.posts.create(title: post_title, content: post_content)
true
end
Baixo acoplamento
Alta coesão
end
# Exemplo
params = { user_name: "Mauro", user_email: "maurogot@gmail.com",
post_title: "Post 1", post_content: "Content"}
user_with_post = UserWithPost.new(params)
user_with_post.save
28. Solução: Service
app/services/like_manager.rb
class LikeManager
def initialize(likeable, user)
@likeable, @user = likeable, user
end
def like
return false if user_already_liked?
up_one_like
add_user_as_voted
end
Baixo acoplamento
Alta coesão
Única
responsabilidade
Duck Typing
def unlike
return false unless user_already_liked?
down_one_like
remove_user_as_voted
end
# Exemplo
user = User.find(1)
private
post = Post.find(1)
like_manager = LikeManager.new(post, user)
attr_reader :likeable, :user
like_manager.like
like_manager.unlike
def up_one_like
# ...
30. Bad Smell: N métodos com nome de outra entidade
app/models/post.rb
class Post < ActiveRecord::Base
# ...
def popular_comments
# ...
end
def most_viewed_comment
# ...
end
def most_replied_comment
# ...
end
end
31. Bad Smell: N métodos recebendo o mesmo
paramêtro
app/models/post.rb
class Post < ActiveRecord::Base
# ...
def self.most_popular_from(user)
self.top_posts_from(user)
self.more_social_media_repercussion_from(user)
# ...
end
private
def self.top_posts_from(user)
# ...
end
def self.more_social_media_repercussion_from(user)
# ...
end
end
32. Bad Smell: N métodos privados que são usados em
apenas um método
app/models/post.rb
class Post < ActiveRecord::Base
# ...
def self.most_popular
self.most_commented
self.more_social_media_repercussion
# ...
end
private
def self.most_commented
# ...
end
def self.more_social_media_repercussion
# ...
end
end