[ 
https://issues.apache.org/jira/browse/WICKET-7145?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17924668#comment-17924668
 ] 

ASF GitHub Bot commented on WICKET-7145:
----------------------------------------

jstuyts commented on PR #1093:
URL: https://github.com/apache/wicket/pull/1093#issuecomment-2640771837

   > I'm also unsure about proceeding with this if we don't have a concrete and 
useful final result in mind.
   
   The desired end result would be that for every variable and method in Wicket 
it is known whether it is nullable or not. This may take a very long time to 
achieve. And may even be unsatisfactory: for some situations a client is 
guaranteed that the value will never be `null`, but as there are other 
situations where it can be `null` the variable or method has to be marked as 
nullable.
   
   So the perfect state where you know exactly what is nullable will likely 
never be achieved. Even so, even adding nullable information to the most-used 
types of Wicket will greatly improve the developer experience. Yes, it is too 
bad that nobody took the time to add the annotations to less-used parts. And 
yes, it is unfortunate that a value is marked as nullable that will never be 
`null` because of the way you set things up.
   
   Both issues can be solved: more effort by people who want to contribute, and 
new, more strict APIs and backward-incompatible changes to contracts of 
existing APIs (if acceptable for Wicket users).
   
   In my opinion adding nullability information to even a small number of 
places, makes Wicket easier to use. This will hopefully help convince 
developers that Wicket still is a good choice for front end development.
   
   Note that knowing what is nullable is one of the reason I love working with 
Kotlin: no more going through incomplete documentation, and then through 
multiple layers of code to figure out whether or not I should handle `null`s. 
It saves me so much time. This time saving can also be (partially) realized for 
Wicket developers.




> Developer experience improvement: nullability
> ---------------------------------------------
>
>                 Key: WICKET-7145
>                 URL: https://issues.apache.org/jira/browse/WICKET-7145
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 10.4.0
>            Reporter: Johan Stuyts
>            Priority: Minor
>         Attachments: WICKET-7145.patch
>
>
> Knowing whether a variable can be {{null}} or not, improves the developer 
> experience. A first step is to add {{@Nonnull}} to parameters that are 
> checked for {{{}null{}}}.
> The patch adds {{@Nonull }}to those parameters. The following has been done:
>  * The annotation has been added to base and sub types, and to some overloads.
>  * Conditional nullability has been taken into account.
>  ** In some methods in {{Files}} the client may pass values for other 
> parameters that allows the non-{{{}null{}}} parameter to be {{{}null{}}}. It 
> is assumed that clients do not do this. If a client checks if the 
> non-{{{}null{}}} parameter may be {{{}null{}}}, the client can better skip 
> the call.
> In some hierarchies the handling of {{null}} is inconsistent. The contract of 
> the base method has to be tightened, or the implementations need to be  
> changed to support {{{}null{}}}:
>  * {{{}org.apache.wicket.request.Response.encodeURL{}}}: the annotations has 
> only be added to the implementations in {{ServletWebResponse}} and 
> {{{}WebSocketResponse{}}}.
>  * {{{}org.apache.wicket.request.http.WebResponse.encodeRedirectURL{}}}: the 
> same holds true as above.
>  * 
> {{{}org.apache.wicket.request.mapper.parameter.IPageParametersEncoder.encodePageParameters{}}}:
>  the annotation has only be added to the implementation in 
> {{{}UrlPathPageParametersEncoder{}}}.
> In addition bugs were found and fixed:
>  * The order of the parameters to {{Checks.notNull(...)}} in 
> {{{}OriginResourceIsolationPolicy{}}}.
>  * The order of parameters to {{assertNull(...)}} in {{BaseWicketTester}} and 
> {{{}WicketTesterTest{}}}.
> The patch is quite big, but the changes are small and simple. The changes can 
> be viewed here: 
> https://github.com/apache/wicket/compare/master...jstuyts:wicket:add-non-null-to-parameters



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to