<p>My current employer uses a 3rd party hosted CRM provider and we have a fairly sophisticated integration tier between  the two systems.  Amongst the capabilities of the CRM provider is for developers to author business logic in a  Java like language and on events such as the user clicking a button or submitting a new account into the system, have validation and/or business logic fire off. </p>

<p>One of the capabilities that we make use of is for that business code running on the hosted provider to invoke web services that we host.  The canonical example is a sales rep entering  in a new sales lead and hitting a button to ping our systems to see if we can identify that new lead based on email address, company/first/last name, etc, and if so, return back an internal GUID that represents that individual.  This all works for us fine, but we've run into a wall again and again in trying to setup a sane dev environment to work against.</p>

<p>So while our use case is a bit nuanced, this can generally apply to any development house that builds APIs for 3rd party consumption:  <b>what are some best practices when designing a development pipeline and environment when  you're building APIs to be consumed by the outside world?</b></p>

<p>At our office, all our devs are behind a firewall, so code in progress can't be hit by the outside world, in our case the CRM provider.  We could poke holes in the firewall but that's less than ideal from a security surface area standpoint.  Especially if the # of devs who need to be in a DMZ like area is high.  We currently are trying a single dev machine in the DMZ and then remoting into it as needed to do dev work, but that's created a resource scarcity issue if multiple devs need the box, let alone they're making potentially conflicting changes (e.g.  different branches).</p>

<p>We've considered just mocking/faking incoming requests by building fake clients for these services, but that's a pretty major overhead in building out feature sets  (though it does by nature reinforce a testability of our APIs).  This also doesn't obviate the fact that sometimes we really do need to diagnose/debug issues coming from the real client itself, not some faked request payload.</p>

<p>What have others done in these types of scenarios?  In this day and age of mashups, there have to be a lot of folks out there w/ experiences of developing APIs--what's worked (and not worked so) well for the folks out there?</p>

[{'answer_id': 29334, 'author': 'John', 'author_id': 2168, 'author_profile': 'https://Stackoverflow.com/users/2168', 'pm_score': 2, 'selected': False, 'text': '<pre><code>import java.util.HashMap;\n\nMap map = new HashMap();\n</code></pre>\n'}, {'answer_id': 29336, 'author': 'Edmund Tay', 'author_id': 2633, 'author_profile': 'https://Stackoverflow.com/users/2633', 'pm_score': 6, 'selected': True, 'text': '<pre><code>Map map = new HashMap();\nHashtable ht = new Hashtable();\n</code></pre>\n\n<p>Both classes can be found from the java.util package. The difference between the 2 is explained in the following <a href="http://www.jguru.com/faq/view.jsp?EID=430247" rel="noreferrer">jGuru FAQ entry</a>.</p>\n'}, {'answer_id': 29342, 'author': 'SCdF', 'author_id': 1666, 'author_profile': 'https://Stackoverflow.com/users/1666', 'pm_score': 1, 'selected': False, 'text': '<p>What <a href="https://stackoverflow.com/questions/29324/how-do-i-create-a-hash-table-in-java#29336">Edmund</a> said.</p>\n\n<p>As for not calling .add all the time, no, not idiomatically. There would be various hacks (storing it in an array and then looping) that you could do if you really wanted to, but I wouldn\'t recommend it.</p>\n'}, {'answer_id': 29356, 'author': 'Cem Catikkas', 'author_id': 3087, 'author_profile': 'https://Stackoverflow.com/users/3087', 'pm_score': 3, 'selected': False, 'text': '<p>Also don\'t forget that both Map and Hashtable are generic in Java 5 and up (as in any other class in the <a href="http://java.sun.com/javase/6/docs/technotes/guides/collections/index.html" rel="noreferrer">Collections framework</a>).</p>\n\n<pre><code>Map&lt;String, Integer&gt; numbers = new HashMap&lt;String, Integer&gt;();\nnumbers.put("one", 1);\nnumbers.put("two", 2);\nnumbers.put("three", 3);\n\nInteger one = numbers.get("one");\nAssert.assertEquals(1, one);\n</code></pre>\n'}, {'answer_id': 30413, 'author': 'Mocky', 'author_id': 3211, 'author_profile': 'https://Stackoverflow.com/users/3211', 'pm_score': 0, 'selected': False, 'text': "<blockquote>\n  <p>And is there a way to populate the table with a list of key->value pairs without individually calling an add method on the object for each pair?</p>\n</blockquote>\n\n<p>One problem with your question is that you don't mention what what form your data is in to begin with. If your list of pairs happened to be a list of Map.Entry objects it would be pretty easy.</p>\n\n<p>Just to throw this out, there is a (much maligned) class named java.util.Properties that is an extension of Hashtable. It expects only String keys and values and lets you load and store the data using files or streams. The format of the file it reads and writes is as follows:</p>\n\n<pre><code>key1=value1\nkey2=value2\n</code></pre>\n\n<p>I don't know if this is what you're looking for, but there are situations where this can be useful. </p>\n"}, {'answer_id': 31797, 'author': 'izb', 'author_id': 974, 'author_profile': 'https://Stackoverflow.com/users/974', 'pm_score': 5, 'selected': False, 'text': '<p>You can use double-braces to set up the data. You still call add, or put, but it\'s less ugly:</p>\n\n<pre><code>private static final Hashtable&lt;String,Integer&gt; MYHASH = new Hashtable&lt;String,Integer&gt;() {{\n    put("foo",      1);\n    put("bar",      256);\n    put("data",     3);\n    put("moredata", 27);\n    put("hello",    32);\n    put("world",    65536);\n }};\n</code></pre>\n'}, {'answer_id': 13080134, 'author': 'hedrick', 'author_id': 1146047, 'author_profile': 'https://Stackoverflow.com/users/1146047', 'pm_score': 0, 'selected': False, 'text': '<p>It is important to note that Java\'s hash function is less than optimal. If you want less collisions and almost complete elimination of re-hashing at ~50% capacity, I\'d use a Buz Hash algorithm <a href="http://www.cs.hmc.edu/~geoff/classes/hmc.cs070.200101/homework10/hashfuncs.html" rel="nofollow">Buz Hash</a></p>\n\n<p>The reason Java\'s hashing algorithm is weak is most evident in how it hashes Strings.</p>\n\n<p><code>"a".hash()</code> give you the ASCII representation of <code>"a"</code> - <code>97</code>, so <code>"b"</code> would be <code>98</code>. The whole point of hashing is to assign an arbitrary and "as random as possible" number.</p>\n\n<p>If you need a quick and dirty hash table, by all means, use <code>java.util</code>.  If you are looking for something robust that is more scalable, I\'d look into implementing your own.</p>\n'}, {'answer_id': 55966592, 'author': 'Juraj Valkučák', 'author_id': 11446430, 'author_profile': 'https://Stackoverflow.com/users/11446430', 'pm_score': -1, 'selected': False, 'text': '<pre><code>Hashtable&lt;Object, Double&gt; hashTable = new Hashtable&lt;&gt;();\n</code></pre>\n\n<p><strong>put values</strong>\n...</p>\n\n<p><strong>get max</strong></p>\n\n<pre><code>Optional&lt;Double&gt; optionalMax = hashTable.values().stream().max(Comparator.naturalOrder());\n\nif (optionalMax.isPresent())\n System.out.println(optionalMax.get());\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/29335', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2228/']