Skip to content

I reduced boilerplate - #1277

Closed
Guthib-of-Dan wants to merge 1 commit into
uNetworking:masterfrom
ublitzjs:code-structure
Closed

I reduced boilerplate#1277
Guthib-of-Dan wants to merge 1 commit into
uNetworking:masterfrom
ublitzjs:code-structure

Conversation

@Guthib-of-Dan

Copy link
Copy Markdown

As the name suggests, why suffer? I did following changes for DX within C++ codebase:

Made Utilities.h central header-file (clangd LSP sees Http3 functonality in every file). Basically I put #include <v8.h> #include "App.h" #include "Http3App.h" using namespace v8 into Utilities.h;

renamed PerContextData to PerIsolateData. In fact, this struct is local to each V8 instance, which is Isolate. If it is "per isolate", why not be "PerIsolateData" ?;

replaced 'const FunctionCallbackInfo&' onto 'args_t'. Name is self-explanatory (type for arguments), much easier to write;

reduced boilerplate in 'init' functions. I put registering functionality into lambdas, so they don't live on the global stack and this saves tons of effort when trying to figure out what code does.

So while I have a draft for build improvements, I have also made a draft for C++ DX + type-safety (coming in subsequent PRs). This is the first pull request. Again, it compiles with old build and with build.exe from my other pull-request.

@uNetworkingAB

Copy link
Copy Markdown
Contributor

Renaming the raw, explicit v8::FunctionCallbackInfo<Value> into some generic args_t is at best subjective opinion, not an improvement. You might as well just put "auto" there or T, if you want generic non-descriptive types.

renamed PerContextData to PerIsolateData. In fact, this struct is local to each V8 instance, which is Isolate. If it is "per isolate", why not be "PerIsolateData" ?;

Again, this is just subjective opinion. And it ignores the fact this library is older than the introduction of "Isolate" naming in V8. PerContextData is perfectly fine as is.

I have looked at both your PRs and they both have the same problem - you mix arbitrary refactorings with functional changes. An arbitrary refactoring PR is problematic alone, but an arbitrary refactoring PR mixed in with subtle functional changes is frankly unmergable.

If you find a single functional fix - make that, and only that, a separate PR that tries to make as minimal change as possible.

If you have opinions on formatting or style, make a PR that only performs that style change (literally nothing else). Ideally, you should also provide some verifiable proof that the style change is identical to the original (such as providing a proof of the style rules you applied into clang-format so that I can confirm that you did not introduce functional changes).

Your PRs have the style of "here is my playground, I have done this and this and this, some of it is functional change, some is subjective" - that kind of PR is impossible to deal with.

A PR needs to be surgical, only change what is necessary for your fix and provide reason why the fix is even necessary (such as the setbuf thing in your other PR - provide proof of its usefulness)

@uNetworkingAB

Copy link
Copy Markdown
Contributor

Git is a crime scene - the less you can move things around while still getting the job done, the better. That's why any kind of refactoring is bad alone - but a refactoring that ALSO changes functionality in subtle ways is very bad (I'm mainly thinking of your other PR). When you change lines that aren't necessarily changed, you damage the ability to easily backtrack if something breaks. That's why not changing something that does not need to change is better than doing it just because it can be changed.

There is also the social friction component - changing things based on subjective opinion assumes that your opinion is heavier than others (or that the original author does not know how to wrap things). You aren't following the social convention of "when in rome do as the romans do".

@Guthib-of-Dan

Guthib-of-Dan commented Apr 21, 2026 •

Copy link
Copy Markdown
Author

Alright, understood. So in this particular PR, only lambdas have any use? And also that you mentioned other PR has some kind of functionality change. You mean the fix of MacOS 12 additional option? That's why it is still "hanging"?

@Guthib-of-Dan

Copy link
Copy Markdown
Author

Then I have to make even more niche PRs. I close this one and that.

@Guthib-of-Dan

Copy link
Copy Markdown
Author

Thanks for patience

@uNetworkingAB

Copy link
Copy Markdown
Contributor

I think what you are missing is you look at the source file as a whole and say "this file now looks fine, it is how I want it", make a PR of it. Rather than look at the PR itself and say "this diff looks surgical & reviewable". You can use "git add -p" to produce surgical PRs

…ity in every file); renamed PerContextData to PerIsolateData (it has more meaning); replaced 'const FunctionCallbackInfo&' onto 'args_t'; reduced boilerplate in 'init' functions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants