GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing azure.github.io — Android Azure SDK Design Guidelines | Azure SDKs Android Azure SDK Design Guidelines DRAFT: The Android guidelines are in DRAFT status
IntroductionThe following document describes Android specific guidelines for designing Azure SDK client libraries. These guidelines also expand on and simplify language-independent General Azure SDK Guidelines. More specific guidelines take precedence over more general guidelines. The Android guidelines are for the benefit of client library designers targeting service applications written for the native Android ecosystem. You do not have to write a client library for Android if your service is not normally accessed from mobile apps. Design principlesThe main value of the Azure SDK is productivity. Other qualities, such as completeness, extensibility, and performance are important but secondary. We ensure our customers can be highly productive when using our libraries by ensuring these libraries are: Idiomatic
Consistent
Approachable
Dependable
General Guidelines✅ DO follow the General Azure SDK Guidelines. ✅ DO locate all source code in the azure/azure-sdk-for-android GitHub repository. ✅ DO write the client libraries using Java 8. The intent is to ensure that the client library is idiomatic for Android applications while remaining compatible with a minimum API level of Android 15 (Ice Cream Sandwich). Support for non-HTTP ProtocolsCurrently, this document describes guidelines for client libraries exposing HTTP services. If your service is not HTTP-based, please contact the Azure SDK Architecture Board for guidance. Azure SDK API DesignAzure services are exposed to Android developers as one or more service client types and a set of supporting types. Service ClientService clients are the main starting points for developers calling Azure services with the Azure SDK. Each client library should have at least one client in its main namespace, so it’s easy to discover. The guidelines in this section describe patterns for the design of a service client. Because for Android both synchronous and asynchronous service clients are required, the sections below are organized into general service client guidance, followed by sync- and async-specific guidance. ✅ DO name service client types with the Client suffix (for example, ✅ DO annotate all service clients with the ✅ DO place service client types that the consumer is most likely to interact with in the root package of the client library (for example, ✅ DO ensure that all service client classes are immutable and stateless upon instantiation. ✅ DO have separate service clients for sync and async APIs. ☑️ YOU SHOULD support only those features provided by the Azure service that would make sense to access from a mobile app. Mobile apps are inherently end-user facing applications, and only a subset of Azure services and features are intended for use by these type of applications. While completeness is valuable and gaps in functionality can cause frustration, a smaller binary size and an opinionated stance of only providing end user facing functionality will make our libraries easier and more desirable for app developers to use. ✅ DO provide a public API whose shape matches the public API shape provided in the equivalent iOS library as closely as possible. Clients should have the same names and provide the same functionality in their public APIs, and while method naming should be idiomatic to each platform, consistency in naming between the two platforms is the next most important consideration. Sync Service Clients✅ DO offer a sync service client named Refer to the ChatClient class for a fully built-out example of how a sync client should be constructed. Async Service Clients✅ DO offer an async service client named Refer to the ChatAsyncClient class for a fully built-out example of how a sync client should be constructed. ✅ DO use Android retro future’s ⛔️ DO NOT write custom APIs for streaming or async operations. Make use of the existing functionality offered in the Azure core library. Discuss proposed changes to the Azure core library with the Architecture Board. Refer to the Azure Core Types section for more information. Service Client Creation⛔️ DO NOT provide any ✅ DO offer a fluent builder API for constructing service clients named ✅ DO offer build method ‘overloads’ for when a builder can build multiple client types. These methods must be named in the form ✅ DO annotate service client builders with the ✅ DO ensure consistency across all HTTP-based client libraries, by using the following names for client builder fluent API:
✅ DO allow the consumer to construct a service client with the minimal information needed to connect and authenticate to the service. ✅ DO ensure the builder will instantiate a service client into a valid state. Throw an Service Versions✅ DO call the highest supported service API version by default, and ensure this is clearly documented. ⛔️ DO NOT include preview API versions in a stable SDK release’s API version enum. ✅ DO expose preview API versions only in beta SDKs. ✅ DO provide an enum of supported service API versions that can be supplied via the options class when initializing the service client, as shown below: This can then be called by the developer as such: ✅ DO include a Service MethodsService methods are the methods on the client that invoke operations on the service. ✅ DO use standard JavaBean naming prefixes for all methods that are not service methods. ⛔️ DO NOT use the suffix ⛔️ DO NOT provide multiple asynchronous methods for a single REST endpoint in the same library, unless to provide overloaded methods to enable alternative or optional method parameters. One of the Azure Core types is ✅ DO provide an overload method that takes a ⛔️ DO NOT include overloads that take Naming✅ DO name service methods using a standardized set of verbs or verb prefixes within a set of client libraries for a service. Prefer the use of the following terms for CRUD operations: Verb
Parameters
Returns
Comments
Verb
upsert<noun>
Parameters
key, item
Returns
Updated or created item
Comments
Create new item or update existing item. Verb is primarily used in database-like services.
Verb
set<noun>
Parameters
key, item
Returns
Updated or created item.
Comments
Create new item or update existing item. Verb is primarily used for dictionary-like properties of a service.
Verb
create<noun>
Parameters
key, item
Returns
Created item.
Comments
Create new item. Fails if item already exists.
Verb
update<noun>
Parameters
key, partial item
Returns
Updated item
Comments
Fails if item doesn’t exist.
Verb
replace<noun>
Parameters
key, item
Returns
Replace existing item
Comments
Completely replaces an existing item. Fails if the item doesn’t exist.
Verb
delete<noun>
Parameters
key
Returns
Deleted item, or
Comments
Delete an existing item. Will succeed even if item didn’t exist. Deleted item may be returned, if service supports it.
Verb
add<noun>
Parameters
index, item
Returns
Added item
Comments
Add item to a collection. Item will be added last, or into the index position specified.
Verb
get<noun>
Parameters
key
Returns
item
Comments
Will return
Verb
list<noun>
Parameters
Returns
Items
Comments
Return list of items. Returns empty list if no items exist.
Verb
<noun>Exists
Parameters
key
Returns
Comments
Return ☑️ YOU SHOULD remain flexible and use names best suited for developer experience. Don’t let the naming rules result in non-idiomatic naming patterns. For example, Java developers prefer ✅ DO use the verb as as prefix for the method name when object(s) the action will apply to or return is unclear. For example, prefer ✅ DO prefix methods in sync clients that create or vend subclients with ✅ DO prefix methods in async clients that create or vend subclients with Cancellation✅ DO support an optional ✅ DO cancel any in-flight requests when a developer calls ✅ DO return an Return TypesRequests to the service fall into two basic groups: methods that make a single logical request, and methods that make a deterministic sequence of requests. An example of a single logical request is a request that may be retried inside the operation. An example of a deterministic sequence of requests is a paged operation. The logical entity is a protocol neutral representation of a response. The logical entity may combine data from headers, body, and the status line. For example, you may expose an ✅ DO return the logical entity (i.e. the ✅ DO return the logical entity (i.e. the Return ✅ DO make it possible for a developer to access the complete response, including the status line, headers, and body. The type ✅ DO provide examples on how to access the raw and streamed response for a request, where exposed by the client library. We don’t expect all methods to expose a streamed response. ✅ DO return an instance of the For methods that combine multiple requests into a single call: ⛔️ DO NOT return headers and other per-request metadata unless it’s obvious as to which specific HTTP request the methods return value corresponds to. ✅ DO provide enough information in failure cases for a developer to take appropriate corrective action, including a message describing what went wrong and details on the corrective actions to take. Service Method Parameters✅ DO accept all arguments required to execute a method call as individual parameters to the method. An argument is considered required if it is flagged as such in the service’s API spec or if the library author deems it to be essential to the developer experience of the client API. Option ParametersService methods fall into two main groups when it comes to the number and complexity of parameters they accept:
Simple methods are methods that take up to six parameters, with most of the parameters being simple primitive types. Complex methods are methods that take a larger number of parameters and typically correspond to REST APIs with complex request payloads. Simple methods should follow standard Java best practices for parameter list and overload design. Complex methods should introduce an option parameter to represent the request payload. Consideration can subsequently be made for providing simpler convenience overloads for the most common scenarios. This is referred to in this document as the ‘options pattern’, and is demonstrated in the code below: ✅ DO name the options type after the name of the service method it is used for, such that the type is named ✅ DO use the options parameter pattern for complex service methods. ✔️ YOU MAY use the options parameter pattern for simple service methods that you expect to ✔️ YOU MAY add simple overloads of methods using the options parameter pattern. If in common scenarios, users are likely to pass just a small subset of what the options parameter represents, consider adding an overload with a parameter list representing just this subset. ⛔️ DO NOT introduce method overloads that take a subset of the parameters as well as the options parameter, except for parameters that are for client-side use only (e.g. ✅ DO use rich types where possible for options. For example, use the ✅ DO use the options parameter type, if it exists, for all ✅ DO store options classes (and supporting enumerations / classes referenced by such models) in a root-level ✅ DO design options types with the same design guidance as given below for model class types, namely fluent setters for optional arguments, using the standard JavaBean naming convention of ✔️ YOU MAY introduce constructor overloads for each combination of required arguments (in a similar manner to required properties on model types). Parameter ValidationThe service client will have several methods that perform requests on the service. Service parameters are directly passed across the wire to an Azure service. Client parameters are not passed directly to the service, but used within the client library to fulfill the request. Examples of client parameters include values that are used to construct a URI, or a file that needs to be uploaded to storage. ✅ DO validate client parameters. ⛔️ DO NOT validate service parameters. This includes null checks, empty strings, and other common validating conditions. Let the service validate any request parameters. Common parameter validations include null checks, empty string checks, and range checks. Let the service validate its parameters. ✅ DO test the developer experience when invalid service parameters are passed in. Ensure clear error messages are generated by the client. If the developer experience is inadequate, work with the service team to correct the problem. Methods Returning Collections (Paging)Many Azure REST APIs return collections of data in batches or pages. A client library will expose such APIs as special enumerable types ✅ DO return
⛔️ DO NOT return other collection types for sync APIs that return collections (for example, do not return ✅ DO return Consumers of this API can consume individual items by treating the response as a The consumer may process items page-by-page instead: The ✔️ YOU MAY subclass the Azure Core paged and iterable APIs, where appropriate, to offer additional, service specific API to users. If this is done, the subtype must be named as it currently is, prefixed with the name of the service. For example, ✅ DO use the same type for entities returned from a list operation vs. a get operation if those operations return different views of the same result. For example a list operation may provide only a minimal representation of each result, with the expectation that a get operation must be performed for each result to access the full representation. If the representations are compatible, reuse the same type for both the list and the get operation. Otherwise, it is permissible to use distinct types for each operation. Important: Services should refrain from having a difference between the type of a particular entity as it exists in a list versus the result of a GET request for that individual item as it makes the client library’s surface area simpler.
⛔️ DO NOT expose an iterator over each individual item if getting each item requires a corresponding GET request to the service. One GET per item is often too expensive and so not an action we want to take on behalf of users. Methods Invoking Long Running OperationsLong-running operations are uncommon in a mobile context. If you feel like you need long running operations, contact the Azure SDK mobile team for advice.
Conditional Request MethodsConditional requests are normally performed using HTTP headers. The primary usage provides headers that match the With headers, tests are possible for the following:
Not all services support all of these semantics, and may not support any of them. Developers have varying levels of understanding of the Safe conditional requests (e.g. GET) These are typically used to save bandwidth in an “update cache” scenario, i.e. I have a cached value, only send me the data if what the service has is newer than my copy. These return either a 200 or a 304 status code, indicating the value was not modified, which tells the caller that their cached value is up to date. Unsafe conditional requests (e.g. POST, PUT, or DELETE) These are typically used to prevent losing updates in an optimistic concurrency scenario, i.e. I’ve modified the cached value I’m holding, but don’t update the service version unless it has the same copy I’ve got. These return either a success or a 412 error status code, indicating the value was modified, to indicate to the caller that they’ll need to retry their update if they want it to succeed. These two cases are handled differently in client libraries. However, the form of the call is the same in both cases. The signature of the method should be: The
In all cases, the conditional expression is “opt-in”, and the default is to perform the operation unconditionally. The return value from a conditional operation must be carefully considered. For safe operators (e.g. GET), return a response that will throw if the value is accessed (or follow the same convention used fro a ☑️ YOU SHOULD accept a ☑️ YOU SHOULD accept an additional boolean or enum parameter on service methods as necessary to enable conditional checks using ☑️ YOU SHOULD include the ⚠️ YOU SHOULD NOT throw an error when a ☑️ YOU SHOULD throw a distinct error when a Hierarchical Clients
Supporting TypesModel TypesModel types are classes that developers of applications use to provide required information into, or to receive information from, Azure services. For example: ⛔️ DO NOT offer a separate builder class for model classes. ✅ DO provide public constructors for all model classes that a user is allowed to instantiate. Model classes that are not instantiable by the user, for example if they are model types returned from the service, must not have any publicly visible constructors. Because model types can represent many different kinds of models, it is important that they can correctly enforce required properties. Whilst many models have no required properties, some do, and moreso, some models can even support multiple mutually exclusive sets of required properties. ✅ DO provide a no-args constructor if a model type has no required properties. ✅ DO provide one or more constructors with arguments, if a model type has required properties. If there are multiple mutually exclusive sets of supported required parameters, a constructor must be introduced for each of these. For example: ✅ DO provide a fluent setter API to configure the model class, where each ✅ DO override all ✅ DO apply the Fluent types must not be immutable. Don’t return a new instance on each setter call. ✅ DO use the JavaBean naming convention of ✅ DO include static methods if new model instances are required to be created from raw data. The static method names should be Model types sometimes exist only as an Azure service return type, and developers would never instantiate these. Often, these model types have API that is not user-friendly (in particular, overly complex constructors). It would be best for developers if they were never presented with this API in the first place, and we refer to these as ‘undesirable public API’. ✅ DO put model classes that are intended as service return types only, and which have undesirable public API into the Examples of situations where this is applicable include when there are constructors or setters on a type which receive implementation types, or when a type should be immutable but needs to be mutable internally. The interface should have the model type name, and the implementation (within Enumerations✅ DO use an ✅ DO use all upper-case names for enum (and ‘expandable’ enum) values. ✔️ YOU MAY use the ✅ DO use an ✅ DO use Using Azure Core Types✅ DO make use of packages in Azure Core to provide behavior consistent across all Azure SDK libraries. This includes, but is not limited to:
See the Azure Core README for more details. Using Primitive Types⛔️ DO NOT create API that exposes the old Java date library (e.g. ⛔️ DO NOT create API that exposes the ✅ DO wrap primitive types where appropriate to represent a meaningful domain entity even if the model type contains a single field. For example, a phone number is just a string, but creating a new type to wrap primitive Using Android-compatible Java APIs✅ DO write client libraries in Java. This avoids forcing customers to depend on the Kotlin runtime in their applications. ✅ DO write client libraries using Java 8 syntax. Java 8 syntax constructs will be down-leveled using Java 8 language feature desugaring provided by Android Gradle Plugin 3.0.0+. This includes use of the following Java 8 language features:
⛔️ DO NOT use Java 8+ APIs. Some such APIs are able to be down-leveled using Java 8+ API desugaring provided by Android Gradle Plugin 4.0.0+. However many developers may not be using a sufficiently updated version of the plugin, and library desugaring injects additional code into the customer’s application, potentially increasing the APK size or method count. This includes use of the following Java 8+ APIs:
ExceptionsError handling is an important aspect of implementing a client library. It is the primary method by which problems are communicated to the consumer. We convey errors to developers by throwing appropriate exceptions from our service methods. ✅ DO throw an exception when any HTTP request fails with an HTTP status code that is not defined by the service/Swagger as a successful status code. ✅ DO use unchecked exceptions. Java offers checked and unchecked exceptions, where checked exceptions force the user to introduce verbose In the case of a higher-level method that produces multiple HTTP requests, either the last exception or an aggregate exception of all failures should be produced. ✅ DO use the following standard Java exceptions for pre-condition checking:
⛔️ DO NOT create a new error type when a language-specific error type will suffice. ✅ DO specify all checked and unchecked exceptions thrown in a method within the JavaDoc documentation on the method as ✅ DO use the existing exception types present in the Azure Core library for service request failures. Avoid creating new exception types. The following list outlines all available exception types (with indentation indicating exception type hierarchy):
✅ DO extend from one of the above exceptions defined in Azure Core when defining a new service-specific exception. Do not extend from ✅ DO define exception type in a public package if the exception is thrown from a public API. Do not throw an exception that is defined as package-private or is defined in AuthenticationAzure services use a variety of different authentication schemes to allow clients to access the service. Conceptually, there are two entities responsible in this process: a credential and an authentication policy. Credentials provide confidential authentication data. Authentication policies use the data provided by a credential to authenticate requests to the service. ✅ DO provide service client fluent builder APIs that accept an instance of the appropriate Azure Core credential abstraction, namely ✅ DO support all authentication techniques that the service supports and that make sense in a mobile context. Service principal authentication generally does not make sense, for example.
⛔️ DO NOT persist, cache, or reuse security credentials. Security credentials should be considered short lived to cover both security concerns and credential refresh situations. ✅ DO use authentication policy implementations from the Azure Core library where available. ✅ DO define a public custom credential type which enables clients to authenticate requests using the custom scheme. ⚠️ YOU SHOULD NOT define custom credential types extending or implementing abstractions from Azure Core. ✅ DO provide credential types that can be used to fetch all data needed to authenticate a request to the service. If using a service-specific credential type, the implementation must be non-blocking and atomic. ✅ DO define custom credential types in the same namespace and package as the client, or in a service group namespace and shared package, not in Azure Core or Azure Identity. ✅ DO prepend custom credential type names with the service name or service group name to provide clear context to its intended scope and usage. ✅ DO append ✅ DO define a constructor or factory for the custom credential type which takes in ALL data needed for the custom authentication protocol. ✅ DO define an update method which accepts all mutable credential data, and updates the credential in an atomic, thread safe manner. ⛔️ DO NOT define public settable properties or fields which allow users to update the authentication data directly in a non-atomic manner. ⚠️ YOU SHOULD NOT define public properties or fields which allow users to access the authentication data directly. They are most often not needed by end users, and are difficult to use in a thread safe manner. In the case that exposing the authentication data is necessary, all the data needed to authenticate requests should be returned from a single API which guarantees the data returned is in a consistent state. ✅ DO provide service client constructors or factories that accept all supported credential types. Client libraries may support providing credential data via a connection string ONLY IF the service provides a connection string to users via the portal or other tooling. Connection strings are generally good for getting started as they are easily integrated into an application by copy/paste from the portal. However, connection strings are considered a lesser form of authentication because the credentials cannot be rotated within a running process. ✔️ YOU MAY provide a service client initializer that accepts a connection string if appropriate. The connection string must be provided as the first parameter to the initializer and must be named ⛔️ DO NOT support initializing a service client with a connection string unless such connection string is available within tooling (for copy/paste operations). ⚠️ YOU SHOULD NOT support connection strings with embedded secrets. Android apps are not cryptographically secure and may be distributed to millions of devices. A developer should assume that any credential placed in an Android app is compromised. When implementing authentication, don’t open up the consumer to security holes like PII (personally identifiable information) leakage or credential leakage. Credentials are generally issued with a time limit, and must be refreshed periodically to ensure that the service connection continues to function as expected. Ensure your client library follows all current security recommendations and consider an independent security review of the client library to ensure you’re not introducing potential security problems for the consumer. If your service implements a non-standard credential system (that is, a credential system that is not supported by Azure Core), then you need to produce an authentication policy for the HTTP pipeline that can authenticate requests given the alternative credential types provided by the client library. ✅ DO provide a suitable authentication policy that authenticates the HTTP request in the HTTP pipeline when using non-standard credentials. NamespacesJava uses packages to group related types. Grouping services within a cloud infrastructure is common since it aids discoverability and provides structure to the reference documentation. In Java, the namespace should be named
✅ DO start the package with ✅ DO construct the package name with all lowercase letters (no camel case is allowed), without spaces, hyphens, or underscores. For example, Azure Key Vault would be in ✅ DO pick a package name that allows the consumer to tie the package to the service being used. The package does NOT change when the branding of the product changes. Avoid the use of marketing names that may change. ✅ DO use the following list as the group of services:
If the client library does not seem to fit into the group list, contact the Architecture Board to discuss the namespace requirements. ✅ DO place the management (Azure Resource Manager) API in the ⛔️ DO NOT choose similar names for clients that do different things. ✅ DO register the chosen namespace with the Architecture Board. Open an issue to request the namespace. See the registered namespace list for a list of the currently registered namespaces. ⛔️ DO NOT allow implementation code (that is, code that doesn’t form part of the public API) to be mistaken as public API. There are two valid arrangements for implementation code:
CheckStyle checks ensure that classes within an Example NamespacesHere are some examples of namespaces that meet these guidelines:
Here are some namespaces that do not meet the guidelines:
Support for MockingAll client libraries must support mocking to enable non-live testing of service clients by customers. One of the key things we want to support is to allow consumers of the library to easily write repeatable unit-tests for their applications without activating a service. This allows them to reliably and quickly test their code without worrying about the vagaries of the underlying service implementation (including, for example, network conditions or service outages). Mocking is also helpful to simulate failures, edge cases, and hard to reproduce situations (for example: does code work on February 29th). Below is an example of writing a mock unit test using the Mockito framework. For more details on using Mockito in the context of the Azure SDK for Android, refer to the unit testing wiki documentation.
✅ DO encapsulate access to Android OS APIs by way of an intermediate interface. This allows the runtime implementation to be swapped out for a test implementation in unit tests. ✅ DO support mocking to enable non-live testing of service clients (and by extension also model types, option types, etc) by customers. ✅ DO support mocking of all IO operations (including network and file operations). Azure SDK Library DesignSupported PlatformsAndroid developers need to concern themselves with the runtime environment they are running in. The Android ecosystem is very fragmented, meaning that multiple versions and form factors are prevalent. ☑️ YOU SHOULD support all versions of Android starting with API level 15 (Ice Cream Sandwich). ✅ DO write client libraries in Java. This avoids forcing customers to depend on the Kotlin runtime in their applications. ✅ DO support Java 8 language features that do not require desugaring to work on older Android versions. For more information on the list of supported language features, please refer Use Java 8 language features and APIs. PackagingGradle and Android StudioAll client libraries for Android standardize on the Gradle build tooling for build and dependency management. This section details the standard configuration that must be used in all client libraries. ✅ DO ship a ✅ DO specify the ✅ DO name Android library modules to be of the form ✅ DO specify the ✅ DO specify the Service-Specific Common LibrariesThere are occasions when common code needs to be shared between several client libraries. For example, a set of cooperating client libraries may wish to share a set of exceptions or models. ✅ DO gain Architecture Board approval prior to implementing a common library. ✅ DO minimize the code within a common library. Code within the common library is available to the consumer of the client library and shared by multiple client libraries within the same namespace. ✅ DO store the common library in the same namespace as the associated client libraries. The common library should use the A common library will only be approved if:
Let’s take two examples:
Versioning✅ DO be 100% backwards compatible with older versions of the same package. ✅ DO call the highest supported service API version by default. ✅ DO allow the consumer to explicitly select a supported service API version when instantiating the service client, by using the service client builder with a property called ✅ DO offer a ✅ DO use the version naming used by the service itself in naming the version values in the enum. The standard approach takes the form Note: Third-party reusable libraries shouldn’t change behavior without an explicit decision by the developer. When developing libraries that are based on the Azure SDK, lock the library to a specific service version to avoid changes in behavior.
✅ DO introduce a new library (with new library names, new package names, and new type names) if you must do an API breaking change. Breaking changes should happen rarely, if ever. Register your intent to do a breaking change with the Architecture Board. You’ll need to have a discussion with the language architect before approval. Client Version NumbersA consistent version number scheme allows consumers to determine what to expect from a new version of the library. ✅ DO use MAJOR.MINOR.PATCH format for the library version. Use ✅ DO change the version number of the client library when ANYTHING changes in the client library. ✅ DO increment the patch version when fixing a bug. ⛔️ DO NOT include new APIs in a patch release. ✅ DO increment the major or minor version when adding support for a service API version. ✅ DO increment the major or minor version when adding a new method to the public API. ☑️ YOU SHOULD increment the major version when making large feature changes. DependenciesDependencies bring in many considerations that are often easily avoided by avoiding the dependency.
✅ DO depend on the Android Azure Core ( ⛔️ DO NOT be dependent on any other packages within the client library distribution package, with the exception of the following:
Dependency versions are purposefully not specified in this table. The definitive source for the dependency versions being used in all client libraries will be published in a separate document that is generated from the azure-sdk-for-android code repository. Transitive dependencies of these libraries, or dependencies that are part of a family of dependencies, are allowed.
⛔️ DO NOT introduce new dependencies on third-party libraries that are already referenced from the top level ⛔️ DO NOT specify or change dependency versions in your client library Gradle file. All dependency versioning must be centralized through the common parent ⛔️ DO NOT include dependencies on pre-released or beta versions of external libraries. All dependencies must be approved for general use. ☑️ YOU SHOULD consider copying or linking required code into the client library in order to avoid taking a dependency on another package that could conflict with the ecosystem. Make sure that you are not violating any licensing agreements and consider the maintenance that will be required of the duplicated code. “A little copying is better than a little dependency” (YouTube). ⛔️ DO NOT depend on concrete logging, dependency injection, or configuration technologies (except as implemented in the Azure Core library). The client library will be used in applications that might be using the logging, DI, and configuration technologies of their choice. Native codeNative code plugins cause compatibility issues and require additional scrutiny. Certain languages compile to a machine-native format (for example, C or C++), whereas most modern languages opt to compile to an intermediary format to aid in cross-platform support. ⚠️ YOU SHOULD NOT write platform-specific / native code. If you feel like you need to include native binaries in your library, contact the Azure SDK mobile team for advice. ✅ DO include binaries for all common Android architectures if your library includes platform-specific / native code. You should only include such native code in the Android library if:
Documentation✅ DO ensure that anybody can clone the repo containing the client library and generate the full and complete JavaDoc output for the code, without any need for additional processing steps. ✅ DO include descriptive text of the method, as well as all parameters, the returned value (if any), all checked exceptions, as well as all unchecked exceptions. Failing to document unchecked exceptions means that users do not have any indication of how they can handle exceptional circumstances. ✅ DO include code samples in all class-level JavaDoc, and in relevant method-level JavaDoc. ⛔️ DO NOT hard-code the sample within the JavaDoc (where it may become stale). Put code samples in ✅ DO follow the naming convention outlined below for naming samples tags:
Repository GuidelinesDocumentationGeneral guidelines✅ DO include your service’s content developer in the architectural review for your library. To find the content developer you should work with, check with your team’s Program Manager. ✅ DO follow the Azure SDK Contributors Guide (MICROSOFT INTERNAL) ✅ DO adhere to the Microsoft style guides when you write public-facing documentation. (MICROSOFT INTERNAL) Use the style guides for both long-form documentation like a README and the ☑️ YOU SHOULD attempt to document your library into silence. Preempt developers’ usage questions and minimize GitHub issues by clearly explaining your API in the As you write your code, doc it so you never hear about it again. The fewer questions you have to answer about your client library, the more time you have to build new features for your service. ⛔️ DO NOT include version details when specifying Gradle dependency statements. SamplesCode samples are small applications that demonstrate a certain feature that is relevant to the client library. Samples allow developers to quickly understand the full usage requirements of your client library. Code samples shouldn’t be any more complex than they needed to demonstrate the feature. Don’t write full applications. Samples should have a high signal to noise ratio between useful code and boilerplate code for non-related reasons. ✅ DO include code samples alongside your library’s code within the repository. The samples should clearly and succinctly demonstrate the code most developers need to write with your library. Include samples for all common operations. Pay attention to operations that are complex or might be difficult for new users of your library. Include samples for the champion scenarios you’ve identified for the library. ✅ DO place code samples within the
✅ DO use the latest coding conventions when creating samples. Make liberal use of Java 8 syntax and APIs (for example, diamond operators) as they remove boilerplate from your samples and highlight you library, as long as they are included in Android’s Java 8 supported features list for the Gradle 3.0.0+ plugin. ✅ DO compile sample code using the latest major release of the library. Review sample code for freshness. At least one commit must be made (to update dependencies) to each sample per semester. ✅ DO ensure that code samples can be easily grafted from the documentation into a users own application. For example, don’t rely on variable declarations in other samples. ✅ DO write code samples for ease of reading and comprehension over code compactness and efficiency. ✅ DO ensure that samples can run in Android Studio for Windows, macOS and Linux. Don’t use a non-standard developer toolchain. ✅ DO build and test your code samples using the repository’s continuous integration (CI) to ensure they remain functional. ⛔️ DO NOT combine multiple operations in a code sample unless it’s required for demonstrating the type or member. For example, a Cosmos DB code sample doesn’t include both account and container creation operations. Create a sample for account creation, and another sample for container creation. Combined operations require knowledge of additional operations that might be outside their current focus. The developer must first understand the code surrounding the operation they’re working on, and can’t copy and paste the code sample into their project. Java Best Practices for AndroidThis section introduces guidelines for fundamental Java development design decisions that are used throughout the Azure SDK for Android. Naming PatternsUsing a consistent set of naming patterns across all client libraries will ensure a consistent and more intuitive developer experience. This section outlines good practices for naming that must be followed by all client libraries. ✅ DO prefer succinctness over verbosity in method and class names, except when readability is impacted. A few examples include:
⛔️ DO NOT fully uppercase acronyms. APIs must take the form of ✅ DO use service-specific acronyms sparingly in API. Whereas most users will accept a method including ✅ DO use the correct naming for ‘host’ vs ‘hostname’. ‘hostname’ is the host name without any port number, whereas ‘host’ is the hostname with the port number. ⛔️ DO NOT use camel case on words that are commonly accepted in their combined form. For example, ‘hostname’ should be spelt as ⛔️ DO NOT name interface types with an ‘I’ prefix, e.g. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |