Single Responsibility Principle
The Single Responsibility Principle states that:
A class should have one, and only one, reason to change.
The idea behind this principle is to design a class that has one responsibility or various methods with unique functionality. According to this principle, a method should not do more than one task at a time. Each function must be designated a unique task.
Let's take, for example, the adapter of a recyclerView
:
@Override public void onBindViewHolder(final ViewHolder holder, final int position) { PlaceItem item = list.get(position); String name = item.getName() != null ? item.getName() : ""; String description = item.getDescription() != null ? item.getDescription() : ""; String location = item.getAddress() != null ? item.getAddress() : ""; String rating = String.format("%.02f", item.getRating()); String distance = item.getDistance()+"km"; holder.name.setText(name); holder.location.setText(location); holder.description.setText...