module need to manage high-level functionality with zero implementation details this allows the module to be used for any type of application and for all modules inside the application.
we have an existing system which sends notifications to users by email
public class Email{public void sendMail(){// send mail
}
}public class Notification{private Email _email;public Notification(){_email = new Email();
}public void promotionalNotification(){_email.sendMail(); …
public interface someInterface{public int methodOne(){
// Do something}public int methodTwo(){
// Do somthing diffrent}}
if you want to implement this Interface
public someClass implements someInterface{public int methodOne(){
// logic to do something}public int methodTwo(){
}}
and only need to overwrite one method only why you forced to overwrite the other method and left it empty.
we solve this problem by creating two separate interfaces, every interface has only relevant methods.
public interface someInterface{public int methodOne(){
// Do…
Bad Example of LSP:
public class Bird{
public void fly(){}
}
public class Duck extends Bird{}
The duck can fly because it is a bird, But what about this:
public class Ostrich extends Bird{}
Ostrich is a bird, But it can’t fly, Ostrich class is a subtype of class Bird, But it can’t use the fly method, that means that we are breaking the LSP principle. …
if simple extensions to the requirements force massive changes to the software, then the architecture of that software is bad, and a good software architecture would reduce the amount of changed code to the barest minimum. Ideally, zero.
One of the most common User Experience (UX) issues in the Mobile Development track, is when you have input filed and the user finishes typing inside it and need to close the keyboard to continue with another thing, he/she can’t do simply with tapping out of input instead he/she forced to press back button, and this work against UX principles, you need to make using of your application done with familiar behavior for users, not forcing them to follow your rules this increase useability of your application.
If you have TextFiled or any input with some decorations like that:
as in the previous part, we discussed the rules of choosing names for variables, functions, class ...etc, let us take another step to something more important which is Functions, Function is the basic building block and the core of any system.
But first Let’s give an example to show the concepts that will be discussed. If you have a haystack and needle inside it, and you have to extract the needle from it, which case will need fewer efforts and time?
As mention in the previous part of the clean code, we discuss the problems of the speed coding and the desire to finish the product and bringing it to the market as fast as possible.
one of the most common issues that programmers make is Bad Naming.
chose appropriate names is part of everywhere in software. We name variables, functions, arguments, classes, packages, source files.
Because this task is repeated over and over, we need to find a better way to do it well, rather than naming randomly and make a mess, just by following some rules.
Choosing good names takes time but saves more than it takes. …
About