How do you make coding easier to yourself?

I am interested what thing do people do to make coding easier and faster.

I have found out that good IDE like Netbeans can make things done much faster (maybe about 5 to 10%) and some nice simple methods can also help. For example I like to include following small method to all my projects to avoid typing System.out.println(String s) dozens of times in my project:


public void ps(String s) // ps = print string
{

System.out.println(s);

}

This way I just need to type ps(someString); anytime I need to print something. Does anyone else like to make things easier to yourself and how you do that? One dude once said that he has a principle that coding must be hard and he didn’t want to learn to use advanced Ides that JEdit. I don’t like to think that way. :stuck_out_tongue:

In Eclise you type

syso[CTRL][SPACE]

And it replaces it with

System.out.println(|);

You might ask, why [CTRL][SPACE], well, in Eclipse can you do ‘everything’ with that combo.

These days an import static might be the way forward there.

Cas :slight_smile:

Advanced IDEs make writing, navigating and refactoring code much faster than using a simple text editor (not necessarily easier - the hard thing about programming is not writing the code, but knowing what code to write). It would be unprofessional to not use the best tools available (I use IntelliJ IDEA). You also need to know how things work in the grass-root-level, so that you can work things when they fail, but under normal circumstances you don’t want to waste your time doing repetitive things that can be automated.

The thing that has had the most impact on my coding is TDD - it turned upside down the way I approach writing code. For me, it has made programming more fun, because it gives a quick sense of accomplishment and progress when you see new tests pass, and it lets me do more OO design and use more design patterns, because writing testable code requires decoupling the code elements. Also I spend less time debugging the code and searching for nasty bugs, because I have a good test suite which finds 99% of them, and it allows me to refactor the code without fear of breaking something.

Eclipse has other simple templates like this, too - for example, type for[CTRL][SPACE], hit enter, and it creates a for loop that you can fill; fore (or foreach if you’re not as lazy as I am) gives you an advanced for loop that iterates over a collection. If you have the IDE set to automatically insert best-guess variables (set in Preferences->Java->Editor->Content Assist, it’s off by default I think - try it out, but be aware some people really find it annoying), it will even take a guess as to what you want to iterate over. A lot of times this is correct, and it saves a bit of time. If you go to Preferences->Java->Editor->Content Assist->Templates, you can see all the available templates, and even define your own if you find pieces of code you tend to need often.

Learn all the key shortcuts you can, also - one of my favorites in Eclipse is the organize imports command, which at least on OS X is shift+cmd+o, and handles all import statements based on the classes it looks like you’re using in a file. It’s probably been years since I’ve even thought about an import statement, I just hit that key combo reflexively every time I see a syntax error and it often fixes it by importing the right classes.

I’ve been using XCode lately for iPhone development and as a result I can tell you what you can do to in order to not go faster… obviously the answer is to use XCode.

There are so many ultra irritating things about it that really waste my time a lot. Like say I had this:


guy.foo (
               5,
               56456.56,
               23423,
               56776,
               2342
          );

XCode will constantly try to adjust the indenting for you to absolutely inane results. It’s just awful at lining things up, and it will adjust it as you type, not only when you go to a new line. In addition it doesn’t have a nice drop down menu of available functions like Eclipse does (like if you say System.our.pr on Eclipse and wait a moment a menu appears with all the possible options using those letters), instead it just starts doing a variable autofill. Trouble is when you’ve got overloaded methods or similar variable names then it magically is almost always able to fill in the absolute wrong option. So say I have guyLife and guyDeath as two variables, and I want to use guyLife 5 times in the same method. Guaranteed, as you start typing guy, the filled in option will be guyDeath. Similarly whenever you want to use guyDeath guyLife comes up.

What’s even worse about their autofill is that it doesn’t quite seem to know when to stop or start. It appears that it has a stopping function similar to when you press tab in Unix - it will fill in everything it can until it has a conflict with multiple names. So theoretically I would type g, press return, and it would type out guy. Then I could type either an L or a D and press return again to get either guyLife or guyDeath. Instead, it might do something like this: I type g, press return, and it types out gu. So I type the y and press return and then it types guyLife. Literally at the stupidest and most random places possible it will just stop autofilling. Only have one variable called thingILikeToDo? Type in thing, press enter, and it might fill in thingILik. Then press enter again and thingILikeTo. Then again for thingILikeToDo. Just doesn’t make sense, and wastes all kinds of time.

Not to mention other stuff like pressing delete when your cursor is flashing in your code but your focus is actually in your file browser… it will remove the file from your project immediately, no chance of using Undo or anything. Your only option is to drag it back from your filesystem. And when you actually want to delete a file, you can’t unless you do it physically from your file system.

And the default way of referencing files is absolute path, so forget using source control unless you make the paths to your projects the exact same on every machine. You can make it relative to the project’s location (i.e. local) but only if you remember to select that from a drop down box every single time you make a new file or add something to your project. Awesome.

Anyway, I rant. I could go on basically forever.

http://www.xcodesucks.com/

Use Eclipse and be happy. :slight_smile:

Pfft, you still use the shortcut? I’ve set eclipse to organise imports (and do a source format/clean up) every time I save.

ctrl][space] also does ‘organize imports’. Just press it at the end of the class name

Am I the only one who uses NetBeans? Does professional coders laugh at NB users always when they open eclipse? ??? I once installed eclipse about two years ago but I think something happened and it didn’t start or something… Anyway I have different computer, OS etc so I guess I’ll give it another try. I think I won’t abandon NetBeans because there is some nice plugins that help me a lot. However I’ll download eclipse now.

About that Xcode thing… It sounds very Apple! I downloaded Safari once and there was some autocomplete things that actually slowed me down.

no, professional coders don’t laugh about tools…

Netbeans is very good ide and has been imporoved dramaticly over past few years. It has a keyboard shortcut for System.out.println ;), just type sout[tab]. For more shortcuts check Help->Keyboard Shortcuts(or something like that).

Oh dear. :o I didn’t know that netbeans had shortcuts (except alt+enter to do autoimports and implementation of abstract methods) nor I knew that eclipse had them either before reading these posts. I guess I might save some time on long run if I would watch some tutorials or read help contents. :persecutioncomplex: So far I have only set things that can be set from tools --> options. :-\

Yeah, I have organize imports on save, but the source clean up tends to bother me - there are times when I want to violate some of the formatting rules, and it’s kind of annoying to have my changes undone every time I save. :slight_smile: So I shut that one off a while ago…

Cool, never realized that before!

Re: Netbeans, I finally took another look at it recently and it looks like it’s definitely on the same level as Eclipse or IntelliJ (though IntelliJ users will claim that nothing approaches IntelliJ, a claim that I’m in no position to comment on…); some of the plugins are real nice, though I’d miss a lot of mine from Eclipse. I suspect the main reason more people don’t use NetBeans is that in its earlier days it kind of sucked (to put it lightly), so a lot of people locked in to Eclipse and are now too used to it to consider a switch.

And re: XCode, it’s an absolute abomination even for Objective C, which is what it’s mainly used for; and for any other type of programming? Pain, pure and simple. For anyone that has to suffer through using it: escape is the rough equivalent of ctrl+space in Eclipse, though it doesn’t do very much, and what it does do it only does sometimes and at varying levels of correctness, depending on your computer’s mood, the phase of the moon, and whether or not you are working on a deadline. And don’t even get me started on Interface Builder…yeesh.

If I remember correctly, mr. Gosling himself was developing netbeans some time ago (I read about it somewhere I think.) someway so maybe that has taken nb so fast ahead or maybe I just saw a dream.

i heard Chuck Norris got commit rights since NB 6.0 which would be the main reason for the rapid quality improvements.

I heard Michael Biehn from The Terminator was developing somekind of plugin to netbeans.

Anyway I see your point. I shouldn’t comment when I am tired.

Good IDEs do not boost productivity about 5 to 10% - it’s more about 100% to 500%. NetBeans (as well as Eclipse and Intellij) has a ton of productivity features. Take your time and try out every menu entry. Look at the Keyboard shortcuts unter Tools->Options->Keymap, look at the editor abbrevations under Tools->Options->Editor->Code Templates (you can even make your own for any supported programming language) and see the macros under Tools->Options->Editor->Macros.

Also try the Debugger, try the Profiler and work yourself through some articles on http://www.netbeans.org/kb/index.html.

You might uncover unexpected possibilities :slight_smile:

I am a long time Intellij user at work, so I edited my keyboard shortcuts in Netbeans to mimic Intellijs. Some weeks ago I had a visit of a co-worker and we were discussing and coding a bit on my engine. After a couple of minutes he shouted out “Hey, I just this second noticed this is Netbeans - every feature I am accustomed to just worked”. There is not much room for Intellij and I think they are on a bloat roadmap currently, which undermines the strenths they once had.

I heard Michael Bean, secret son of Mr Bean has interest in computer graphics :wink:

All 3 IDEs just mentioned are brilliant - pick the one you like the most and you’ll be coding even up to 10x faster.

Chuck Norris has two speeds: walk and kill.

Cas :slight_smile:

Aye. Open Declaration (F3 in eclipse) and Find References (control+shift+G in eclipse) have saved me muuuuch time.
Hierarchy (F4) is pretty awesome as well.

When doing those GUI things IDEs definitely boost productivity 100% to 500% or even more but in some cases its not that much (well those numbers ofcourse depends on that how you define “productivity”). However within last two days I have learned a lot about NB and I think I will keep going with it (“don’t fix it if it ain’t broken”).

I have read that Chuck Norris’s strenght was his kicks (I’m serious, it was in Black belt magazine that I read in library). ::slight_smile: