Coding Guidelines: Programmer’s Daily Bread and Butter

As we work in startup, we are under time pressure to release a lot of new features on time, features which do not have well defined requirements and the complexity of those features is often underestimated and we end up taking a lot of shortcuts / adding hacks to release such time sensitive features.

This may work for a short time, but over the period of time we realize that the same shortcuts that you took to release features quickly are now slowing you down. You can not scale and add new features on top of it, even if you do, they become quite unstable. In this situation you might want to take a step back and revamp/refactor you base system.

One of the easiest things that you can do to avoid this situation is follow coding guidelines.

Coding Standards

Well, what according to you is a good code? The simple definition could be: if it can’t be understood, maintained and extended by other developers then its definitely not a good code. The computer doesn’t care whether your code is readable. It’s better at reading binary machine instructions than it is at reading high-level-language statements. You write readable code because it helps other developers to read your code.

Naming conventions:

As the name suggests, it is a simple concept where you follow a specific naming conventions across teams. This becomes important when your team is growing and are solving problems on daily basis and pushing a lot of code every day.

camelcases vs underscore

This helps a lot when your team becomes big and a lot of developers are working on the same code-base. If you follow some fixed patterns while defining classes/functions/variables names, it becomes really easy for fellow colleagues to understand your code. This directly impacts delivery time taken by a developer to build/modify a feature on top of existing code. For example, let us suppose you want to define a time-stamp field in a database table, how would you name it ? If you have a fixed pattern like a “action_ts” or “action_at” for giving names then you can easily guess what could be the field name in the schema. If its a created time-stamp then it could be either “created_at” or “created_ts”. You do not have to go and check every-time you writing any logic over different database tables.

Function/Module/API writing (Size and Purpose)

Simplicity and readability counts. It’s always better to write to concise code than a messier one so that if any other developer is also looking at it who has no idea, should get what exactly it is doing. Not more than max 10–15 lines. Jenkins is considered as one of the greatest implementations, and has average function length of 2 lines.

A function/module should only do ONE thing and should do it NICELY. By following this, code becomes modular and it helps a lot in debugging. You can solve the problem better and debug faster when you know where exactly it’s coming.

When you are developing features over an established products, more than 50% times, new requirements are of the nature which you can build on top of existing code. In such cases, you can ship those requirements really faster and stable if existing code-base is modular and stable. Writing library functions a savior. There are countless advantages of writing a library code. It avoids code repetition, no surprises when it comes to response formats and of-course code re-usability.

Exception/Error Handling

Unknown errors are real pain in developers life. It’s always better if you know probable exceptions and errors in code in advance. But that is not the case always. Irrespective of all this, you definitely do not want your end-users to see unexpected errors on their screens.

When you have different micro-services and bigger development teams, if you follow standard response formats for across APIs and standard exceptions then there will not be any surprises in production. You can agree upon one format across all the services. Every API can have certain ‘response_data’ and standard set of error-codes. Every Exception will have an error-code and a message. Message could have variation viz, tech specific message and user facing message.

Writing test cases:

If you want to have a good night sleep, then you better have thorough test cases covering almost all aspects of your code. The best way forward with building test cases is at requirement stage only. Whenever a requirement comes, products managers discuss it with developers as well as QA. Both teams start preparing for possible use-cases and test-cases.

A testing unit should focus on one tiny bit of functionality and prove it correct. Each test unit must be fully independent. Each test must be able to run alone, and also within the test suite, regardless of the order that they are called. The implication of this rule is that each test must be loaded with a fresh data-set and may have to do some cleanup afterwards.

Automation plays an important role here. What else is needed for stable product where you have all test cases covered and running at intervals automatically, giving you a report of the all functionalities. Also, whenever you are adding/modifying code, you make sure either you write new test cases or modify existing ones.

coding

Code Reviews:

This one thing save lives, trust me! Every team can benefit from code reviews regardless of development methodology. Initially it takes time if you do not have a procedure setup of doing code reviews, but eventually it becomes a habit. Code review should be one of the core development steps.

Code review generally is about:

  • Does the new code conform to existing style guidelines?
  • Does the written piece of code covers all the use-cases specified in the requirements and has relevant test cases written ?
  • Are the new automated tests sufficient for the new code? Do existing automated tests need to be rewritten to account for changes in the code?

There are several advantages of this process such as –

Code reviews make for better estimates: Estimation is a team exercise, and the team makes better estimates as product knowledge is spread across the team. As new features are added to the existing code, the original developer can provide good feedback and estimation. In addition, any code reviewer is also exposed to the complexity, known issues, and concerns of that area of the code base. The code reviewer, then, shares in the knowledge of the original developer of that part of the code base.

Code reviews mentor new joiners: Code reviews help facilitate conversations about the code base between team members. During these conversations, team members share their views and new alternatives of doing things.

Code reviews take time: It’s an incremental process, where it takes time initially but as your code-base grows, it ensures, you are always pushing verified and tested code.

Hidden truth about code reviews: When developers know their code will be reviewed by a teammate, they make an extra effort to ensure that all tests are passing and the code is as well-designed as they can make it so the review will go smoothly. That mindfulness also tends to make the coding process itself go smoother and, ultimately, faster.

As a fast growing company our self, these set of guidelines have helped us a lot in shipping stable features on time and helping to increase a healthy learning environment.

Source:- Capital Float’s Medium Blog

More Related Posts

Card image cap
A digital prescription for the pharma industry

Must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness.

Oct 24, 2018

Card image cap
Budget 2017: Giving SMEs a stronger footing

SMEs play a crucial role in the economic development of India. They contribute to 45% of the industrial output, 40% of the exports and 42% of the employment in the country. Although these enterprises are highly significant to the economy, they are regularly challenged by policies, laws and processes In recognition of this, the Union Budget 2017 gave start-ups and SMEs a lot to cheer about.

Increasing Financial Viability with a Lower Tax Burden

Finance Minister Arun Jaitley announced a reduction in corporate tax from 30% to 25% for SMEs with an annual turnover of less than ₹50 crores. Moreover, the presumptive tax rate for SMEs with an annual turnover of up to ₹2 crores has been lowered from 8% to 6%. Both these measures would increase the bottom-line of SMEs. These enterprises work on low profits, and their survival is often threatened by even minor fluctuations in the business. The enhanced financial viability would increase the survival rate of SMEs.

At the same time, Budget 2017 has tried to align with the broader objective of increased digitalization. The proposed reduction in presumptive tax is applicable only for a firm’s gross receipts that are received via digital transactions. Also, no cash transaction above ₹3 lakhs would be permitted going forward. Both these measures have been designed to increase transparency and widen the tax base through digitalization.

Much Needed Breaks

Start-ups need maximum support during their initial years. From the next fiscal year, start-ups would have to pay taxes for only three out of seven years, up from last year’s exemption limit of five years, if they recorded profits. This is a great opportunity for start-ups and the economy. While a huge percentage of start-ups fail, these enterprises are responsible for introducing the most innovative products and services. The tax break announced by the Finance Minister would give start-ups a better fighting chance of survival and encourage more innovative ideas to be executed well.

Loans, Financing & Funding

The Finance Minister doubled the lending target to ₹2.44 lakh crores for the next fiscal year, making more credit available to small businesses to finance their working capital needs. Prime Minister Narendra Modi had already announced, on December 31, an increase in government credit guarantees for SMEs from ₹1 crore to ₹2 crores.

The FIPB (Foreign Investment Promotion Board) is to be abolished in the upcoming fiscal year. This would significantly liberalize policy related to FDI (Foreign Direct Investment). This is expected to boost retail and ecommerce in the country. Mr. Jaitley mentioned that further FDI relaxations were under consideration.

Most traditional banks are unwilling to give loans to SMEs due to the fear of defaults. Tax concession on provisions for non-performing assets (NPAs) and capital infusion of ₹10,000 crores for state-owned lenders would make loans more accessible to SMEs.

To encourage more investments into start-ups, the condition of continuous holding of 51% voting rights has been relaxed for carrying forward of losses by start-ups, provided the founder remains invested in the business.

Building on Digital India

While saying the almost 125 lakh people had adopted the BHIM digital payment app, the Finance Minister announced two new schemes – cashback for merchants and referral bonus for individuals.

Aadhaar Pay, the merchant version of the Aadhaar Enabled Payment System (AEPS), is to be launched shortly. This app would enable consumers to make payments without using cards, e-wallets or even mobile phones, since the merchant’s device would be linked to an Aadhaar biometric reader. More than a billion people in India already have Aadhaar cards, and this system would make most financial transactions simple, fast and traceable. It would be a boon for raising loans, enabling fintech lenders to link repayment to payments received by the SME.

The government would be targeting ₹2500 crore digital transactions in FY18 through BHIM, Aadhaar Pay, IMPS and debit cards. The Finance Minister indicated that banks would have to introduce 10 lakh new point-of-sale (PoS) terminals by March and 20 lakh Aadhaar-based PoS terminals by September, allowing more digital transactions, which would enhance financial inclusion and transparency.

Infrastructure

For the upcoming fiscal year, the Finance Minister announced a step-up in the total allocation for infrastructure development to an all-time high of ₹3.96 lakh crores, including increased allocations for railways, road and shipping. Infrastructural development eases a huge bottleneck faced by SMEs in transporting their goods to other regions in a timely and cost-effective manner. Better infrastructure would give confidence to SMEs to expand their markets farther and reduce wastage and spoilage during transportation.

Moreover, the roll out of GST (Goods and Services Tax), which the Finance Minister indicated was tracking as planned, would further increase the ease of doing business in other states.

An allocation of ₹10,000 crores towards the Bharat Net project was announced. This would increase access to high-speed broadband across India, facilitating communication and allowing SMEs to reach out to clients located in various corners of the country in a cost-efficient way. The geographic scale achieved will help SMEs to break physical boundaries and leverage bigger opportunities for growth.

The latest Union Budget comes as a respite for start-ups and SMEs. The strengthening of these businesses would play a critical role in India’s transition to becoming an economic superpower.

Oct 24, 2018

Card image cap
7 Reasons Why Merchant Cash Advance Is a Great Alternative to Traditional Finance

Businesses need additional finances either for growth in terms of scale or for expansion into newer product categories, or for geographical expansion. Sometimes, additional finances are also required for day-to-day operations. Going the traditional route via banks and financial institutions may not always work, especially for small business that are still in the process of building up their brand and market presence. The merchant can also withdraw from his/ her working capital loan. But, if the working capital limits are reached, and if the bank is unwilling to extend more working capital, then the merchant has to look for funds from other sources.

Fortunately, a whole new option of loans based on card swipes at POS terminals offers a great alternative to traditional finance. “Merchant cash advance” is a form of finance where sales from card machines can be used to raise loans. Merchants who allow their customers to pay with a credit or debit card can avail of such credit advance. Merchant cash advance loans are repaid by the POS partner on behalf of the borrower as a percentage of every sale registered on the POS machine.

When merchants accept credit/debit cards as a form of payment, the cards are swiped on a point-of-sale (PoS) terminal. Once the card and the sale amount is verified, the transaction is completed by entering a PIN number. Such sales are actually credit sales as banks credit the sale amount on the next day, or as decided with the merchant, after they deduct transaction charges.

There are several reasons why merchant cash advance is a great alternative to banks and other traditional lenders. Apart from the lengthy process and paperwork, the terms of traditional credit are much tougher for small businesses that have just set out on their entrepreneurial journey or are about to move into an expansion phase. Here is a quick look at why merchant cash advance loans are a better option for SMEs:

No collateral required

Merchant Cash Advance is a completely unsecured loan. The borrower isn’t required to pledge their property or assets to avail themselves of the loan.

Quick, easy loan disbursal

Merchant cash advance loans are usually disbursed easily and quickly as the onus to repay the amount is with the bank that provides the PoS terminal. Thus, merchant cash advance companies have to only ensure the regularity of the sales and the commitment of the merchant to be in business for the duration of the loan.

Hassle-free application

The borrower can apply for the loan by using a mobile device or a desktop, as long as the device is connected to the internet. The documents required can be scanned and uploaded at the time of the application. The borrower isn’t required to visit our office. This hassle-free application process provides for a comfortable experience to the borrower.

Assured repayment

As the onus to pay the instalment is with the provider of the PoS terminal, which is usually a bank, the merchant cash advance companies are reasonably assured of receiving repayments regularly, provided the merchant’s business has no issues. When the PoS terminal providers credit the merchant’s account with the proceeds of their credit card sales, they transfer a fixed percentage of these proceeds to merchant cash advance companies that have provided the merchant cash advance.

Flexibility of Repayment

The repayment of merchant cash advance loans can be pegged to the sales volumes. As a result, merchant can direct their PoS providers to pay less during low seasons. In the case of merchant cash advance loans, the merchants may also have the flexibility to structure their repayments to suit their ability to pay. Instead of making monthly repayments of the loan, they can opt to repay in weekly or fortnightly instalments as well.

Advance as a multiple of card sales

Merchant cash advance loans are ideal for merchants who have consistent credit/debit card sales. Merchant cash advance companies will first evaluate the credit worthiness of the merchant by verifying their past sales and business performance. Once merchant cash advance companies are satisfied, they will decide the basis of the loan advance and how much they can lend to the merchant. For example, Capital Float uses the monthly card settlement amount as the basis for deciding the loan amount. We lend up to 200% of the monthly sales made by the borrower from card swipes.

No pre-closure charges

Capital Float doesn’t charge the borrower any pre-closure charges if the borrower chooses to close the loan ahead of the agreed upon tenure. Additionally, we maintain complete transparency in fees and charges. The borrower is required to pay up to 2% of the loan amount as processing fees, while applying for the loan.

The usage of PoS terminals has significantly increased after the recent demonetization drive. The Government of India is pushing Indian banks to install PoS terminals so that the nation can progress towards becoming a cashless economy. With cashless transactions set to rise with card swipes and PoS machines, merchant cash advance loans will soon become a popular way of raising short-term funds to finance working capital requirements.

Capital Float is one of the few financial companies in India to offer merchant cash advance loans. We have already tied up with POS terminal vendors like Pine Labs, ICICI Merchant Services, Mswipe, MRL Posnet, Bijlipay, and more. We provide a merchant cash advance up to Rs. 1 crore for a convenient tenure of six months to one year.

Oct 24, 2018