Showing posts with label books. Show all posts
Showing posts with label books. Show all posts

Sunday, December 1, 2024

Cloud Native Spring in Action

 


Nice book, it covers really a lot of topics, well worth reading.



Thursday, October 31, 2024

Life 3.0: Being Human in the Age of Artificial Intelligence

Very savvy book about AI, worth reading even if it's from 2017

Life 3.0: Being Human in the Age of Artificial Intelligence






Friday, January 3, 2020

Lasse Koskela, Effective Unit Testing

https://www.manning.com/books/effective-unit-testing


I am really enjoying this book, the Author reflects about the STRATEGIC importance of well written Unit Tests as a way to DRIVE development.

It focuses also on the importance of writing SIMPLE CODE and avoid unnecessary complication:

"One of the worst offenders of code quality and a major contributor to
developers’ productivity crawling to a halt is accidental complexity.
Accidental complexity is unnecessary complexity. It’s complexity that could
be avoided by substituting a simpler design that still meets the requirements. Sometimes
we programmers like to demonstrate our mental capacity by producing such
complex designs that we have trouble understanding them ourselves. I will bet you
recognize that primal instinct in yourself, too. The problem with complex designs is
that complexity kills productivity and unnecessary complexity is, well, unnecessary
and counterproductive."





Saturday, July 13, 2019

Book: Spring Microservices in Action


This is a brilliantly written book.

https://github.com/carnellj/spmia-chapter1

Microservice Architecture

@SpringBootApplication
@RestController
@RequestMapping
@PathVariable

Flexible, Resilient, Scalable

IaaS, PaaS, SaaS, FaaS, CaaS

Client-side load balancing, Circuit breaker, Fallback, Bulkhead

Log correlation. Log aggregation. Microservice tracing

Spring Cloud:
Netflix Eureka (discovery), Zuul (routing), Ribbon (LN), Hystrix (Circuit Breaker), Sleuth/Uipkin (logging, tracing, aggregation), Oauth2/JWT

https://cloud.spring.io/spring-cloud-security/ Spring Security

https://jwt.io JavaScript Web Token

https://travis-ci.org


Hystrix proxies all RestTemplate. calls to add timeout. Ribbon also injects RestTemplate with all available service instances for LB and FO


to expose a bean there are 2 ways:
either one of @Component, @Service, @Repository
or @Configuration + @Bean


Apache Thrift, Apache Avro

12 factor apps: codebase in git, dependencies in maven, config in separate files, backing services (DB etc) cloud-ready,
immutable builds, stateless processes, port binding, horizontal scaling, disposable services, dev=prod, streamable logs (splunk, fluentd), scripted admin tasks.


Actuator health check.








Saturday, June 8, 2019

Cloud-Native Applications in Java


excellent book covering basically EVERYTHING about the Java Cloud ecosystem.



Monday, May 6, 2019

Accelerate

https://www.kobo.com/us/en/ebook/accelerate-7




This is an excellent book - not only about technology but mostly about culture, leadership, teamwork, innovation.

I don't share the enthusiastic vision of the author for which life is about serving corporations to beat competition and cut jobs. However it's an educational book.


Monday, April 29, 2019

IntelliJ IDEA Essentials




this is a really precious book, very focused and essential, to learn very practical tricks on how to use Intellij effectively




Tuesday, April 9, 2019

Effective Java third edition


the source code:

https://github.com/jbloch/effective-java-3e-source-code






*clone (p. 86)
copy constructor/ copy factory
compareTo()
java.util.Comparator.comparingInt + thenComparingInt


immutable objects

composition over inheritance

default methods

generics and collections

unbounded wildcard types (<?>)

PECS producer extends consumer super

isAnnotationPresent
@ExceptionTest
@Repeatable


java.util.function
Operator
Predicate
Function
Supplier
Consumer



Monday, April 1, 2019

Best Spring books

reblogging for my own reference, I am planning to read all those 5 books...

https://javarevisited.blogspot.com/2018/04/5-spring-framework-books-experienced-Java-developers-2018.html

- Spring in Action 5
- Cloud Native Java
- Learning Spring Boot 2.0
- Spring 5 Recipes
- Spring Microservices in Action



I am already going through https://www.udemy.com/spring-framework-5-beginner-to-guru/ but I find it incredibly non-concise - lot of repeated stuff, very lengthy and boring coding sessions where you don't really see much new, lot of unnecessary verbosity. Not my style, I like crisp, focused, simple examples and just fundamental facts and concepts.


Saturday, March 30, 2019

Java EE 8 Application Development book

David R. Heffelfinger - Java EE 8 Application Development-Packt Publishing (2017)



I am going through the examples of the book, using WLS 12.2.1.3 (it supports only Java EE 7, unfortunately), and IntelliJ 2019.1

here how to setup your environment (very easy!) :

https://www.jetbrains.com/help/idea/creating-and-running-your-first-java-ee-application.html#bfda7423


Code is here https://github.com/PacktPublishing/Java-EE-8-Application-Development


You can run also on Wildfly 16 https://wildfly.org/downloads/ which supports Java EE 8


Java EE 8 Javadoc https://javaee.github.io/javaee-spec/javadocs/index.html?overview-summary.html

Monday, March 25, 2019

Book: java by comparison by Simon Harrer, Jörg Lenhard, Linus Dietz

Interesting book, concise and a breeze to read

https://pragprog.com/book/javacomp/java-by-comparison



Source code is here https://pragprog.com/titles/javacomp/source_code

My first (not very functional) implementation of FizzBuzz:

import java.util.stream.IntStream;

public class ConsoleBasedFizzBuzz implements FizzBuzz {
    public static void main(String[] args) {
        FizzBuzz fizzBuzz = new ConsoleBasedFizzBuzz();
        fizzBuzz.print(1, 100);
    }

    private static void accept(int i) {
        StringBuffer result = new StringBuffer();
        if (i % 3 == 0) result.append("Fizz");
        if (i % 5 == 0) result.append("Buzz");
        if (result.length() == 0) result.append(i);
        System.out.println(result);
    }

    @Override
    public void print(int from, int to) {
        IntStream.range(from, to).forEach(ConsoleBasedFizzBuzz::accept);
    }
}



"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."


Avoid Unnecessary Comparisons
Avoid Negations
Return Boolean Expressions Directly
Simplify Boolean Expressions
Avoid NullPointerException in Conditionals
Avoid Switch Fallthrough
Always Use Braces
Ensure Code Symmetry
Replace Magic Numbers with Constants
Favor Enums Over Integer Constants
Favor For-Each Over For Loops
Avoid Collection Modification During Iteration
Avoid Compute-Intense Operations During Iteration
Group with New Lines
Favor Format Over Concatenation
Favor Java API Over DIY
Remove Superfluous Comments
Remove Commented-Out Code
Replace Comments with Constants
Replace Comments with Utility Methods
Document Implementation Decisions
Document Using Examples
Structure JavaDoc of Packages
Structure JavaDoc of Classes and Interfaces
Structure JavaDoc of Methods
Structure JavaDoc of Constructors
Use Java Naming Conventions
Follow Getter/Setter Conventions for Frameworks
Avoid Single-Letter Names
Avoid Abbreviations
Avoid Meaningless Terms
Use Domain Terminology
Fail Fast
Always Catch Most Specific Exception
Explain Cause in Message
Avoid Breaking the Cause Chain
Expose Cause in Variable
Always Check Type Before Cast
Always Close Resources
Always Close Multiple Resources
Explain Empty Catch
Structure Tests Into Given-When-Then
Use Meaningful Assertions
Expected Before Actual Value
Use Reasonable Tolerance Values
Let JUnit Handle Exceptions
Describe Your Tests @DisplayName @Disabled
Favor Standalone Tests
Parametrize Your Tests @ParameterizedTest @ValueSource
Cover the Edge Cases
Split Method with Optional Parameters
Favor Abstract Over Concrete Types
Favor Immutable Over Mutable State
Combine State and Behavior
Avoid Leaking References (defensive copying)
Avoid Returning Null
Favor Lambdas Over Anonymous Classes
Favor Method References Over Lambdas
Avoid Side Effects
Use Collect for Terminating Complex Streams
Avoid Exceptions in Streams
Favor Optional Over Null (Optional.ofNullable())
Avoid Optional Fields or Parameters
Use Optionals as Streams

Google Java Style Guide https://google.github.io/styleguide/javaguide.html

Automate Your Build
Favor Logging Over Console Output
Minimize and Isolate Multithreaded Code
Use High-Level Concurrency Abstractions
Speed Up Your Program


import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;

import java.io.IOException;

public class JunitAssertionsTest {

    @Test
    public void testException() {
        Executable when = () -> pippo();
        Assertions.assertThrows(IOException.class, when);
    }

    private void pippo() throws IOException {
        System.out.println("running");
        throw new IOException("ciao");
    }
}



Sunday, April 22, 2018

wildfly configuration, deployment and administration - second edition


This is a decent book, hands on and very practical. It wastes a bit too much time explaining stuff that everybody knows (what is TLS) rather than concentrating only on Wildfly stuff. Also big drawback is lack of github repository with examples (you can download then from the publisher). Also the style is a bit dry and boring.

Good for the beginner just getting started with Wildfly.



Friday, April 6, 2018

Kubernetes up and running


https://github.com/kubernetes-up-and-running/examples

Velocity
Declarative, self-healing
Decoupled architectures (APIs and LB) (Pods, LB, namespaces, ingress)



Thursday, April 5, 2018

primefaces cookbook on wildfly

The book is covering in depth many examples available on the official PF showcase. Don't expect advanced programming techniques, it's purely about implement not-so-common use cases in PF


sample code is here https://github.com/ova2/primefaces-cookbook

git clone git://github.com/ova2/primefaces-cookbook.git
cd primefaces-cookbook
mvn install

copy $MAVEN_REPO/org/primefaces/cookbook/showcase/2.0.0/showcase-2.0.0.war to /opt/wildfly12/standalone/deployments

http://localhost:8180/pf-cookbook/ (or http://localhost:8080/pf-cookbook/ )



Tuesday, January 16, 2018

the Docker book by James Turnbull



The books - although a bit outdated - is still excellent, very practical, hands-on and detailed.



Saturday, October 28, 2017

Adam Bien: real world Java EE 6 Patterns 2012 edition

here a general presentation http://download.java.net/general/podcasts/real_world_java_ee_patterns.pdf

here the book (11 USD in Kindle) https://www.amazon.com/Real-World-Java-Patterns-Rethinking-Practices/dp/1300149310/ref=sr_1_1?s=books&ie=UTF8&qid=1508683416&sr=1-1




Examples from the books here https://github.com/dlee0113/java_ee_patterns_and_best_practices

I love the dry, concise, down-to-earth approach of Adam, however a little more sense of humor would not hurt... but I prefer a concise book than a book who tries to be smart and eventually only wastes your time in endless blablabla

Sunday, October 15, 2017

Camel in Action, Second Edition

I have just purchased the book from Manning (if you google for "manning discount code" you should find a coupon to get a 40% discount on these EXTREMELY (52 USD) expensive books ...)

I am a bit disappointed by the book, it's extremely verbose and it repeats a lot of concepts that - unless this is the first IT book you read in your life - are very well known to anybody. You have to wade across a lot of verbosity to extract useful practical info "how to solve this kind of problem".

Also, the choice to cover at the same depth the XML DSL and the Java DSL, the Spring XML configuration and the Spring Java configuration leaves me astonished.... Spring XML is almost extinct, in favor of Java.

Also, some frightening basic English mistakes like using "whom" instead of "who" , together with incredibly complicated sentences, makes you wonder about the literary skills of the authors.

I also dislike embedding a lot of incomplete code in a book.... a coding book should only provide a link to a github repository, I can't understand code if I don't see ii in its completeness... for instance something frustrating is when the import statements are omitted.


The examples associated to the book are here:
git clone https://github.com/camelinaction/camelinaction2


Here https://github.com/apache/camel/tree/master/examples/camel-example-spring-boot a simple Camel - Spring Boot example

run it like this:

git clone https://github.com/apache/camel.git
cd camel
mvn install
cd examples\camel-example-spring-boot
mvn spring-boot:run





Tuesday, September 26, 2017

Books: Docker in Action



It's an excellent book, highly recommended, Jeff Nickoloff is a great author.

Here some notes from the exercises

docker run dockerinaction/hello_world

docker help


Usage: docker COMMAND

A self-sufficient runtime for containers

Options:
--config string Location of client config files (default "/home/centos/.docker")
-D, --debug Enable debug mode
--help Print usage
-H, --host list Daemon socket(s) to connect to
-l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
--tls Use TLS; implied by --tlsverify
--tlscacert string Trust certs signed only by this CA (default "/home/centos/.docker/ca.pem")
--tlscert string Path to TLS certificate file (default "/home/centos/.docker/cert.pem")
--tlskey string Path to TLS key file (default "/home/centos/.docker/key.pem")
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit

Management Commands:
config Manage Docker configs
container Manage containers
image Manage images
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
secret Manage Docker secrets
service Manage services
stack Manage Docker stacks
swarm Manage Swarm
system Manage Docker
volume Manage volumes

Commands:
attach Attach local standard input, output, and error streams to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes to files or directories on a container's filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container's filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
login Log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search the Docker Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
wait Block until one or more containers stop, then print their exit codes

Run 'docker COMMAND --help' for more information on a command.






interesting demo of Portainer https://portainer.io/overview.html#demo , I have installed and run locally to manage my environment

docker run --detach --name web nginx:latest

docker run --interactive --tty --link web:web --name web_test busybox:latest /bin/sh

wget -O - http://web:80/

exit
(CTRL-P CTRL-Q to run interactively a process and then detach)

#this example is WRONG in the book!
docker run -d --name mailer dockerinaction/ch2_mailer

docker run -it --name agent --link web:insideweb --link mailer:insidemailer dockerinaction/ch2_agent

#connect to a running instance in interactive mode
docker start -i "CID"

docker restart web
docker restart mailer
docker restart agent

docker run -d --name namespaceA busybox:latest /bin/sh -c "sleep 30000"
docker run -d --name namespaceB busybox:latest /bin/sh -c "nc -l -p 0.0.0.0:80"

docker exec namespaceA ps
docker exec namespaceB ps

#creating a conflict by NOT using namespaces
docker run -d --name webConflict nginx:latest
docker logs webConflict
docker exec webConflict nginx -g 'daemon off;'

#avoiding conflicts by using namespaces
docker run -d --name webA nginx:latest
docker logs webA
docker run -d --name webB nginx:latest
docker logs webB


docker rename webA webPippo

#create is like run, but it's created in stopped state
CID=$(docker create nginx)
echo $CID

docker create --cidfile /tmp/web.cid nginx

#running 3 containers linked to each other - in reverse order
MAILER_CID=$(docker run -d dockerinaction/ch2_mailer)
WEB_CID=$(docker run -d nginx)
AGENT_CID=$(docker run -d --link $WEB_CID:insideweb --link $MAILER_CID:insidemailer dockerinaction/ch2_agent)

#check status of container
docker inspect $CID


docker search postgres


docker pull busybox:latest
docker save -o myfile.tar busybox:latest
docker rmi busybox
docker load -i myfile.tar