This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to create an auto-generated "class structure stub" in Eclipse?  RSS feed

 
Mark Richardson
Ranch Hand
Posts: 104
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As something who is learning Java, I would like that every single class I create has the following comments inserted into it automatically:



is this possible?
 
Liutauras Vilda
Marshal
Posts: 4783
330
BSD
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sorry for not answering to your question, but this is completely useless thing, in my opinion.
 
Campbell Ritchie
Marshal
Posts: 56187
171
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Liutauras is right; it is not going to help you.
Window→Options→Formatter→Templates. That is probably wrong, but it will give you a start.

Moving to our IDEs forum.
 
Piet Souris
Rancher
Posts: 2014
71
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For bigger classes I use a similar structure.

You can create such a template in Eclipse (Luna) as follows:

1) in the Menu Bar above, choose 'Windows', then 'Preferences', 'Code Style', 'Code Templates', and then in the bigger panel in the middle, 'Code', 'Class body', click the 'Edit' button and type in your desired structure.
2) That's all
 
Mark Richardson
Ranch Hand
Posts: 104
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Liutauras Vilda wrote:I am sorry for not answering to your question, but this is completely useless thing, in my opinion.


In Robert Cecil's book on Clean Code, he stresses that classes and methods must be small.

Hm so, I'm guessing the reason this practice will be useless to me is that if I follow "clean code" conventions, I wouldn't really need to "label" my class? is that why? because everything will be small and managable, to begin with?
 
Piet Souris
Rancher
Posts: 2014
71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, what is small and what is large? At the moment I write my 'bigger' classes like this, and I'm pleased with how it looks:
 
Mark Richardson
Ranch Hand
Posts: 104
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Piet Souris wrote:Well, what is small and what is large? At the moment I write my 'bigger' classes like this, and I'm pleased with how it looks:



Out of curiosity, do you actually add those comment labels to each section of your classes, or did you just do that to clarify to me visually? And, is it a good practice to do this? Also, will I be laughed at in a workplace if I label my classes like this?
 
Piet Souris
Rancher
Posts: 2014
71
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The example is exactly how I write my classes today. And yes, whenever you do something unusual, be prepared to be stared, pointed and laughed at. The class here is just one of my library classes, and so is not subject to any company coding rule.

As Liutauras wrote, it helps you no single bit with coding. I started to experiment a while ago, since I always liked the way the VBA editor works, by drawing lines between methods. I also have a dedicated comment for inner classes and yet another special remark for when I have additional classes in my file.

Well, look at it and decide if you like a set up like this. I did not know that you could make a template for these things in an IDE, so thanks for bringing this subject up.
 
Liutauras Vilda
Marshal
Posts: 4783
330
BSD
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@OP

Probably the task is to become a character, who can solve problems and be recognised in some sense. If you add such comments as Piet or not, this doesnt really matter, that will be judged only depending on how you are able to solve your core problems at hand.

Have you noticed? Nobody judged Piet on his paintings - thats because we have some extensive knowledge about him.

So, the task is, to become a good problem solver.
 
Mark Richardson
Ranch Hand
Posts: 104
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Liutauras Vilda wrote:@OP

Probably the task is to become a character, who can solve problems and be recognised in some sense. If you add such comments as Piet or not, this doesnt really matter, that will be judged only depending on how you are able to solve your core problems at hand.

Have you noticed? Nobody judged Piet on his paintings - thats because we have some extensive knowledge about him.

So, the task is, to become a good problem solver.


This is off topic but I just want to thank you all for taking the time out to guide me and asking for nothing in return. I don't know any of you personally, but this act alone makes you amazing human beings in my eyes. Thank you.
 
Liutauras Vilda
Marshal
Posts: 4783
330
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sorry if I went off topic, didnt want to

So yeah, you can achieve what you want with IDE, but that isnt a game player as everybody else pointed out.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!