Skip to content

Instantly share code, notes, and snippets.

@sizovs
Last active November 12, 2021 18:43
Show Gist options
  • Save sizovs/e3bbc0219c22b15a05446119a9b4a4ec to your computer and use it in GitHub Desktop.
Save sizovs/e3bbc0219c22b15a05446119a9b4a4ec to your computer and use it in GitHub Desktop.
Playtech Nov 11-12 2021

Effective Java with Playtech Nov 11-12, 2021

Links

πŸŽ“ Your well-deserved LinkedIn certificates

Congrats! : )

πŸ“š Awesome books

  • Growing Object-Oriented Software Guided by Tests β€” The best testing and TDD book
  • TDD: TDD by Example (Kent Beck) β€” TDD book from the creator of TDD
  • Secure by Design (Dan Bergh Johnsson, Daniel Deogun) β€” Software Design book
  • Java Application Architecture (Kirk K.) β€” Architecture book
  • Patterns of Enterprise Application Architecture – Architecture book
  • Clean Code β€” coding book
  • Head First Design Patterns (2nd edition) – Software Design book
  • Head First Object-Oriented Analysis & Design – Software Design book
  • Implementing Domain-Driven Design (Vaughn Vernon) – Software Architecture and Design book
  • Elegant Objects – OOP book
  • Agile PPP (Robert Martin) - a book about SOLID principles (and other cool things)
  • The Software Craftsman – inspiration to become a better programmer :-)
  • The Clean Coder – inspiration to become a better programmer :-)
  • eXtreme Programming Explained (Kent Beck) – engineering practices book
  • Thinking, Fast and Slow (Kahnenam) – how our brains work

For more books, follow me on Goodreads

Some cool Java libs

Videos:

Not mentioned in slides

  • Marker Interface
  • Header Interface
  • Role Interface
  • The Stepdown Rule (how to order methods, explained well in Clean Code book)
  • Spring "sees" static nested classes.
  • Method Object pattern (turning a method into a class, see BankAccount Enforce* methods)
  • Coupling = Measure of Connectedness.
  • Cohesion = Measure of Relatedness.
  • SRP = fancy name for Cohesion (SRP = does one thing; single reason to change)
  • Reading vs. Writing is ~10:1 (developers read code much more than they write it)
  • Our goal as code authors is to reduce Discovery Cost
  • High level of abstraction = more scanning, less thinking = more productivity and happiness : )
  • Reification = Thingification ("to thingify" something; to turn something into a thing)
  • APIs are like diamonds – they're forever
  • You Aint Gonna Need It (Yet)
  • Sunk Cost Fallacy
  • Java community moving away from checked exceptions to unchecked exceptions (runtime exceptions)
  • Rich domain model (DDD, good for non-trival businesses) vs. Anemic domain model (good for CRUD)
  • Use ByteBuddy instead of Cglib
  • Typing is cheap, coupling is expensive (don't be afraid of creating some DTOs)
  • DTOs and domain model change for different reasons
  • Never let an entity escape transaction boundary
  • https://github.com/sizovs/pipelinr/ (a good friend of .NET's MediatR)
  • Spring core: BeanFactory, ListableBeanFactory, ObjectProvider
  • Cross-cutting concerns (AOP language)
  • MDC = Mapped Diagnostic Context; NDC = Nested Diagnostic Context
  • Database isolation levels: https://github.com/ept/hermitage
  • UnitOfWork (the patterns that Hiberrnate and other ORMs are using to automatically sync object changes with the DB)
  • Temporal coupling (ugly situation when you have to remember to do something before doing X)
  • CQRS (Command-Query Responsibiltiy Segregation)
  • jOOQ – super awesome fluent SQL for Java
  • Moderl SQL: https://modern-sql.com/

Example how object methods reduce coupling (vs. setters)

### coupling = 2
| domain (1)               | domain (2) |
agreement.setSigned(false) | agreement.setSigned(false);

### coupling = 1
| domain (1)               | domain (2) |
agreement.callOff();       | agreement.suspendFraudulent();

Things we didn't have time and energy to cover

  • Day I: covered everything (but I suggest going through slides again).
  • Day II: Managing dependencies between packages and why it matters. You can watch my old but still relevant video from XPDays conference in Ukraine. It's in Russian. English version is available too, but it's not that good IMHO. Or is it? :-)
  • Day II: Unit and acceptance testing. Slides are pretty self-explanatory. For more, check out TDD books above. They are mind-blowing.
  • Day II: Validation. Nothing particularly exciting here – just use Bean Validator to validate data classes. And remember that good objects are secure by design, t.i. objects should fail fast if you provide some falsy data; Even better – they shouldn't allow you to provide falsy data thanks to strong types. For example:
  • Day II: IDs, PKs, equality and hashCode. Slides are pretty self-explanatory.
  • Day II: Aggregate roots. Software architecture best practices suggest that we should only create Repositories for Aggregate Roots. For example, BankAccount "owns" a collection of Transactions and controls access to them. So, Bank Account is an Aggregate Root. So our system should have one repository – BankAccountRepository, and never provide a separate repository for Transactions. Why? Check out the slides here. For more explanation, read DDD book.
  • Day II: Transactional Outbox Pattern. Good explanation here: https://microservices.io/patterns/data/transactional-outbox.html
  • Day II: Fault Tolernace Patterns. Slides are pretty self-explanatory. For more, I suggest amazing Release It! book (2nd edition).

Is blacklist racist?

A bit of Googling shows that the phrase blacklist/whitelist have etymological roots that are unrelated to race/racism. Also found a good alternative: Blocklist :-)

Let's stay connected!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment