I am starting to write this blog to track my progress of learning and documenting for future reference.

To be a better developer we should not only write code for sake of it but it should be easy to understand, scalable, reliable. For that, I will be summarizing the content of each chapter of the Clean Code Book.

Day 1 :

What I have learned today in brief: Naming conventions from Clean Code

The name should tell the intent

Use Searchable Names

Use Pronounceable Name

Don’t encode type in names Ex : phoneString, paymentInt

Avoid Prefixes to Names Ex: IshapeFactory

Don’t use the same name to mean two different things

Use Domain-Specific Name Ex: JobQueue, nameBuilder

Avoid Too Long Names

Day 2:

What I have learned today in brief: Heap Data Structure

a Heap is a special type of binary tree. A heap is a binary tree that meets the following criteria:

Is a complete binary tree;

The value of each node must be no greater than (or no less than) the value of its child nodes.

Classification of Heap

There are two kinds of heaps: Max Heap and Min Heap.

Max Heap: Each node in the Heap has a value no less than its child nodes. Therefore, the top element (root node) has the largest value in the Heap.

Min Heap: Each node in the Heap has a value no larger than its child nodes. Therefore, the top element (root node) has the smallest value in the Heap.

A Heap has the following properties:

Insertion of an element into the Heap has a time complexity of O(\log N)O(logN);

Deletion of an element from the Heap has a time complexity of O(\log N)O(logN);

The maximum/minimum value in the Heap can be obtained with O(1)O(1) time complexity.

First, we will cover Insertion in Max Heap and Min Heap:

Max Heap Insertion :

Suppose the Heap is a Max-Heap as:

10

/ \

5 3

/ \

2 4

The new element to be inserted is 15.

Process:

Step 1: Insert the new element at the end.

10

/ \

5 3

/ \ /

2 4 15

Step 2: Heapify the new element following bottom-up

approach.

-> 15 is more than its parent 3, swap them.

10

/ \

5 15

/ \ /

2 4 3

-> 15 is again more than its parent 10, swap them.

15

/ \

5 10

/ \ /

2 4 3

Therefore, the final heap after insertion is:

15

/ \

5 10

/ \ /

2 4 3

Min Heap Insertion

Suppose the Heap is a Min-Heap as:

2

/ \

3 4

/ \

5 6

The new element to be inserted is 1.

Process:

Step 1: Insert the new element at the end.

2

/ \

3 4

/ \. /

5 6. 1

Step 2: Heapify the new element following bottom-up

approach.

-> 1 is less than its parent 4, swap them.

2

/ \

3 1

/ \. /

5 6. 4

-> 1 is again more than its parent 2, swap them.

2

/ \

3 1

/ \. /

5 6. 4

Therefore, the final heap after insertion is:

1

/ \

3 2

/ \. /

5 6. 4

In case of any query please put ur comments. See you soon :)

Day 3:

Today I have contributed to open source for the first time, basically put some comments on open PR and wrote down a few good coding practices. I think we learn also a lot by reading someone else’s code.

1) Junit test cases how we can better use never() method.

2) The usage of @Nullable is to let a user and the compiler know it is fine to allow a null value in as that parameter.

I believe it is a more straight-forward way of letting a user looking at your API to know that passing null will not create an NPE or undefined behaviour.

For a setter, if that field is going to be used in many places, it would be nice to look at its setter and discover null is handled.

That being said I think it should only be used for API's or libraries, using them in your own code would create too much useless code.

3) Using Jdoc it's better to see what parameters it accepts and what its return value is. It gives a clear cut idea about its acceptance of input and return of output.

Example:

/**

* Delegates the call to the {@code createContext(sessionMode)},

* using the {@link JMSContext#AUTO_ACKNOWLEDGE} as a value (JMS specification compliant).