How to create a README file

How to create README file for your git code

What is a README?

A well formatted text file that is used to document important information about your GIT project for any user who starts to use it for the first time.

Sample README.md file

Generally there is just 1 README.md file per project. But if needed it can also be created for each module in a project.

How to create a README?

Most commonly used format for README files are markdown language. That’s why you see a file extension ‘.md’. markdown language can be thought similar to HTML.

Steps to create a README.md:

When a new git project is created a blank markdown file README.md file is created automatically.

  1. Open the README.md file using a text editor. You can use text editor like Notepad, notepad++, Sublime etc.
  2. Edit the file using markdown language. Learn markdown language syntax from here.
  3. Commit the file to git to see the preview . Alternatively, you can use any editor like  Atom, Emacs, Sublime TextVim to create and preview the file.

You can also directly open the file in Git UI and edit it using the markdown language. Git UI also has an option to Preview the file .

That’s It !

Sample README File:

Find below the template of a README.md file written using markdown language syntax.

Copy the below to any text editor to begin creating your README.md file.

# Header H1
Header H1 is used to display the Project heading. 

## Sub Topic Headings H2
Sub Topic Headings H2 is used for sub sections like Configurations, Authors etc.

````
pip install boto
````

The above formatting is used to create a box which can display code or command in a well formatted manner.


## Usage

Below is another example of displaying
````python
import csv

with open("sample.csv","r") as csvinput: # read input csv file
    reader = csv.reader(csvinput) # create a reader
    for row in reader:
        print(row[0])
````

 

OUTPUT README :

The output of sample README.md after committing the file in git looks like below.

Markdown Syntax

As git README.md file is created using markdown language, learning some basic markdown syntax can be very useful to style your README.md file.

Learn syntax for the following most commonly used elements in the git README.md

  • Text formatting
  • List creation
  • Code block creation
  • Table creation

Text Formatting:

Bold: To create text as bold enclose it in double stars or double underscore.

Italic :  To create text as bold enclose it in single star or single underscore.

Syntax:

**bold** OR __bold__

*Italic* OR _Italic_

Output:

bold OR bold
Italic OR Italic

Lists:

Ordered lists: Markdown syntax for creating numbered list is just by putting numbers in front of each row.

Syntax:

1. One
2. Two
3. Three

Output:

  1. One
  2. Two
  3. Three

Unordered lists: Bulleted lists can be created using star or dashes.

Syntax 1:

* Star is used to create a bullet list item
* Item 2

Output:

  • Star is used to create a bullet list item
  • Item 2

Syntax 2:

- You can also use Dashes instead of stars
- Parent Item
 - Item 1
 - Item 2

Output:

  • You can also use Dashes instead of stars
  • Parent Item
  • Item 1
  • Item 2

Code Blocks:

Backticks are used to create code blocks .For inline code wrap it in single backticks.

Syntax:

`variable a = 20`

Output:

variable a = 20

For multiline code block : Use spaces for indentation & use 4 backticks for code blocks without indentation:

Syntax:

if(IndentationRequired)
print(“use 4 spaces”)

Output:

    if(IndentationRequired) 
        print(“use 4 spaces”)

Syntax:

````
if(IndentationNotRequired)
print(“use 4 spaces”)
````

Output:

if(IndentationNotRequired) 
print(“use 4 spaces”)

Create Tables:

Tables are created using dashes and pipes. Dashes are used to underline the headers and pipes are used to separate the columns.Check the example below.

Syntax:

Column 1|Column 2
--------------|--------------
Row element| Row element

Output:

Column 1Column 2
Row elementRow element

Summary

In this article, we learnt what is readme and we also learnt how to create a readme file for your project.
I hope you liked it !


Microservices Design Patterns

Today there is a growing demand for microservices in the market. It has become a go-to solution to build APIs and application. Designing microservices may also have architectural challenges. To avoid any design based difficulty in future a developer must know some common microservices design patterns for building microservices.

What are MicroServices?

It is an implementation of a functionality in the form of service, which is self contained and implements a single business capability.

Principles Behind Microservices

You need to know on what principles microservices are designed and architectured.

  1. Resilient Services – one service goes down, entire application doesn’t go down.
  2. Scalability
  3. Independent and Autonomous Services
  4. Availability – services are available 24×7
  5. Decentralization – control is not at one place, its segregated
  6. Real Time Load Balancing –
  7. Seamless API Integration and continous monitoring
  8. Isolation from Failures – error in one service will not affect others

Design Patterns

1. Aggregator

Collects Related Items of Data and displays them Based on DRY principle.

An aggregator design pattern is design in which it invokes various other microservices which further has different data stores from which they fetch required data. Then show the aggregated data.

2. API Gateway

API Gateway acts as an entry point to forward the clients requests to appropriate microservices. Then, with the help of the load balancer, the load of the request is handled and the request is sent to the respective services.

3. Chained Or Chain of Responsibility

Produces a single output which is a combination of multiple chained outputs. Request passed to all the services and output is collected from all services.

4. Asynchronous Messaging

All the services can communicate with each other, but they do not have to communicate with each other sequentially.

5. Database Or Shared Data

DB can be per service Or shared database

6. Event Sourcing

Creates Events Regarding the changes in the application state.

7. Branch

Branch microservices design pattern is that in which you process the requests and response from two or more independent microservices.

8. CQRS ( Command Query Responsibility Segregator)

In this design pattern the application will be divided into 2 parts, Command and the Query.
The Command part will handle CRUD operations and the Query part will handle the materialized views.

9. Circuit Breaker

This design pattern is basically to handle fail scenarios of the microservices, for instance if a service it down, the system will still request and wait for response, but using circuit breaker pattern, after receiving consecutive failures in response, the system will trip and any further request made to this service will fail, this will save performance of the system.

10. Decomposition

It is always a good idea to break your application into small units. With the help of this pattern, either you can decompose an application based on business capability or on based on the sub-domains.
Vine Pattern or the Strangler Pattern further helps in decomposing big monolithic applications into small units.

Summary

In this article, we learnt about Microservices Design patterns for microservices development and its importance, we also read about principles behind microservices and had a look at various types of design patterns.

I hope you liked it !