Layered Design for Ruby on Rails Applications : Discover Practical Design Patterns for Maintainable Web Applications 🔍
Vladimir Dementyev Packt Publishing, Limited, 1, 1, 2023
英语 [en] · PDF · 14.9MB · 2023 · 📘 非小说类图书 · 🚀/lgli/lgrs/nexusstc/zlib · Save
描述
Transition from the traditional Rails model-view-controller trio to an abstraction model and let your application codebase evolve with synchronized components, boosting flexibility and maintainability
Purchase of the print or Kindle book includes a free PDF eBook
Key Features Understand Rails' architectural patterns along with its advantages and disadvantages Organize business logic in Rails apps when the default approach is insufficient Introduce new abstractions to address design problems Book Description Ruby on Rails is an open-source framework for building web applications from scratch while focusing on productivity, leveraging the power of the convention-over-configuration principle, and the well-defined model-view-controller pattern, assisting the developers in building useful features. However, this initial simplicity often leads to uncontrollable complexity turning the well-structured codebase into a hardly maintainable mess. This book aims to help you keep the code maintainable while working on a Rails application.
You'll start by exploring the framework capabilities and principles, allowing you to reap the full potential of Rails. Then, you'll tackle many common design problems by discovering useful patterns and abstraction layers. By implementing abstraction and dividing the application into manageable modules, you'll be able to concentrate on specific parts of the app development without getting overwhelmed by the entire codebase. This strategy also encourages code reuse, simplifying the process of adding new features and enhancing the application's capabilities. Additionally, you'll explore further steps in scaling Rails codebase, such as service extractions.
By the end of this book, you'll be a code design specialist with a deep understanding of the Rails framework principles.
What you will learn Discover Rails' core components and its request/response cycle Understand Rails' convention-over-configuration principle and its impact on development Explore patterns for flexibility, extensibility, and testability in Rails Identify and address Rails' anti-patterns for cleaner code Implement design patterns for handling bloated models and messy views Expand from mailers to multi-channel notification deliveries Explore different authorization models and layers Use a class-based approach to configuration in Rails Who this book is for This book is for Rails application developers facing challenges in managing the growing complexity of their projects. It offers practical strategies for maintaining code readability and manageability, providing valuable guidance for developers at all levels. Whether you've recently launched your first Rails minimum viable product or are struggling to progress with a sizable monolithic application, this book is here to help. A deep understanding of core Rails principles is a must. Some experience in building web applications using the Rails framework will enhance your comprehension and application of the concepts presented in the book.
Table of Contents Rails as a Web Application Framework Active Models and Records More Adapters, Less Implementations Rails Anti-Patterns? When Rails Abstractions Are Not Enough Data Layer Abstractions Handling User Input outside of Models Pulling Out the Representation Layer Authorization Models and Layers Crafting the Notifications Layer Better Abstractions for HTML Views Configuration as a First-Class Application Citizen Cross-Layers and Off-Layers
备用文件名
lgli/Layered Design for Ruby on Rails Applications Discover practical design patterns for maintainable web applications. (Dementyev, Vladimir).pdf
备用文件名
lgrsnf/Layered Design for Ruby on Rails Applications Discover practical design patterns for maintainable web applications. (Dementyev, Vladimir).pdf
备用文件名
zlib/Computers/Web Development/Vladimir Dementyev/Layered Design for Ruby on Rails Applications: Discover practical design patterns for maintainable web applications_25844640.pdf
备用版本
United Kingdom and Ireland, United Kingdom
备用版本
Packt Publishing, Birmingham, UK, 2023
元数据中的注释
{"content":{"parsed_at":1708364445,"parser":{"name":"textparser","version":"0.1.82"},"source":{"name":"aquila","version":"4.2.0"}},"edition":"1","isbns":["1801813787","9781801813785"],"last_page":439,"publisher":"Packt Publishing"}
备用描述
Cover
Title Page
Copyright
Dedication
Contributors
Table of Contents
Preface
Part 1: Explore Rails and Its Abstractions
Chapter 1: Rails as a Web Application Framework
Technical requirements
The journey of a click through Rails abstraction layers
From web requests to abstraction layers
Rack
Rails on Rack
Rails routing
C for controller
Beyond requests – background and scheduled tasks
The need for background jobs
Jobs as units of work
Scheduled jobs
The heart of a web application – the database
The trade-off between abstractions and database performance
Database-level abstractions
Summary
Questions
Exercises
Further reading
Chapter 2: Active Models and Records
Technical requirements
Active Record overview – persistence and beyond
Object-relational mapping
From mapping to the model
From model to anything
Active Model – the hidden gem behind Active Record
Active Model as an interface
Active Model as an Active Record satellite
Active Model versus Struct – performance implications
Active Model for an Active Record-like experience
Seeking God objects
Summary
Questions
Exercises
Further reading
Chapter 3: More Adapters, Less Implementations
Technical requirements
Active Job as a universal queue interface
Adapterizing queues
Serializing all things
Active Storage and its adapters and plugins
Adapters versus plugins
Adapters and wrappers at your service
Summary
Questions
Exercises
Further reading
Chapter 4: Rails Anti-Patterns?
Technical requirements
Callbacks, callbacks everywhere
Callbacks under control (and in controllers)
Active Record callbacks go wild
Concerning Rails concerns
Extracting behavior, not code
Concerns are still modules, with all the shortcomings
Extracting objects from objects
On global and current states
Current everything
Summary
Questions
Exercises
Chapter 5: When Rails Abstractions Are Not Enough
Technical requirements
The curse of fat/thin controllers and thin/fat models
From fat controllers to fat models
A fat controller example
Refactoring the example controller following the thin controllers, fat models principle
From fat models to services
Generic services and granular abstractions
Layered architecture and abstraction layers
Summary
Questions
Part 2: Extracting Layers from Models
Chapter 6: Data Layer Abstractions
Technical requirements
Using query objects to extract (complex) queries from models
Extracting query objects
Scopes versus query objects
Reusable query objects and Arel
Code organization with query objects versus architecture layers
Separating domain and persistence with repositories
Summary
Questions
Chapter 7: Handling User Input outside of Models
Technical requirements
Form objects – closer to the UI, farther from persistence
UI forms versus models
Using Active Model to abstract form objects
Filter objects or user-driven query building
Filtering in controllers
Moving filtering to models
Extracting filter objects
Filter objects versus form objects versus query objects
Summary
Questions
Exercise
Chapter 8: Pulling Out the Representation Layer
Technical requirements
Using presenters to decouple models from views
Leave helpers for libraries
Presenters and decorators
Presenters as an abstraction layer
Serializers are presenters for your API
From model to JSON
Serializers as API presenters
Summary
Questions
Further reading
Part 3: Essential Layers for Rails Applications
Chapter 9: Authorization Models and Layers
Technical requirements
Authorization, authentication, and friends
Authentication versus authorization
Lines of defense for a web application
Authorization models
Domain-less authorization models
Classic authorization models
Authorization enforcement, or the need for authorization abstractions
Extracting policy objects
Shaping an abstraction layer for authorization
Authorization in views
Performance implications of authorization
The N+1 authorization problem in the representation layer
The case of scoping-based authorization
Summary
Questions
Exercise
Further reading
Chapter 10: Crafting the Notifications Layer
Technical requirements
From Action Mailer to multiple notification channels
Action Mailer in action
Mailers in the layered architecture
Not only emails or adding more notification channels
Extracting notifications layer
Ad hoc abstraction
Using third-party libraries to manage notifications
Modeling user notification preferences
Bit fields and value objects
Notification preferences store
A separate table for storing preferences
Summary
Questions
Exercises
Chapter 11: Better Abstractions for HTML Views
Technical requirements
The V in Rails’ MVC: templates and helpers
UI without a programming interface
Reusability and design systems
Thinking in components
Turning partials and helpers into components
View components as an abstraction layer
View components for mixed teams
Summary
Questions
Further reading
Chapter 12: Configuration as a First-Class Application Citizen
Technical requirements
Configuration sources and types
Files, secrets, credentials, and more
Settings and secrets
Production, development, and local configurations versus data providers
Using domain objects to tame configuration complexity
Separating application code from configuration sources
Using specialized configuration classes
Summary
Questions
Exercises
Chapter 13: Cross-Layers and Off-Layers
Technical requirements
The Rails infrastructure layer and its diversity
Infrastructure abstractions and implementations
Across the layers – logging and monitoring
Logging
Exception tracking
Instrumentation
Extracting implementations into services
Separating WebSockets from Action Cable with AnyCable
Processing images on the fly and off Rails
Summary
Questions
Index
Gems and Patterns
About Packt
Other Books You May Enjoy
备用描述
Transition from the traditional Rails model-view-controller trio to an abstraction model and let your application codebase evolve with synchronized components, boosting flexibility and maintainability. Purchase of the print or Kindle book includes a free PDF eBook through the link provided withinKey FeaturesUnderstand Rails'architectural patterns along with its advantages and disadvantagesOrganize business logic in Rails apps when the default approach is insufficientIntroduce new abstractions to address design problemsBook DescriptionRuby on Rails is an open-source framework for building web applications from scratch while focusing on productivity, leveraging the power of the convention-over-configuration principle, and the well-defined model-view-controller pattern, assisting the developers in building useful features. However, this initial simplicity often leads to uncontrollable complexity turning the well-structured codebase into a hardly maintainable mess. This book aims to help you keep the code maintainable while working on a Rails application. You'll start by exploring the framework capabilities and principles, allowing you to reap the full potential of Rails. Then, you'll tackle many common design problems by discovering useful patterns and abstraction layers. By implementing abstraction and dividing the application into manageable modules, you'll be able to concentrate on specific parts of the app development without getting overwhelmed by the entire codebase. This strategy also encourages code reuse, simplifying the process of adding new features and enhancing the application's capabilities. Additionally, you'll explore further steps in scaling Rails codebase, such as service extractions. By the end of this book, you'll be a code design specialist with a deep understanding of the Rails framework principles.What you will learnDiscover Rails'core components and its request/response cycleUnderstand Rails'convention-over-configuration principle and its impact on developmentExplore patterns for flexibility, extensibility, and testability in RailsIdentify and address Rails'anti-patterns for cleaner codeImplement design patterns for handling bloated models and messy viewsExpand from mailers to multi-channel notification deliveriesExplore different authorization models and layersUse a class-based approach to configuration in RailsWho this book is forThis book is for Rails application developers facing challenges in managing the growing complexity of their projects. It offers practical strategies for maintaining code readability and manageability, providing valuable guidance for developers at all levels. Whether you've recently launched your first Rails minimum viable product or are struggling to progress with a sizable monolithic application, this book is here to help. A deep understanding of core Rails principles is a must. Some experience in building web applications using the Rails framework will enhance your comprehension and application of the concepts presented in the book.
开源日期
2023-08-24
更多信息……
We strongly recommend that you support the author by buying or donating on their personal website, or borrowing in your local library.

🚀 快速下载

成为会员以支持书籍、论文等的长期保存。为了感谢您对我们的支持,您将获得高速下载权益。❤️
如果您在本月捐款,您将获得双倍的快速下载次数。

🐢 低速下载

由可信的合作方提供。 更多信息请参见常见问题解答。 (可能需要验证浏览器——无限次下载!)

  • 对于大文件,我们建议使用下载管理器以防止中断。
    推荐的下载管理器:JDownloader
  • 您将需要一个电子书或 PDF 阅读器来打开文件,具体取决于文件格式。
    推荐的电子书阅读器:Anna的档案在线查看器ReadEraCalibre
  • 使用在线工具进行格式转换。
    推荐的转换工具:CloudConvertPrintFriendly
  • 您可以将 PDF 和 EPUB 文件发送到您的 Kindle 或 Kobo 电子阅读器。
    推荐的工具:亚马逊的“发送到 Kindle”djazz 的“发送到 Kobo/Kindle”
  • 支持作者和图书馆
    ✍️ 如果您喜欢这个并且能够负担得起,请考虑购买原版,或直接支持作者。
    📚 如果您当地的图书馆有这本书,请考虑在那里免费借阅。