@@ -348,33 +348,39 @@ public static void exampleSnippet(String projectId, String filePath) {
348348 // Snippet content ...
349349}
350350```
351+
351352### Method Structure
353+
352354Method arguments should be limited to what is absolutely required for testing (ideally having at
353355most 4 arguments). In most cases, this is project specific information or the path to an external
354356file. For example, project specific information (such as ` projectId ` ) or a ` filePath ` for an
355357external file is acceptable, while an argument for the type of a file or a specific action is not.
356-
358+
357359Any declared function arguments should include a no-arg, main method with examples for how
358360the user can initialize the method arguments and call the entrypoint for the snippet. If the
359361values for these variables need to be replaced by the user, be explicit that
360362they are example values only.
361363
362- Snippet methods should specify a return type of ` void ` and avoid returning any value wherever
363- possible. Instead, show the user how to interact with a returned object programmatically by printing
364- some example attributes to the console.
364+ Snippet methods should return data that can be used in the calling method to show the user how to
365+ interact with a returned object programmatically.
366+
365367``` java
366368public static void main(String [] args) {
367369 // TODO(developer): Replace these variables before running the sample.
368370 String projectId = " my-project-id" ;
369371 String filePath = " path/to/image.png" ;
370- inspectImageFile(projectId, filePath);
372+ List<String > results = inspectImageFile(projectId, filePath);
373+ for (String result : results) {
374+ // process result ...
375+ }
371376}
372377
373378// This is an example snippet for showing best practices.
374- public static void exampleSnippet(String projectId, String filePath) {
379+ public static List< String > exampleSnippet(String projectId, String filePath) {
375380 // Snippet content ...
376381}
377382```
383+
378384### Exception Handling
379385Samples should include examples and details of how to catch and handle common ` Exceptions ` that are
380386the result of improper interactions with the client or service. Lower level exceptions that are
0 commit comments