the trailboss abuses his CodeRanch power for his other stuff (power corrupts. absolute power corrupts absolutely is kinda neat!)
permaculture light bulbs permaculture electric heat permaculture cast iron permaculture wood burning stove permaculture solar food dehydrators
The moose likes Meaningless Drivel and the fly likes Less typing in java print statements - Epic Win ! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Other » Meaningless Drivel
Bookmark "Less typing in java print statements - Epic Win !" Watch "Less typing in java print statements - Epic Win !" New topic
Author

Less typing in java print statements - Epic Win !

Andy Jack
Ranch Hand

Joined: Nov 22, 2012
Posts: 257


Bliss !!!



Java Newbie with 72% in OCJP/SCJP - Super Confused Jobless Programmer.
I am a "newbie" too. Please verify my answers before you accept them.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9915
    
158

Modern day IDEs already have a feature where a particular key combination gets you that, without you having to type all of it.


[My Blog] [JavaRanch Journal]
Andy Jack
Ranch Hand

Joined: Nov 22, 2012
Posts: 257
Jaikiran Pai wrote:Modern day IDEs already have a feature where a particular key combination gets you that, without you having to type all of it.


Ok, how do i enable that on my eclipse ? I don't see anything when i type Sys...It starts appearing only when i type System.
After that, there is more selection and pressing keys.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9915
    
158

Andy Jack wrote:
Jaikiran Pai wrote:Modern day IDEs already have a feature where a particular key combination gets you that, without you having to type all of it.


Ok, how do i enable that on my eclipse ? I don't see anything when i type Sys...It starts appearing only when i type System.


I'm on IntelliJ these days, but from what I remember, you have to just type sop and then Ctrl+Space (or whatever the auto completion key combination is).
Andy Jack
Ranch Hand

Joined: Nov 22, 2012
Posts: 257
Jaikiran Pai wrote:
I'm on IntelliJ these days, but from what I remember, you have to just type sop and then Ctrl+Space (or whatever the auto completion key combination is).


Why do you use intellij ? Is eclipse and netbeans not good enough for you ?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9915
    
158

Andy Jack wrote:
Jaikiran Pai wrote:
I'm on IntelliJ these days, but from what I remember, you have to just type sop and then Ctrl+Space (or whatever the auto completion key combination is).


Why do you use intellij ? Is eclipse and netbeans not good enough for you ?

Personal preference.

Jaikiran Pai wrote:
I'm on IntelliJ these days, but from what I remember, you have to just type sop and then Ctrl+Space (or whatever the auto completion key combination is).

Actually, turns out it is sysout and not sop (see here http://www.makeuseof.com/tag/8-keyboard-shortcuts-beginner-eclipse-ide-users/)

Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2271
    
  28

Andy Jack wrote:
Jaikiran Pai wrote:Modern day IDEs already have a feature where a particular key combination gets you that, without you having to type all of it.


Ok, how do i enable that on my eclipse ? I don't see anything when i type Sys...It starts appearing only when i type System.
After that, there is more selection and pressing keys.


Hit Ctrl+space at anytime and eclipse will popup auto suggest for you. If there is only one option it will fill it for you. You can even setup macros (forgot what it is called exactly) so if you type sop Ctrl space, it will convert it into code for you
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Another option is



which lets you type all sorts of things:



This has the (arguable) advantage that the actual source code is less wordy. Sometimes this could make your code clearer, although other times it might be considered confusing.



[Jess in Action][AskingGoodQuestions]
Andy Jack
Ranch Hand

Joined: Nov 22, 2012
Posts: 257
Ernest Friedman-Hill wrote:Another option is



which lets you type all sorts of things:



This has the (arguable) advantage that the actual source code is less wordy. Sometimes this could make your code clearer, although other times it might be considered confusing.


Thanks. But thats still long - sopln(arg) < out.println(arg). Actually, I use sopln for debugging and i have many debug statements that i keep on removing and adding.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

You can, of course, use a debugger for debugging!
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3606
    
  60

Ernest Friedman-Hill wrote:You can, of course, use a debugger for debugging!

Or set up a logging system that you can configure without a need for recompiling (such as log4j). I'd say this is a handy tool, since the logging statements remain in the program and can be turned on or off as needed, even in production.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60749
    
  65

In other posts you have seemed concerned with how things would reflect on an employer, so I'll let you know that if you were on my team, this would be an epic fail!

Adding superfluous wrapper methods around existing methods -- especially those that are widely used and understood -- just to "save typing" would not fly on my watch. Extra cruft is bad. It's a bug waiting to happen, and it's confusing to everyone else.

As has already been pointed out, it's an IDE's job to make writing code easier, not adding extra goop to the actual code.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Andy Jack
Ranch Hand

Joined: Nov 22, 2012
Posts: 257
Bear Bibeault wrote:In other posts you have seemed concerned with how things would reflect on an employer, so I'll let you know that if you were on my team, this would be an epic fail!

Adding superfluous wrapper methods around existing methods -- especially those that are widely used and understood -- just to "save typing" would not fly on my watch. Extra cruft is bad. It's a bug waiting to happen, and it's confusing to everyone else.

As has already been pointed out, it's an IDE's job to make writing code easier, not adding extra goop to the actual code.


Ok, i get the point. It makes the code confusing and bloated (wrapping). Thanks for letting me know.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11150
    
  16

Bear Bibeault wrote:[I]f you were on my team, this would be an epic fail!

Couldn't agree more.

Consider that you spend more time debugging code than writing it in the first place, I would think any time saved with this 'trick' would be lost by others trying to figure out what "sopln" does.

Also, I have types System.out.println() so many times, it's like typing hello or rosenberger - I don't think about the individual keys...my fingers just know what to do.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4646
    
    5

Not to pile on, but I agree, this "shortcut" is a really bad idea.

A major part of writing code is to communicate to the human who reads it six months after you wrote it. Your local/custom stylings obscure what is an instantly recognizable idiom: System.out.printXX causes printing on the console. No one knows what your idiom does, until they slog through your code to find the method.
Manoj Kumar Jain
Ranch Hand

Joined: Aug 22, 2008
Posts: 191

If you just type "syso" and hit Ctrl+Space it will write the complete System.out.println();
It works for me.


Do not wait to strike till the iron is hot; but make it hot by striking....
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60749
    
  65

That is specific to your IDE; it will not work for everyone. Most IDEs will allow such shortcuts to be defined.
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2833
    
  11

You may have just been born too late Andy. I remember grizzled old programers showing me how to alias ls to l and cp to c in order to save keystrokes. Java tends to discourage abbreviations though, which I like because it means I don't have to remember how someone chose to abbreviate something. Was that variable called mgr, mngr, or man? With IDEs to take up the tedium of having to type things out, there's really no need to abbreviate anyway. As long as I'm on a soapbox, let me say this. You'll never regret time put in to learning how to use your tools well. The templates (like sysout) in Eclipse can save you a lot of typing, and you can even define your own. Learning how to use a debugger well is much more effective than using printlns everywhere, and real logging is better than printlns as well. These things take a certain investment to learn, but they pay great dividends.
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2271
    
  28

Greg Charles wrote:You may have just been born too late Andy. I remember grizzled old programers showing me how to alias ls to l and cp to c in order to save keystrokes.


I remember using C macros for printing logging statements *shudder*
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60749
    
  65

I remember well the chaos resulting from everyone defining their own macros.

At one company, we instituted a group-wide C macro "library" that only the senior developers could add to. No one was allowed to define their own, so everyone used the same macro set.

Earlier, when I was working for DEC, we used a language called BLISS, which had a very powerful macro capability that put the macro facility in any other language to shame. The downside was that everyone used it to basically set up their own DSL. So code written by any developer looked like a completely different language than anyone else's. This was decidedly not A Good Thing™.
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4646
    
    5

Bear Bibeault wrote: DEC, we used a language called BLISS, which had a very powerful macro capability that put the macro facility in any other language to shame.

Almost true. Its macro facility was based on the macro facility in the PDP-10/PDP-20 assembly language that was named, Macro-10. It had an amazing macro facility that was used everywhere by systems programmers. When the "use Bliss or die" directive came down, they had to provide similar in Bliss to bring the systems programmers along.

Bliss' was good, but not quite as powerful as Macro-10.

It took very strong technical management to control the wild home-grown-DSL in both Macro-10 and Bliss.
 
wood burning stoves
 
subject: Less typing in java print statements - Epic Win !
 
Similar Threads
flush JTextArea immediately
Why inner classes cant have static memebers
What good are interfaces?
convert pseudo code to java
Creating and using exceptions