Part of the design philosophy of the Class Viewer project is getting the best method you need for a particular object or to return a particular object, where I also like to warn that one problem with that philosophy is that there is a drop in emphasis, oddly enough, in actually memorizing all the methods associated with a class.
Understanding how powerful Class Viewer is in searching for the perfect method is best done by seeing it in action, where my favorite example is to use the String class, which gives the main screenshot for the Class Viewer project, where you need to know what methods take chars or return them. Using Class Viewer now I can copy and paste to show them:
static String valueOf(char[])
static String valueOf(char[],int,int)
static String valueOf(char)
char charAt(int)
boolean contains(CharSequence)
boolean contentEquals(CharSequence)
static String copyValueOf(char[])
static String copyValueOf(char[],int,int)
byte[] getBytes(java.nio.charset.Charset)
void getChars(int,int,char[],int)
static String join(CharSequence,CharSequence[])
static String join(CharSequence,Iterable)
String replace(char,char)
String replace(CharSequence,CharSequence)
CharSequence subSequence(int,int)
char[] toCharArray()
And that's it. Everything that can possibly give or receive a char in the entire String class, so if you're developing and wonder if there is anything else, nope, not in the String class. That's it. And I did a search on "char", highlighting a method that had "char" from the left window of the app.
But hey, there is another class that can handle chars which is StringBuilder, and yes, you DO need to keep up with knowing classes, just not the methods in them, so it pushes you to only know your classes, as you can just pull out which method you need based on what you will hand them, and what you want them to give back to you.
That is key to the design philosophy: what thing do I have that needs to be given to a class and what do I need it to hand back to me?
Now if you open StringBuilder in Class Viewer you may notice--as I did while pondering what to say in this post--that it has a LOT of methods with "String" in them. But let's say I only want methods that receive just a String, here they are:
AbstractStringBuilder append(String)
StringBuilder append(String)
int indexOf(String)
int lastIndexOf(String)
And that's it. There are no other methods (of course I'm only talking public methods) which will take just a String, and how did I achieve the feat of finding them? I did a search on a method in the left window, highlighting "(String)". That's the easy way. To get just those methods using the "Search String" box in Class Viewer you actually have to search on: (java.lang.String)
You can get fancy searches by what you highlight and search on from the left window, like here's a fun one: "String "
It gives:
String toString()
String substring(int)
String substring(int,int)
And those are all the methods in the StringBuilder class that return a String. That one is kind of tricky as I actually highlighted whitespace, which you can only do with searches on the left hand window. But that can be a very powerful tool. So it's important to emphasize that whatever you highlight in the left window is what is searched, even special characters, like whitespace.
But notice if you were wondering how to get a String from StringBuilder those are the only ways.
Curious about any one of them? Then double-click on the method in the right hand window, and you get taken to javadocs. Here's the link that Class Viewer built for me for the third one:
http://docs.oracle.com/javase/8/docs/api/java/lang/StringBuilder.html#substring-int-int-
Which is the final piece to helping you get the best method possible as if you have questions you can go directly to javadocs at the method, which I call deep linking.
So the focus is on what you want the class to give you. Or you can focus on what you wish to hand the class and that is where Class Viewer can help you a lot.
Results above valid with Java 8 SDK.
Editorial notes:
9/27/12 Updated built link to go to latest Java SDK. ___JSH
7/08/14 Updated copied searches and built link to go to latest Java SDK. ___JSH
Blog ran by me, James Harris. Innovator using meta process analysis. Where ideas rule. Reference site for age of Intelligence.
Translate
Sunday, April 11, 2010
Friday, November 27, 2009
Class Viewer as an applet
Oh yeah, you can run Class Viewer as an applet. For a while I did have it up at my SourceForge site as an applet but I wasn't sure that was ok, and didn't want it to turn into some kind of reference site.
But anyone can just throw it on a webpage, maybe with their own code's javadocs bundled up in the jar file so that they can access their class information from the web.
Class Viewer is a hybrid app--it runs on the desktop or on the web, with less functionality from the web.
I think hybrid apps are the future of app development.
But anyone can just throw it on a webpage, maybe with their own code's javadocs bundled up in the jar file so that they can access their class information from the web.
Class Viewer is a hybrid app--it runs on the desktop or on the web, with less functionality from the web.
I think hybrid apps are the future of app development.
Saturday, August 22, 2009
Handling low light, two camera review from Pogue
Link above goes to: The New York Times
Quote from the Source:
An interesting review from David Pogue, which has good information about sensors. I'm putting this up partly as a reference for myself later for when I might pick up a camera good in low light as I have been frustrated trying to take nighttime city-scape shots of San Francisco.
Quote from the Source:
STATE OF THE ART
Low Light Becomes a Highlight
By DAVID POGUE
Published: August 20, 2009
New cameras from Sony and Fujifilm come with redesigned sensors that mark an important step forward in personal photography.
An interesting review from David Pogue, which has good information about sensors. I'm putting this up partly as a reference for myself later for when I might pick up a camera good in low light as I have been frustrated trying to take nighttime city-scape shots of San Francisco.
Labels:
technology
Sunday, July 05, 2009
Fun Twitter game for bright people: perfect tweets
Because Twitter has the rule of 140 characters or less for a tweet an obvious and fun game is to produce perfect tweets, defined to be 140 characters exactly, but that's not enough as here is a perfect Tweet that I tweeted earlier today to my Twitter:
In my opinion, crucial criteria for a perfect tweet is that it be EXACTLY 140 characters, have few if any abbreviations, and is grammatical.
That tweet is 140 characters exactly and is (um, I'm fairly certain), grammatical.
Ok, updating as I got in an argument over this subject, so have a variant to handle both cases in case it turns into some kind of major thing:
In my opinion crucial criteria for a perfect tweet are that it be EXACTLY 140 characters, have few if any abbreviations, and is grammatical.
And later I found another...
The perfect tweet must have the following conditions: it must be 140 characters, be grammatically correct and have few if any abbreviations.
I'm curious, how many tweets on Twitter on any given day are perfect by those rules?
Here's one more perfect tweet:
My wild guess unsupported by inside information is that YouTube is now profitable. If so congratulations Google, and what took you so long?
I will admit that I don't in general try to make my tweets perfect but will if I see one approaching perfection work at it if I can, briefly to see if I achieve that, but if not, it's not a big deal.
But how hard can it be? I have one more perfect tweet:
Ok, I've locked down both variants of the "perfect tweet" which defines itself as perfect within the tweet while also being a perfect tweet.
That tweet is perfect.
(Hmmm...editing yet again to wonder, how many times can you use the phrase "perfect tweet" in a tweet which is itself perfect? I've managed twice above, can anyone do better?)
But when it happens I do wonder, how hard is it to do really? And, how did I do it?
Doing a web search on "perfect tweet" I see other people are using the term and differently. Oh well. Also one site has the phrase "twoosh" for a tweet of 140 characters "on the first try", which I guess means no editing.
Hmmm...maybe I should call my definition a "twee-dunk"?
Oh, I know, how about a "twee-three"?
No, basketball references may not work with all viewers...so I will still call it a perfect tweet, and others can do what they want.
James Harris
In my opinion, crucial criteria for a perfect tweet is that it be EXACTLY 140 characters, have few if any abbreviations, and is grammatical.
That tweet is 140 characters exactly and is (um, I'm fairly certain), grammatical.
Ok, updating as I got in an argument over this subject, so have a variant to handle both cases in case it turns into some kind of major thing:
In my opinion crucial criteria for a perfect tweet are that it be EXACTLY 140 characters, have few if any abbreviations, and is grammatical.
And later I found another...
The perfect tweet must have the following conditions: it must be 140 characters, be grammatically correct and have few if any abbreviations.
I'm curious, how many tweets on Twitter on any given day are perfect by those rules?
Here's one more perfect tweet:
My wild guess unsupported by inside information is that YouTube is now profitable. If so congratulations Google, and what took you so long?
I will admit that I don't in general try to make my tweets perfect but will if I see one approaching perfection work at it if I can, briefly to see if I achieve that, but if not, it's not a big deal.
But how hard can it be? I have one more perfect tweet:
Ok, I've locked down both variants of the "perfect tweet" which defines itself as perfect within the tweet while also being a perfect tweet.
That tweet is perfect.
(Hmmm...editing yet again to wonder, how many times can you use the phrase "perfect tweet" in a tweet which is itself perfect? I've managed twice above, can anyone do better?)
But when it happens I do wonder, how hard is it to do really? And, how did I do it?
Doing a web search on "perfect tweet" I see other people are using the term and differently. Oh well. Also one site has the phrase "twoosh" for a tweet of 140 characters "on the first try", which I guess means no editing.
Hmmm...maybe I should call my definition a "twee-dunk"?
Oh, I know, how about a "twee-three"?
No, basketball references may not work with all viewers...so I will still call it a perfect tweet, and others can do what they want.
James Harris
Labels:
twitter
Saturday, June 13, 2009
Science and traffic jams
Link above goes to: MSNBC
Quote from the Source:
Great article and I'm glad scientists are studying these things as when I lived in the Atlanta metro area--thankfully in the Bay Area I rarely have to drive--it would be so frustrating when I figured out that a slow-down that could have you completely stopping at points was just about a lot of cars being on the road and nothing else.
Here's one more quote introducing a cool word:
That's what I'm calling them from now on as that is just a cool word: jamitons
Quote from the Source:
Math model may decrease phantom traffic jams
Method could help engineers design roads to keep traffic density low
LiveScience
updated 11:49 a.m. PT, Fri., June 12, 2009
Some traffic jams have no apparent cause — no accident, no stalled vehicle, no lanes closed for construction...
Great article and I'm glad scientists are studying these things as when I lived in the Atlanta metro area--thankfully in the Bay Area I rarely have to drive--it would be so frustrating when I figured out that a slow-down that could have you completely stopping at points was just about a lot of cars being on the road and nothing else.
Here's one more quote introducing a cool word:
Key to the new study is the realization that the mathematics of such jams, which the researchers call "jamitons," are strikingly similar to the equations that describe detonation waves produced by explosion...
That's what I'm calling them from now on as that is just a cool word: jamitons
Labels:
out of the box,
Science
Subscribe to:
Posts (Atom)