[VV67] Advent of code, static nested class, spring handler, sdkman, REST, URL parts, springboot 3 poll, luhn check, multi-team refinement
[VV67] The Java Fullstack Newsletter

[VV67] Advent of code, static nested class, spring handler, sdkman, REST, URL parts, springboot 3 poll, luhn check, multi-team refinement

????Advent of Code 2023

Advent of Code is an Advent calendar of small programming puzzles for various skill sets and skill levels that can be solved in any programming language you like. People use them for interview prep, company training, university coursework, practice problems, a speed contest, or to challenge each other.

https://adventofcode.com




???JAVA CERTIFICATION QUESTION: static nested class

Given:

public class OuterClass{
    static class NestedClass{}
    public static void main(String[] args){
        NestedClass nestedA = new NestedClass();//1
        OuterClass.NestedClass nestedB = new OuterClass.NestedClass();//2
        NestedClass nestedC = new OuterClass().new NestedClass();//3
        NestedClass nestedD = new OuterClass.NestedClass();//4
    }
}        

Which line fails to compile?

* line 1

* line 2

* line 3

* line 4

* All of the above

#java #certificationquestion #ocp

https://www.udemy.com/course/ocp-oracle-certified-professional-java-developer-prep/?referralCode=54114F9AD41F127CB99A

The wrong syntax is the one in line 3:

NestedClass nestedC = new OuterClass().new NestedClass();

Explanation:

NestedClass nestedA = new NestedClass();

- This line is valid because NestedClass is a static nested class of OuterClass, and it can be instantiated directly.

OuterClass.NestedClass nestedB = new OuterClass.NestedClass();

- This line is also valid. It explicitly mentions the outer class name (OuterClass) followed by the nested class name (NestedClass), and it creates an instance of the static nested class.

NestedClass nestedC = new OuterClass().new NestedClass();

- This line will fail to compile.

It attempts to create an instance of the nested class using the new OuterClass().new NestedClass() syntax, but NestedClass is a static nested class, not an inner (non-static nested) class.

To create an instance of a non-static nested class, you would need an instance of the outer class, but in this case, NestedClass is static.

NestedClass nestedD = new OuterClass.NestedClass();

- This line is similar to line 2 and is also valid.

It creates an instance of the static nested class without requiring an instance of the outer class.

(Note if NestedClass was not static, it would be the syntax at line 3 the right syntax.)




???? SPRING CERTIFICATION QUESTION: HandlerAdapter & HandlerMapping

Which is true about the workflow of mapping an incoming request to a controller method? Choose two.

(A handler method is a method annotated with @RequestMapping/@GetMapping/@PostMapping/... inside a controller class annotated with @Controller/@RestController).

* Incoming requests are mapped to a controller handler method by the DispatcherServlet

* HandlerAdapter defines a strategy for mapping client requests to controllers.

* HandlerMapping handles HTTP requests by invoking the appropriate controller method.

* DispatcherServlet uses components of type HandlerAdapter and HandlerMapping

#spring #certificationquestion #vcp

https://www.udemy.com/course/spring-professional-certification-6-full-tests-2v0-7222-a/?referralCode=04B6ED315B27753236AC

Right answers:

Incoming requests are mapped to a controller handler method by the DispatcherServlet.

This is true. The DispatcherServlet is the front controller in Spring MVC and is responsible for handling incoming requests.

It uses various components, including HandlerMapping, to determine which controller method (handler method) should handle the request.

DispatcherServlet uses components of type HandlerAdapter and HandlerMapping.

This is true.

DispatcherServlet relies on HandlerAdapter to invoke the appropriate controller method and HandlerMapping to map the request to the correct handler.

Wrong answers:

HandlerAdapter defines a strategy for mapping client requests to controllers.

This statement is false.

HandlerAdapter is responsible for adapting (invoking) the controller method to handle a request, but it does not define the strategy for mapping requests to controllers.

The mapping strategy is the role of HandlerMapping.

HandlerMapping handles HTTP requests by invoking the appropriate controller method.

This statement is false.

HandlerMapping is responsible for determining which controller method (handler method) should handle a specific request by mapping the request to the appropriate handler.

However, HandlerMapping itself does not handle the request; it provides the mapping information to the DispatcherServlet.

The actual handling of the request is done by HandlerAdapter, which is responsible for adapting the request to the controller method.




QUOTE ???

Learn any new technology by practicing regularly and staying consistent – that's the key to becoming an expert.



? INSTALL SDKMAN on Windows

INSTALL SDKMAN on Windows

SDKMAN is a tool that lets you install and switch between different versions of SDKs for various languages and platforms on Unix systems.

It is inspired by apt, pip, RVM, and Git, and supports Java, Scala, Kotlin, Groovy, Ant, Gradle, Grails, Maven, SBT, Spark, Spring Boot, Vert.x, and more.

A] INSTALL GITBASH

install git bash

install zip https://gnuwin32.sourceforge.net/packages/zip.htm

copy zip.exe and bzip2.dll from C:\Program Files (x86)\GnuWin32\bin to C:\Program Files\Git\mingw64\bin

reopen git-bash

B] INSTALL SDKMAN

Just launch a new terminal and type in:

$ curl -s "https://get.sdkman.io" | bash        

Follow the on-screen instructions to wrap up the installation. Afterward, open a new terminal or run the following in the same shell:

$ source "$HOME/.sdkman/bin/sdkman-init.sh"        

Lastly, run the following snippet to confirm the installation's success:

$ sdk version        

You should see the output containing the latest script and native versions:

SDKMAN!

script: 5.18.2

native: 0.4.3        

C] INSTALL JDK 21

The usage of SDKMan helps you to manage different Java versions on your machine in a simple way, even the last one.

https://sdkman.io/usage

After installing the SDKMan, you should run:

sdk list java        

Choose what Java 21 version you want to install, in this example, I will use 21.0.1-oracle

sdk install java 21.0.1-oracle        

Then you can set the previous version as the default.

sdk default java 21.0.1-oracle        

(Optional) Or only use that on your terminal

sdk use java 21.0.1-oracle        

Now you can check the Java version in your environment:

java -version        

You should see:

#java version "21.0.1" 2023-10-17 LTS

#Java(TM) SE Runtime Environment (build 21.0.1+12-LTS-29)

#Java HotSpot(TM) 64-Bit Server VM (build 21.0.1+12-LTS-29, #mixed mode, sharing)        

(Optional) If not set your JAVA_HOME in your windows environment variables to 'C:\Program Files\Java\jdk-21'

More

?? install on IntelliJ: https://dev.to/danilopdl/using-java-21-on-intellij-36mm

?? Baeldung: https://www.baeldung.com/java-sdkman-intro.




How to (and how not to) design REST APIs by Jeff Schnitzer

https://github.com/stickfigure/blog/wiki/How-to-(and-how-not-to)-design-REST-APIs

Rule #0: DON'T get pedantic

Don't worry about what is or isn't REST; focus on building pragmatic, useful APIs.

Rule #1: DO use plural nouns for collections

?? GET /products/{product_id}

?? GET /product/{product_id}        

Rule #2: DON'T add unnecessary path segments

?? GET /v3/application/listings/{listing_id}

?? GET /v3/application/shops/{shop_id}/listings/{listing_id}/properties        

The {listing_id} is globally unique; there's no reason for {shop_id} to be part of the URL.

Rule #3: DON'T add .json or other extensions to the url

Rule #4: DON'T return arrays as top-level responses

?? GET /things returns:
{ "data": [{ ...thing1...}, { ...thing2...}] }

?? GET /things returns:
[{ ...thing1...}, { ...thing2...}]        

Rule #5: DON'T return map structures

?? GET /things returns:
{
    "data": [
        { "id": "KEY1", "foo": "bar" },
        { "id": "KEY2", "foo": "baz" },
        { "id": "KEY3", "foo": "bat" }
    ]   
}

?? GET /things returns:
{
    "KEY1": { "id": "KEY1", "foo": "bar" },
    "KEY2": { "id": "KEY2", "foo": "baz" },
    "KEY3": { "id": "KEY3", "foo": "bat" }
}        

Rule #6: DO use strings for all identifiers

Rule #7: DO prefix your identifiers

Stripe's identifiers have two-letter-plus-underscore prefixes.

For customer, it is something like cus_sd9f87gds987, for subscription it is sub_df987gds98fg, for invoice it is in_d98fg7d987fg, and so on. You got the idea.

Rule #8: DON'T use 404 to indicate "not found"

Returning HTTP 404 for "thing not found" is almost like returning HTTP 500 - it could mean the thing doesn't exist, or it could mean something went wrong; the client cannot be sure which.

Rule #9: BE consistent

Please please do your best to keep fields consistent among objects with similar meanings.

Rule #10: DO use a structured error format

My error formats tend to look something like this, roughly shaped like a (Java) exception:

{
  "message": "You do not have permission to access this resource",
  "type": "Unauthorized",
  "types": ["Unauthorized", "Security"],
  "cause": { ...recurse for nested any exceptions... }
}        

Rule #11: DO provide idempotence mechanisms

Rule #12: DO use ISO8601 strings for timestamps

Someone glancing at "2023-12-21T11:17:12.34Z" might notice that it's a month in the future; someone glancing at 1703157432340 will not.

#rest #api #programming #goodPractices #developer




?? Parts of URL:

for example, if we have this URL :

"https : // blog. vvauban .com /blog/be-a-long-life-learner"

Parts of URL:

  1. https :// ?? Protocol
  2. blog. ?? Subdomain
  3. vvauban ?? Second-level Domain (SDL)
  4. .com ?? Top-Level Domain (TLD)
  5. /blog/be-a-long-life-learner ?? Page path

#web #programming #url #urlParts #TIL #vocabulary




???? How did you handle Spring Boot 2.7 end? UPGRADE/ BUY SUPPORT/ DO NOTHING/ NOT CONCERNED

#spring #release #poll #upgrade #springboot3 #java #springboot

Spring Boot end-of-life date??https://endoflife.date/spring-boot

Most of us have upgraded.



BANKING: The numbers on your credit cards are not random! There is a logic behind all credit card numbers.

All credit cards follow the Luhn algorithm:

1. Starting from the first digit, double every alternate digit

2. If the multiplication results in a two-digit number, add both its digits together.

3. Add all these numbers and the digits we didn’t double in Step 1

4. The sum should be divisible by 10

Let’s run it on the card in the image: 5412 7512 3412 3456

Detect fake numbers

Step 1: Result (10)422 (14)522 6422 64(10)6

Step 2: Result 1422 5522 6422 6416

Step 3: Result: 54

As the result is not divisible by 10, it is not a valid card number.

This algorithm is not intended to detect fraud, but only for typing errors. It can detect a single digit error and most adjacent digit swaps error.

Try it on your card!




Multi-Team Backlog Refinement by Cesario Ramos

What is Product Backlog Refinement?

??activity that Scrum Teams regularly do to clarify potential upcoming Product Backlog Items (PBI)

by

  1. Understanding what is the right problem to solve
  2. Splitting big items for discussion and learning
  3. Estimating items for learning and alignment
  4. Understanding Customer needs
  5. Clarify Items
  6. Define Exploratory Test Charters
  7. Create initial designs

?? But how can you do refinement with multiple teams?

refinement with multiple teams

Why multi-team refinement?

Benefits that multi-team refinement can give you:

  • Adaptability at the product level ( because all teams understand all PBIs)
  • Improved self-coordination (the teams know of "dependencies" between PBIs)
  • Transparent measure of progress at the product level (one common velocity at the product level)

How to do multi-team refinement?

So, let's say that there are four teams A, B, C, and D.

Then at refinement, I ask the teams to form four new groups, each group consisting of a person from teams A, B, C, and D.

Why? With groups consisting of members from each team, all PBIs are refined by at least one person from every team.

This creates a shared ownership and broad understanding of the PBIs.

Multi-team refinement formats

?? 0. Full Roulette

Each group picks a PBI for refinement and starts refining at their station.

After a timebox -I like 15-minute timeboxes- all groups move to the next station and continue refining where the other group left off;

this is continued until the PBIs are refined or the workshop timebox expires

1. Partial Roulette

Just like Full Roulette, but instead of the whole group moving to another station, 1 person stays at the station.

This person then teaches the new group what was discussed before they continue with refinement.

?? 2. Diverge and merge

One person stays at each station and becomes the teacher.

Then all groups send a person to each of the other stations. So, let's say you gave groups A, B, C and D.

Then 1 person from group A stays at the station to teach back and 1 other person visits group B, another group C, and another group D.

After the teach-back, the persons return to their original group and share their learnings.

???? 3. Teach Back

Each group picks a PBI and refines it.

After the timebox is over, each group teaches their work so far back to the other teams and has a Q&A discussion.

???? Role of the Product Owner and Customers

The Product Owner has to be prepared and understand what is needed from the business perspective.

The PO will discuss overall topics for example a Storymap and also participate in each group when requested.

#scrum #multiTeam #refinement

Full article ?? https://www.scrum.org/resources/blog/multi-team-backlog-refinement

Learn Scrum ?? https://www.udemy.com/course/professional-scrum-developer-certification-prep-200-question/?referralCode=49CBC321F20A7E381F7C




?? JOKE: variables naming ???

Choosing variable names

In the initial image titled 'Selecting a Variable Name,' a group of individuals engages in a chaotic brawl, symbolizing the challenge of determining the appropriate variable name. Contrastingly, in the subsequent image named 'Selecting a Loop Variable Name,' a gathering of composed politicians sits in a circle, displaying unanimous agreement on the name 'i' positioned at the center of the circle.



Lew Bloch

Software That Fits

1 年

The headline "static inner class" is misleading because the article actually doesn't use that term, thank goodness.

回复

要查看或添加评论,请登录

Vincent Vauban的更多文章

  • ?? Broken Function Level Authorization – API5:2023 ??

    ?? Broken Function Level Authorization – API5:2023 ??

    I'm kicking off a series of articles on API Security ?? to help us—developers ????????—better understand and implement…

  • [VV112] The Java 21 Newsletter

    [VV112] The Java 21 Newsletter

    ????2??1?? Dear followers, let's prepare for Java 21 certification together! 1?? How would you answer this question:…

  • FR Les mots sans les maux. ???

    FR Les mots sans les maux. ???

    FR Hier, j’ai eu la chance d’assister à un atelier sur la Communication Non Violente (CNV) avec les superbes people de…

  • ?? Unrestricted Resource Consumption – API4:2023 ??

    ?? Unrestricted Resource Consumption – API4:2023 ??

    I'm kicking off a series of articles on API Security ?? to help us—developers ????????—better understand and implement…

  • ?? Broken Object Property Level Authorization – API3:2023 ??

    ?? Broken Object Property Level Authorization – API3:2023 ??

    I'm kicking off a series of articles on API Security ?? to help us—developers ????????—better understand and implement…

  • [VV111] The Java 21 Newsletter

    [VV111] The Java 21 Newsletter

    ????2??1?? Dear followers, let's prepare for Java 21 certification together! 1?? How would you answer this question:…

    18 条评论
  • ?? Broken Authentication – API2:2023 ??

    ?? Broken Authentication – API2:2023 ??

    I'm kicking off a series of articles on API Security ?? to help us—developers ????????—better understand and implement…

  • ?? BOLA – The #1 API Security Threat (API1:2023)

    ?? BOLA – The #1 API Security Threat (API1:2023)

    I'm kicking off a series of articles on API Security ?? to help us—developers ??????????—better understand and…

  • [VV110] The Java 21 Newsletter

    [VV110] The Java 21 Newsletter

    ????2??1?? Dear followers, let's prepare for Java 21 certification together! 1?? How would you answer this question:…

  • ?2??4?? Java 24 features with Thiago

    ?2??4?? Java 24 features with Thiago

    (Thanks Thiago Gonzaga ) Here are some insights based on Thiago X content. Java 24: JEP 491 Boosts Virtual Threads! ??…

社区洞察

其他会员也浏览了