Skip to content
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

Support scaffold Spring Boot components #767

Open
jdneo opened this issue May 23, 2023 · 7 comments
Open

Support scaffold Spring Boot components #767

jdneo opened this issue May 23, 2023 · 7 comments
Labels
Discussing enhancement New feature or request

Comments

@jdneo
Copy link
Member

jdneo commented May 23, 2023

i.e.

Automatically command palette/modal triggers and ask you for the entity name which will be applied in the following generated files inside they respective folders: Controllers/[EntityNameController.java] || BusinessLogic/Services/ServiceImpl [EntityNameServiceImpl.java] || BusinessLogic/Services/ServiceInterfaces[EntityNameService.java] || Models/Repositories/[EntityNameDao.java] || Models/Entities/[EntityName.java]

Maybe need some integration tasks to do with the spring extension.

@jdneo jdneo added enhancement New feature or request Discussing labels May 23, 2023
@BizarreBoy
Copy link

Hi!

Following with the scaffold idea, I would like to attach some screenshots.

In the first picture I created by hand a sample bunch of directories with one file inside each one related to the function they were created for. (Imagine it has been generated with a context menu item named for example "Generate Initial Java Scaffold API" supposing I right-clicked in the named "rest" folder of the following image example):

image

The feature should open a command palette modal and ask to the user what will be the entity name to be applied in any related file generated, for example: SampleNameEntity, SampleNameController, SampleNameService, SampleNameDTO,...

ss02

The initial code by default could be empty methods with the params names replaced by the required entity name from before:

NOTE: In the following pictures you will see default templates generated by the plugin Spring Code Generator developed by the author Sonal Sithara. His plugin saves a lot of time typing general methods and let user focus on the logic development and not in the code structure.

CONTROLLER:

image

SERVICE IMPLEMENTATION:

image

SERVICE INTERFACE:

image

REPOSITORY:

image

ENTITY:

image

RESUME: The idea would be a context menu option which open a command palette modal to insert the shared EntityName. Then the tool will create the required mkdirs and generate inside of each one the file templates according to each folder functionality.

BONUS: Would be great a second modal question for the user before to start generating the scaffold (optional) which ask for Lombok Dependency integration and generates the initial entity template according to this choice.
I mean: [NO] getters and setters generated typed in the code || [YES] just lombok annotation like @Data/@Getter/@Setter/@AllArgsConstructor.

@jdneo
Copy link
Member Author

jdneo commented May 24, 2023

Thank you @BizarreBoy for providing those detailed information.

BTW, just for asking, do other Java IDEs/tools provide feature similar to this one? If there is, we can take a look and make it as a reference.

@BizarreBoy
Copy link

Glad to help you, @jdneo !

In my experience I have been a user of Eclipse IDE, Vscode and IntelliJ and I didn't find any similar tool.

However the idea is not too different from the initial "java create project" feature where the palette command makes few questions before to start generating.

The main idea of feature I suggested you is based on a vscode plugin dedicated to Angular developers named "Angular Schematics" developed by Cyrille Tuzi.

image

It works exactly how I described you in my first comment and makes sure the user respect a logic project structure from begining to end. Generates the minimun and necessary starter templates to develop from zero just right clicking in the choosen root directory.

image

image

Let me know if the attached references could help you.

@jdneo
Copy link
Member Author

jdneo commented May 24, 2023

Thank you. The idea is clear. But we need to think more about how to make the generated structure be suitable to users project as much as possible. (or, make it be easy to configure/customize)

@BizarreBoy
Copy link

I agree, in my opinion we could take the angular schematics plugin as reference.
With just one click and a command palette question it quickly creates the starter scaffold of a new component with a few files related with each other.

@jdneo
Copy link
Member Author

jdneo commented May 25, 2023

There are two options in my mind now:

  1. You mentioned the extension Spring Code Generator, which I took a very quick glance on that and looks very nice. We can consider contributing to that extension and let it hook those command to the Java Project explorer, then as long as user installs the Project Manager extension and Spring Code Generator, they can see those actions in the context menu.

  2. Leverage Copilot to scaffold the template. I just tried it in Copilot Chat and the result looks promising 😁
    image

@BizarreBoy
Copy link

Wow!!! Amazing job by copilot!

And yes, Spring Code Generator works similar, the only thing it doesn't create is the folder structure and only generates files one by one which is comfortable in most scenarios but a bit annoying when user has to create a full APIREST from zero.

This is the reason why I focus on Angular Schematics reference. But it's true that Java Scaffold should work different because Springboot users need the main scaffold just one by project/microservice: Controllers | BussinesLogic [ Services | Interfaces ] | Models [ Entities | DTO | DAO(Repositories) ].

Once the main scaffold is created, the tool should work exactly as Spring Code Generator plugin and add the other templates one by one as the user needs.

Let me know your opinion about the functionality/workflow I described you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussing enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants