Well, having recently sparked an interest in moving towards a Open Source, cross platform, but still as cool as C#/VS2005 development platform, I of course landed in the middle of NetBeans 5.5 and Java.
Having never programmed in Java before, but understanding it's really similar to C# (or I should say C# is really similar to Java), I immediately started fiddling about as if I were writing C# code. So, it's easy to get past typing uppercase String, not lowercase, and also not too hard to grok extends instead of : for inheritance. The one-class-per-file thing, well, I guess it will just make me a more organized programmer, however annoying it is. Actually, I ended up just learning to do the same thing in C#, which has really been better...
But, the things that really erked me was properties.
In C# I can do this:
1// ...
2
3private string _name;
4
5public string Name
6{
7 get
8 {
9 return this._name;
10 }
11 set
12 {
13 this._name = value;
14 }
15}
16
17// ...
but in Java, that looks like:
1// ...
2
3private String _name;
4
5public String getName() {
6 return this._name;
7}
8
9public void setName(string value) {
10 this._name = value;
11}
12
13// ...
Wow. Extremely obnoxious. Furthermore, I have finally gotten myself broken in with the VS2005 IDE to type "prop" + TAB to get a nice template for my properties. Well, since there is no such thing in Java, this macro also does not exist. So, I proceeded to make a NetBeans code template called prop, which functions the same way the VS2005 prop code snippet does.
So, for all you C# coders who are venturing into the foreign lands of Java, here's a little tutorial on how to add this little cultural comfort into NetBeans.
Property Code Template Installation Instructions:
- Select menu item
Tools->Options. - Click on
Editorsidebar button. - Click on
Code Templatestab. - Select
Javafrom languages combo-box. - Click
New, and then enterpropas the Abbreviation in the dialog. - Click
Ok. - Make sure
propis the selected template, and in the text box below the list, enter these lines:
```java
private ${int} ${_prop};
public ${int} get${Property}() {
return this.${_prop};
}
public void set${Property}(${int} value) {
this.${_prop} = value;
}
</code></pre>
<ol start="8">
<li>Select <code>Tab</code> from <code>Expand On</code> combo box.</li>
<li>Click <code>OK</code>.</li>
</ol>
<p>Now you've got it installed... Feel free to go to the code and give it a whirl! Have a look at the other macros in the list to see what's built in, and once you figure out the syntax of the template notation, make your own templates!</p>