SOLID Principle

Different classes for Different Responsibility
public interface NotificationProcessor {

void processPayload(String payload);

int getNotificationId();


}
public class TxnNotificationProcessor implements NotificationProcessor {

@Override
public void processPayload(String payload) {
// put default implementation.....

}

@Override
public int getNotificationId() {
return NotificationIdGenerator.nextID();
}
}
public class PaymentNotificationProcessor extends TxnNotificationProcessor {

@Override
public void processPayload(String payload) {
// put Payment as txn implementation.....

}
public String getTxnAmount(){
// It will be full Payment Amount without any Tax deuction
}
}
Square is not Rectangle if sides are passed with different values
class Program
{
static void Main(string[] args)
{
Apple apple = new Orange();
Debug.WriteLine(apple.GetColor());
}
}

public class Apple
{
public virtual string GetColor()
{
return "Red";
}
}
public class Orange : Apple
{
public override string GetColor()
{
return "Orange";
}
}
class Program
{
static void Main(string[] args)
{
Fruit fruit = new Orange();
Debug.WriteLine(fruit.GetColor());
fruit = new Apple();
Debug.WriteLine(fruit.GetColor());
}
}
public abstract class Fruit
{
public abstract string GetColor();
}
public class Apple : Fruit
{
public override string GetColor()
{
return "Red";
}
}
public class Orange : Fruit
{
public override string GetColor()
{
return "Orange";
}
}
}
open class TrendingRepository @Inject constructor(
@com.example.hotrepo.di.scopes.RepoRemoteDataSource
private val remoteDataSource: RepoDataSource,
@com.example.hotrepo.di.scopes.RepoLocalDataSource
private val localDataSource: RepoDataSource,
private val ioDispatcher: CoroutineDispatcher = Dispatchers.IO
): BaseRepoRepository {
override suspend fun getTrendingRepoList(): Flow<List<TrendingRepoEntity>> =
localDataSource.getTrendingRepoList().flowOn(ioDispatcher)

override suspend fun doNetworkJob() : Resource<List<TrendingRepoEntity>?> {
return performNetworkOperation(
networkCall = { remoteDataSource.getNetworkRepoList() },
saveCallResult = { localDataSource.saveAndDeleteRepoList(it)}
)
}
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store