Java 9 Dependency Injection

Krunal Patel, Nilang Patel

  • 出版商: Packt Publishing
  • 出版日期: 2018-04-26
  • 售價: $1,980
  • 貴賓價: 9.5$1,881
  • 語言: 英文
  • 頁數: 246
  • 裝訂: Paperback
  • ISBN: 1788296257
  • ISBN-13: 9781788296250
  • 相關分類: Java 程式語言
  • 海外代購書籍(需單獨結帳)

相關主題

商品描述

Key Features

  • Use DI to make your code loosely coupled to manage and test your applications easily on Spring 5 and Google Guice
  • Identify when to use the Constructor or the Setter approaches for better results
  • Write more maintainable Java code by decoupling your objects from their implementations

Book Description

Dependency Injection is a design pattern that allows us to remove the hard-coded dependencies and make our application loosely coupled, extendable and maintainable. We can implement dependency injection to move the dependency resolution from compile-time to runtime.

This book will be your one stop guide to write loosely coupled code using the latest features of Java 9 with frameworks such as Spring 5 and Google Guice.

The book begins by explaining you what Dependency Injection is and teach you about the IoC containers. From here, you will learn about the Object compositions and its role in DI and will learn to build a modular application. You will learn how to use Dependency Injection to focus your efforts on the business logic unique to your application and let the framework handle the infrastructure work to put it all together. After this, you will explore Spring and Guice, the popular frameworks for Dependency Injection and see how to define injection keys and configure them in the framework-specific level. The book will then teach you how to use dependency injection when writing web applications and implement Aspect oriented programming in Guice and Spring.

Towards the end, you will learn to integrate any third party library in your DI-enabled application and explore common pitfalls and recommendations to build a solid application with DI.

What you will Learn

  • Understand the benefits of Dependency Injection and get from a tightly coupled design to a cleaner design organized around dependencies.
  • Set up Guice and Spring in an application so that it can be used for DI
  • Use scopes for handling complex application scenarios
  • Integrate any third party library in your DI-enabled application
  • Use dependency injection when writing web applications
  • Implement Aspect Oriented Programming to handle common cross-cutting concerns such as logging, authentication and transactions.
  • Write integration tests for DI applications

商品描述(中文翻譯)

關鍵特點
- 使用依賴注入(DI)使您的程式碼與應用程式鬆散耦合,便於在 Spring 5 和 Google Guice 上管理和測試您的應用程式
- 確定何時使用建構子或設置器方法以獲得更好的結果
- 通過將物件與其實現解耦,撰寫更易於維護的 Java 程式碼

書籍描述
依賴注入是一種設計模式,允許我們移除硬編碼的依賴,使我們的應用程式鬆散耦合、可擴展且易於維護。我們可以實現依賴注入,將依賴解析從編譯時移動到執行時。

本書將成為您使用 Java 9 最新特性以及 Spring 5 和 Google Guice 等框架撰寫鬆散耦合程式碼的全方位指南。

本書首先解釋什麼是依賴注入,並教您有關 IoC 容器的知識。接著,您將學習物件組合及其在依賴注入中的角色,並學會構建模組化應用程式。您將學會如何使用依賴注入,專注於您應用程式獨特的業務邏輯,並讓框架處理基礎設施的工作。之後,您將探索 Spring 和 Guice 這兩個流行的依賴注入框架,了解如何定義注入鍵並在框架特定層級進行配置。本書還將教您在撰寫網頁應用程式時如何使用依賴注入,並在 Guice 和 Spring 中實現面向切面的程式設計。

在書的最後,您將學會如何在您的 DI 啟用應用程式中整合任何第三方庫,並探索常見的陷阱和建議,以建立一個穩固的 DI 應用程式。

您將學到的內容
- 理解依賴注入的好處,從緊密耦合的設計轉變為圍繞依賴關係組織的更清晰設計
- 在應用程式中設置 Guice 和 Spring,以便用於依賴注入
- 使用範圍來處理複雜的應用程式場景
- 在您的 DI 啟用應用程式中整合任何第三方庫
- 在撰寫網頁應用程式時使用依賴注入
- 實現面向切面的程式設計,以處理常見的橫切關注點,例如日誌記錄、身份驗證和交易
- 為 DI 應用程式撰寫整合測試