Skip to content

Instantly share code, notes, and snippets.

View ninadhatkar's full-sized avatar
🎯
Focusing

Ninad Hatkar ninadhatkar

🎯
Focusing
View GitHub Profile
@ninadhatkar
ninadhatkar / system-design.md
Last active September 17, 2024 05:39
Designing a system from scratch and ensuring its smooth first deployment involves several key phases. Here's a step-by-step approach that incorporates both system design principles and deployment processes:

Designing a system from scratch and ensuring its smooth first deployment involves several key phases. Here's a step-by-step approach that incorporates both system design principles and deployment processes:

1. Requirement Gathering

Identify Stakeholders: Understand who will use the system and their needs. Functional Requirements: What the system should do (e.g., user actions, input/output). Non-Functional Requirements: Performance, scalability, security, reliability, compliance. Assumptions & Constraints: External factors like budget, time, existing systems, compliance regulations, and hardware limitations.

2. High-Level System Design

Functions:

Side Effects

  • Side Effects are lies, promises one thing and does other hidden things unexpected changes to variable of its own class

Output Arguments

  • Avoid using output arguments

Command Query Separation

  • Function should either do something or ans something, but not both

Prefer exception to returning error code

module.exports = function(arg){
var localArg = arg;
while(typeof localArg === "function"){
localArg = localArg();
}
return localArg;
};
var curry = function(fun) {
var argLen = fun.length;
return (function currying(){
var memory = Array.prototype.slice.call( arguments );
return function () {
var local = memory.slice();
Array.prototype.push.apply( local, arguments );
if(local.length === argLen) {
result = fun.apply(null, local);
return result;
//Sample code of a plugin file to understand the usage of 'req.contentstack.get(key)'
/*!
* myplugin
*/
"use strict";
/*!
* Module dependencies
*/
var contentstack = require('contentstack-express');