- Side Effects are lies, promises one thing and does other hidden things unexpected changes to variable of its own class
- Avoid using output arguments
- Function should either do something or ans something, but not both
| //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'); |
| 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; |
| module.exports = function(arg){ | |
| var localArg = arg; | |
| while(typeof localArg === "function"){ | |
| localArg = localArg(); | |
| } | |
| return localArg; | |
| }; |
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