• 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

Guide to show common code converted to API methods

 
Ranch Hand
Posts: 109
1
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Morning everyone. The subject of the topic is weird (not sure how to put it in English properly), moderators feel free to change it to your liking.

I was wondering whether there's some site, book, video etc to show us what common techniques can be converted to use API methods.

For example, joining two Strings we would normally write "blah" + "blah", but there's a concat() method in the String class. I'm sure there are lots more occasions like this, can't get others off the top of my head though :P

I'd really like to "delve" more into the API and use what's available for me. Just though there might be some resource available apart from me going through each class and see what's there...
 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you are looking for is really broad. You should be a bit more specific as to what specific API are you looking for? It could be the Java API or some domain specific API's. If you think you have written some useful functions that you want to expose via a well defined API, you can package that as a jar and publish it to GitHub. There are some books that might be of help!

http://www.amazon.com/Practical-API-Design-Confessions-Framework/dp/1430243171/ref=sr_1_3?ie=UTF8&qid=1418369864&sr=8-3&keywords=Writing+Good+API%27s
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vasilis Souvatzis wrote:Just though there might be some resource available apart from me going through each class and see what's there...


That's what the javadocs are for. Obviously, going through all classes won't be possible due to their number, and many wouldn't be particularly interesting with respect to your question. But the ones in java.lang and java.util are useful to know. Or you could check out some of the Apache Commons libraries: http://commons.apache.org/components.html
 
Vasilis Souvatzis
Ranch Hand
Posts: 109
1
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, indeed my question was too broad and I managed to confuse you Joe I meant the Java API, and I was referring to things that we do "manually" but instead can be done more easily with existing methods.

Ulf is spot on I think, lang and util have many useful classes that I should get my hands on. I'll also check the Apache Commons, have heard of it before but never messed with it. (and probably google guava as well).
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vasilis Souvatzis wrote:Yes, indeed my question was too broad and I managed to confuse you Joe I meant the Java API, and I was referring to things that we do "manually" but instead can be done more easily with existing methods.


Unfortunately, many of these things just come with familiarity (as, for example, with when to use "+", or maybe something else like a StringBuilder).

One good rule to remember though, is: Don't re-invent the wheel.

So, if you even think that what you're doing might have been written already, try a Google search for it first. Very often, it will throw up a tutorial page (or possibly even a thread on this site or stackoverflow).

Just one tip: always include the word "Java" in the search; otherwise you may get solutions/techniques from other languages.

HIH

Winston
 
Rancher
Posts: 1044
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The different languages have different idiomatic ways of expressing things even beyond the API usage. For example in the C line of languages (C, C++, Java) this is an idiomatic way of the loop organization:



There are many other ways (using while or indexing from 1 up to including len and working with the (i-1)-th element etc.) but this is the most familiar way.

A sidenote. I worked in a project where my code was reviewed and I got a complaint, that I had written a simple method to check a String's being empty in the sense of being null or having zero length. The "recommended" way to do this was to use some Apache function... Is it an example or a counter-example? You decide...

 
The airline is called "Virgin"? Don't you want a plane to go all the way? This tiny ad will go all the way:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic