-
Notifications
You must be signed in to change notification settings - Fork 137
Implementation of Attributes-per-Tag via Interfaces #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…efault methods. Drawback: 'get()' method that does nothing, typecasting and many classes and interfaces
Can i get some feedback on this implementation? What bothers me the most is not being able to get a type of the actual class instance when implementing default methods in an Currently the type of the tags is also watered down to the type they are extending when using any attribute methods from the base class. This could be avoided by maybe generifying the ContainerTag. But i wanted to get feedback on this direction first, as there would be quite the number of new classes and interfaces. |
Will have a look tomorrow ! |
Looks fine @pointbazaar. My only concern is it will be a lot to maintain, but if you can manage it then it's fine by me :) |
Well atleast the classes (without the 'implements XYZ' ) themselves could be generated. I think this PR conflicts with PR121 regarding how I'm not well versed with how this would be compiled, but i would assume that generating a method per custom attribute In this PR, only the classes themselves would be generated once, then the interfaces would be added and then further implementation which would maybe require tag-specific implementations would be done by hand. I wonder if there would be enough opportunities to make generating once and then handcoding the rest worthwhile. So far, i only stumbled upon [html, head, body] as candidates which could benefit from custom implementations, as they |
An important consideration would also be that if you have n tags and m attributes per tag, and x methods added to a tag-class for having an attribute, |
maybe the 2 approaches can be mixed, generating both interfaces and tag specific classes that 'implement' those interfaces. |
#121 has been dead for a very long time, so I wouldn't worry about that. You can go ahead without code generation, then switch to it later if it makes sense ? |
…rent tags, and change TagCreatorCodeGenerator to reflect those changes.
Now the classes for the different tags can be generated in their most basic form. |
… This is a step to make it more typesafe. the constructing methods now return a custom type for each tag being constructed.
Now the TagCreatorCodeGenerator will generate methods that return the custom type for each tag. |
…ordingly. Now .withClasses(),... and such return the actual precise type of the tag and will be able to be chained with special attributes later on
… an argument or not.
or
What remains to do:
|
…l elements as specified by w3schools.com
… the rest of the project. These methods should now be generated.
What remains:
|
…properties of some attributes
… of some attributes
…t and which does not.
Probably some special cases have been missed and also some attributes have not even been included here, most of them because of a dash ('-') in their name, which would force me to make some decisions as to how their interfaces and attribute-specific methods should be named. I'm facing some tradeoffs with this PR currently:
However i am confident that this PR in it's current state represents an improvement in type-safety and convenience for users of J2HTML and would like to have it reviewed. It has been going on for too long and has collected too many commits already. |
It's gotten quite big, yeah. I will go through it in the weekend. |
I didn't fully read through the generator code, but the generated code looks good. It would be helpful to add a section in the readme, or create a |
PR is out! |
Great work :) |
…efault methods. Drawback: 'get()' method that does nothing, typecasting and many classes and interfaces