Skip to content
Advertisements

Tagcoding

How to Write Clean Code?

Basic Hygiene

  • Leave the place cleaner than you got it.

Naming Convention

  • Do one thing in a function. Name should reflect the action. Function name is a verb.
  • Declare literals ([a-z]+, [0-9]+) as constants.

Functions

  • The function should not exceed twenty lines.
  • Each if, else, while statement can become a function.
  • The function can have one or two levels of indentation.
  • A function must do only one thing. The one thing is discovered when function can’t be reduced further. The reduced name is similar to the function’s current name.

This post is updated until the book “Clean Code” completes!

Reference

Written with StackEdit.

C++: Max Product in a Matrix witout Backtrack

Problem

Given a matrix, find the path from top left to bottom right with the greatest product by moving only down and right.

The code is in C++.
The only moves allowed are down and right. The solution works for positive numbers.

Reference

Written with StackEdit.

%d bloggers like this: