Best Practices for better RESTful API Design

For this guide, I’m assuming you’re familiar with very basics concepts of HTTP, JSON or API and this guide won’t cover its fundamentals or other types of API’s like SOAP or RPC.

Designing RESTful API’s can be tricky because there are a tons of possibilities to build it. Also, REST is an architectural style and not a strict standard and so it puts flexibility and freedom of structure on designing. However, following the best practices you can raise your chances to get succeed.

A well-designed web API should aim to support a platform independence, it means your application clients should be able to consume the API without requiring how it’s physically implemented and service consistency, where your service should be able to evolute regardless your client applications.

The topics listed below covers the developments standards that I’m used to follow to design and implement successful API solutions.

Continue reading

Object oriented principles for a good software design

If you are a developer, you must have at least a basic idea about Object Oriented Programming. But, if you are a willing to become an OOP programmer, it’s a requirement to you putting enough efforts on learning the concepts of Object Oriented Design Principles to create clean and modular designs. And it’s curious how things raised more than decades ago can be still updated.

Patterns of Enterprise Application Architecture” – Martin Fowler.

Principles Of Object Oriented Design“, compiled by Uncle Bob.

Principles about class design (SOLID):

SRP The Single Responsibility Principle A class should have one, and only one, reason to change.
OCP The Open Closed Principle You should be able to extend a classes behavior, without modifying it.
LSP The Liskov Substitution Principle Derived classes must be substitutable for their base classes.
ISP The Interface Segregation Principle Make fine grained interfaces that are client specific.
DIP The Dependency Inversion Principle Depend on abstractions, not on concretions.

Principles about package cohesion:

REP The Release Reuse Equivalency Principle The granule of reuse is the granule of release.
CCP The Common Closure Principle Classes that change together are packaged together.
CRP The Common Reuse Principle Classes that are used together are packaged together

Principles about the couplings between packages:

ADP The Acyclic Dependencies Principle The dependency graph of packages must have no cycles.
SDP The Stable Dependencies Principle Depend in the direction of stability.
SAP The Stable Abstractions Principle Abstractness increases with stability

Besides that, there are a bulck of others object oriented design principles that are equally important:

  1. DRY (Don’t repeat yourself) — avoids duplication in code.
  2. Encapsulate what changes — hides implementation detail, helps in maintenance.
  3. Favor Composition over Inheritance — code reuse without cost of inflexibility.
  4. Programming for Interface — helps in maintenance, improves flexibility.
  5. Delegation principle — don’t do all things by yourself, delegate it.