• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 228
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Marshal
Posts: 8856
637
Mac OS X VI Editor BSD Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry for not answering to your question, but this is completely useless thing, in my opinion.
 
Marshal
Posts: 79151
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 5465
212
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
M Richardson
Ranch Hand
Posts: 228
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 5465
212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
M Richardson
Ranch Hand
Posts: 228
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 5465
212
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 8856
637
Mac OS X VI Editor BSD Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
M Richardson
Ranch Hand
Posts: 228
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 8856
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I have gone to look for myself. If I should return before I get back, keep me here with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic