title: Best practices when using an API (Apache Chemistry for Alfresco)
body: <p>Okay so I'm using this API <a href="https://github.com/donbalon4/API_Alfresco" rel="nofollow noreferrer">https://github.com/donbalon4/API_Alfresco</a> to <strong>upload files to Alfresco</strong> from some other <strong>PHP</strong> site of another service. I don't have any code issue, it's just that as I was using it, some doubts on how to correctly use an API came up to my mind. </p>
  
  <p>I'm basically using it to create some directories into my Alfresco Share. As I said, it's working perfectly well, so the issue is not about my code but on how to use the API (or any API in general) correctly. </p>
  
  <p>First off, if you take a look to that API you'll see how every method is <strong>handling exceptions</strong>, i.e. if you try to create a Folder that already exists, then an Exception will be thrown with proper information.</p>
  
  <p>So far I'm just using the API to <strong>create multiple directories</strong> into some parent root, and some of those directories are likely to have the same name. So when they do, I simply don't have to create them (since directory already exists) and don't need any exception to be thrown or be shown to the end user.</p>
  
  <p>What's the best approach to this goal? I don't feel like modifying the API since it would be contradicting its real meaning. If everyone modifies an existent API then it's not an API anymore. I could simply remove exception handling of methods I'm using, but I don't think it would be a great practice.</p>
  
  <p>Also I realized there's a <em>private</em> method called <em>existsFolder()</em> for internal use. I could maybe change it into <em>public</em> so I can use it  on my actual PHP code to check myself if a given folder already exists, but I don't really know if it would be a great approach either. </p>
  
  <p>What would be the best way to manage directories that already exist? Replace exception handling with a text message to be shown to the end user? Or making the <em>existsFolder()</em> method public? Any other idea I could be missing?</p>