Clean Code Fundamentals: Hands-on Guide to Understand the Fundamentals of Software Craftsmanship and Clean Code in Java
โ Scribed by Martin Hock
- Publisher
- leanpub.com
- Year
- 2024
- Tongue
- English
- Category
- Library
No coin nor oath required. For personal study only.
โฆ Table of Contents
Table of Contents
Preface
What is the goal of this book?
Which topics can you expect?
Who should read this book?
What you must learn about Software Development yourself?
What about the code examples and typographic conventions?
Which literature is this book based on?
Giving Feedback?
Introduction to Software Craftsmanship and Clean Code
A Passion for Software Development
Manifesto for Software Craftsmanship
Clean Code Developer
Boy Scout Rule
Broken Windows Theory
Cargo Cult Programming
Knowledge - Expertise
Basics of Software Design
Software Design Pyramid
Basic concepts of OOD
Goals of Software Design
Symptoms of bad design
Criteria for good design
Information Hiding
Cohesion
Coupling
Cohesion - Coupling
Big Ball of Mud
Architecture Principles
Cognitive Psychology and Architectural Principles
Layered Architecture
Use of Layered Architecture
Violated Layered Architecture
Horizontal Layering
Feature-Based Layering - Single package
Feature-Based Layering - Slices before layers
Feature-Based Layering โ Hexagonal Architecture
The Java Module System
Architecture Documentation
Testing the Architecture and Design
Software Engineering Values
Team Charter
Clean Code Best Practices
Communicate through code
Use Java code conventions and avoid misinformation
Choose an expressive name and avoid mental mapping
Make differences clear with meaningful variable names
Use pronounceable names
Do not hurt the readers
Don`t add redundant context
Don't add words without additional meaning
Don't use and or or in method names
Use positive names for boolean variables and functions
Respect the order within classes
Group by line break
Prefer self-explanatory code instead of comments
Refactor step by step
Bad comments
Redundant comments
Misleading comments
Mandatory comments
Diary comments
Gossip
Position identifier
Write-ups and incidental remarks
Don't leave commented out code in your codebase
Rules for commenting
Classes and objects
Classes
Functions
Variables
Shapes of code
Spikes
Paragraphs
Paragraphs with headers
Suspicious comments
Intensive use of an object
Software Quality Assurance
Test Pyramid
Test Classification
Test-driven Development (TDD)
Unit testing with JUnit 5
Unit Tests
JUnit 5
First unit test
Assertions
assertEquals() / assertArrayEquals()
assertSame() / assertNotSame()
assertTrue() / assertFalse() / assertAll()
assertNull() / assertNotNull()
assertThrows()
assertTimeout()
fail()
Annotations
@Test
@BeforeEach / @AfterEach
@BeforeAll / @AfterAll
@Disabled
@DisplayName
@Tag
@Timeout
Assumptions
assumeFalse()
assumeTrue()
assumingThat()
Parameterized Tests
@ValueSource
@MethodSource
@CsvSource
@CsvFileSource
@ArgumentsSource
More on Unit Tests
Heuristics
Naming of test methods
Object Mother
Test Data Builder
F.I.R.S.T
Mocking with Mockito
Types of Test Double
Activation
Annotations
@Mock
@Spy
@Captor
Code Coverage
Static Code Analysis
Continuous Integration
Differences between CI, CD, and CD
CI Workflow
Preconditions
Advantages and Disadvantages
Best Practices
Design Principles
Goal of Design Principles
Overview of Design Principles
SOLID Principles
Single Responsibility Principle
Example: Modem
Example: Book
Example: Product
Open Closed Principle
Example: LoanRequestHandler
Example: Shape
Example: HumanResourceDepartment
Example: Calculator
Example: FileParser
Liskov Substitution Principle
Example: Rectangle
Example: Coupon
Example: Bird
Interface Segregation Principle
Example: MultiFunctionDevice
Example: TechEmployee
Example: StockOrder
Dependency Inversion Principle
Example: UserService
Example: Logger
Packaging Principles - Cohesion
Release Reuse Equivalency Principle
Common Closure Principle
Common Reuse Principle
Packaging Principles - Coupling
Acyclic Dependencies Principle
Example: Cyclic dependency
Stable Dependencies Principle
Stable Abstractions Principles
Further Design Principles
Speaking Code Principle
Keep It Simple (and) Stupid!
Don't Repeat Yourself / Once and Only Once
You Ain't Gonna Need It!
Separation Of Concerns
Design Patterns of the Gang of Four
Creational
Singleton
Example: Lazy loading
Example: Eager loading
Example: Enum singleton
Builder
Example: MealBuilder
Example: PizzaBuilder
Example: Email
Example: ImmutablePerson
Factory Method
Example: Logger
Example: Department
Abstract Factory
Example: Car
Prototype
Example: Person - Shallow copy
Example: Person - Deep copy
Example: Person - Copy constructor / factory
Structural
Facade
Example: Travel
Example: SmartHome
Decorator
Example: Message
Example: Window
Adapter
Example: Sorter
Example: TextFormatter
Composite
Example: Graphic
Example: Organization Chart
Bridge
Example: Message
Example: Television
Flyweight
Example: Font
Example: City
Proxy
Example: Spaceship
Example: ImageViewer
Behavioural
State
Example: MP3Player
Example: Door
Template Method
Example: Compiler
Example: Callbackable
Strategy
Example: Compression
Example: LogFormatter
Observer
Example: DataStore
Example: Influencer
Chain of Responsibility
Example: Purchase
Example: Authentication
Command
Example: FileSystem
Example: Television
Interpreter
Example: HexBinary
Example: Calculator
Iterator
Example: Cars - intern
Example: Cars - extern
Mediator
Example: Chat
Example: Aircraft
Memento
Example: Editor
Example: Balance
Visitor
Example: Fridge
Example: Figures
๐ SIMILAR VOLUMES
To become a better software developer needs deep knowledge and practical skills in the field of software development and quality. This book gives an overview and discusses in-depth knowledge for the analysis and improvement of your software code. You will be able to apply principles, patterns, te
Even bad code can function. But if code isn t clean, it can bring a development organization to its knees. Every year, countless hours and significant resources are lost because of poorly written code. But it doesn t have to be that way.<br />Noted software expert Robert C. Martin presents a revolut