Wednesday, 30 December 2020

SOLID Design principles in C#

If you have experience more than 8 years and you are going for interview then interviewer will certainly ask about SOLID. 

You read about SOLID but still you are not able to answer the questions as from SOLID concepts or you are confused by interviewer? Yes there are lot of things which confuses you and even many. 

 Let's discuss each principles one by one. Let's loot at the basic definition of the SOLID 

 1. S - S in SOLID stands for Single Responsibility Principle and we also call it SRP. So what is Responsibility ? In general english Responsibility means a duty to deal with something . Similarly in the programming, every class have its own responsibility, if we mix the responsibility of one class with another then your program might work correctly but you are messing with the code, you are loosing the code maintainability and many things. We will discuss more about this in separate discussion, but for now you can understand is as A class should be created only for doing one JOB for example if you have created class for Printing then your class should be only used for print functionality, you should not add methods which does something else like inserting data to database or calling some web api method. 

 2. O - O in SOLID stands for Open Close Principle and is single line we can say a class should be open for extension and closed for modification. Your class should be extendable without any modification. We also call it OCP. We will discuss more about this principle in other post with examples, its benefits, limitations and many more things.

Friday, 2 October 2020

WhatsApp New Search

WhatsApp recent update added few new features which are not noticeable but are of good use. I am going to explain one of the good feature recently added into both Android and iOS version.

So earlier versions of the WhatsApp  search only searches for the text. New Version now searches for Text, Images, Documents, Links and many more .

So when you tap on the search option, by default you can search for texts but if you want to search for Documents or Images then simply select the respective icon from the section below the textbox and search. It will search for the respective documents matching the search keyword.

For Android You will get below screen design 

For iOS, it appears as list and from that list you can select the respective search type

Gitlab Commands

When you create any project in Gitlab or Git then you can use below commands using shell/ command prompt to initialise and setup your source/version control 

First you have to to set it up the user name and login email id. Although when you create your first project in gitlab, you will see the Below commands but if you follow the instructions , you might get errors at some steps, I will provide details for those errors and how to fix those too.

Let's follow the below steps.

1. Git global setup
git config --global "<Your Name>"
git config --global "<your login email >"
2. Create a new repository
git clone<user_name>/<project name>.git
cd <your local project directory>
git add
git commit -m "add README"
git push -u origin master
3. Push an existing folder
cd existing_folder
git init
git remote add origin<user_name>/<project name>.git
git add .
git commit -m "Initial commit"
git push -u origin master
4. Push an existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin<user_name>/<project name>.git
git push -u origin --all
git push -u origin --tags
So, it might work for you always but for some Step 3 or 2 might throw below error.

remote: The project you were looking for could not be found.

fatal: repository '<user name>/<project name>.git/' not found

So, in order to resolve this, you need to modify the URL. You have to add your username in the domain as well . So it should look like 

https://<user_name><user_name>/<project name>.git

So replace the project URL in step 2, 3 and 4 if it doesn't work with default one.