Skip to main content

Posts

Showing posts with the label api

Is it bad practice to make a setter return "this”?

Is it a good or bad idea to make setters in java return "this"? public Employee setName(String name){ this.name = name; return this; } This pattern can be useful because then you can chain setters like this: list.add(new Employee().setName("Jack Sparrow").setId(1).setFoo("bacon!")); instead of this: Employee e = new Employee(); e.setName("Jack Sparrow"); ...and so on... list.add(e); ...but it sort of goes against standard convention. I suppose it might be worthwhile just because it can make that setter do something else useful. I've seen this pattern used some places (e.g. JMock, JPA), but it seems uncommon, and only generally used for very well defined APIs where this pattern is used everywhere. Update: What I've described is obviously valid, but what I am really looking for is some thoughts on whether this is generally acceptable, and if there are any pitfalls or related best practices. I know about the Builder pattern

I"ve got a stack with this API Respond data

lets to the point : I've got respond code like this string(141) "000|0123456789| 0987654321|namexxxxx|081xxxx|10000|1231231230|namexxxxxx|081xxxx|10000|3213213210|namaxxxxxx|081xxxx|10000 |page|total_page" (i've make it bold for the main data) There's 3 main data. The main data is dynamic( the ID is in front of name, the last data is "10000"), and max is 10 loop's. How i can take the main data with PHP ? Help :)

Top losers and gainers of the day

How do i get the top losers or gainers on a particular day in java.(20 minute delay is not an issue). Is it possible to do this using yahoo finance. I am able to get information on a particular stock but none for the top losers on gainers of the day. I have checked out Stock Market API - Top Gainers/Losers but it doesnt seem to have a full answer.

Shopify API - add to basket

I'm thinking of using Shopify to manage my shop. I need to add the products to the website with the API. http://api.shopify.com/ I can get the products and stocks with this API call : http://api.shopify.com/product.html#index But, then I would like to 'Add to basket' - I cannot see from the API docs how to do this. Once added to the basket - I'd like to get the basket contents so I can display something like... "2 items : £130 - checkout" I don't need a detailed answer - just point me in the right direction - thanks.

Mocking a JSP"s post method versus creation an API

I have an requirement as per which I have to call an existing java function which is called from the UI through jsp. Data is provided from a form. I want to call that function from the java code. Should I create an API which should be called from the java code, and pass all the parameters required for the java function OR create a mock of the form(if its possible) and pass it to jsp. What is the recommended way?

Need to add 45+ points to a google map

trying to add 45 different points to a map, but I just get OVER_QUERY_LIMIT returned, and no map. I am getting locations via a string search, then assigning the returned LatLng object to a new google Marker object String Search var geocoder = new google.maps.Geocoder(); geocoder.geocode( { 'address': x}, function(results, status) { if (status === google.maps.GeocoderStatus.OK) { var result = results[0].geometry.location; return result; } else { alert("Geocode was not successful for the following reason: " + status); } });

How can a Chrome extension's content script determine the injected page's referrer?

What is the best way to determine a page's referrer within the context of a content script in a Chrome extension? It looks possible to intercept requests' headers using the chrome.webRequest module, but it would then take some book-keeping and message-passing in order to get it into the content script. That approach feels kludgy. Is there a better way?