Skip to content

Instantly share code, notes, and snippets.

View tarekahsan709's full-sized avatar
:octocat:

Tarek Ahsan tarekahsan709

:octocat:
View GitHub Profile

কিছু সাধারণ কারণ যার জন্য ডিজাইন প্যাটার্ন দিয়ে রি-ডিজাইন করার প্রয়োজন:

##১. একটি সুনির্দিষ্ট ক্লাসকে উল্লেখ করে অবজেক্ট তৈরী করা। কোনো ইন্টারফেসের পরিবর্তে আমরা যখন কোন সুনির্দিষ্ট ক্লাসের নাম উল্লেখ করে অবজেক্ট তৈরী করি তাহা আমাদের একটু বদ্ধ নির্দিষ্ট পথে ধাবিত করে। এই নির্দিষ্ট পথে ধাবিত হাওয়া উক্ত অবজেক্টের পরবর্তী কোন পরিবর্তন অনেক জটিল করে তুলতে পারে। এই সমস্যা থেকে দূরে থাকার জন্য আমাদের অবজেক্ট গুলো অপ্রত্যক্ষ ভাবে তৈরি করা উচিত।
####রেফারেন্স ডিজাইন প্যাটার্ন : অ্যাবস্ট্রাক্ট ফ্যাক্টরি , ফ্যাক্টরি মেথড , প্রোটোটাইপ।

২. নিদিষ্ট কাজের উপর নির্ভর করা।

যখন আমরা একটি কাজ নির্ধারণ করি তখন সেটা এক ভাবেই সমাধান করার করার চেষ্টা করি। আমরা হার্ড কোডে সে কাজটি না করে বরং কাজটি সমাধানের পথ পরিবর্তন করে কম্পাইল এবং রান টাইমে তা সহজে সমাধান করতে পারি । ####রেফারেন্স ডিজাইন প্যাটার্ন : চেইন অফ রেস্পন্সিবিলিটি , কম্যান্ড।

৩. হার্ডওয়্যার ও সফটওয়্যার প্লাটফর্মের উপর নির্ভর করা।

বিভিন্ন হার্ডওয়্যার ও সফ্টওয়ারের এক্সটার্নাল অপারেশন সিস্টারমের ইন্টারফেস এবং এপ্লিকেশন প্রোগ্রামিংয়ের ইন্টারফেস এক না

#What is promise ? ####A promise is a special type of Object that we can either use, or construct ourselves to handle asynchronous tasks.A promise has three states, pending, resolved or rejected. ####How to create ES2015 promise

let promise = new Promise((resolved, reject) =>{
        if(/*Some asynchronous task*/){
            resolved('Sucessfull');
        } else {
            reject('Something went wrong');
        }

The difference between angular js service and factory.

Service and Factory both just a simple function. Service acts as a constructor function but Factory is really just a function that gets called, which is why we have to return an object explicitly. We can create & return anything that's why Factory is much more powerful and flexible.

reference: https://toddmotto.com/factory-versus-service

Here's example of Service

app.service('MyService', function () {
  this.sayHello = function () {
    console.log('hello');
  };

In JavaScript, scope is the set of variables, objects, and functions that you have access. In the other hand current context of your code.

Scope can be global, local, functional, public, private and lexical.

Lexical scope - A function within another function, the inner function has access to the scope in the outer function, this is called Lexical Scope or Closure - also referred to as Static Scope.

// Scope A
var myFunction = function () {
  // Scope B
  var name = 'Todd'; // defined in Scope B
  var myOtherFunction = function () {
 // Scope C: `name` is accessible here!

We can create object in javascript using constructor. By conention constructor name should be in uppercase. The created object will get all the define property as well as a hidden property called prototype. Which is also a object and it's value either null or object. The constructor will have its this variable bound to a newly created fresh object.

function Student (name, id) {
  this.name = name;
  this.id = id;
  this.details = function (){
    return "Name of the object " + this.name + " and it's id " + this.id;
  }
}

We can add getter & setter in javaScript object like normal properties but secretly have methods associated with them.

var Student = {
	name: "Default",
	type: "Student",
 	get Name(){
  	return this.name;},
	set Name(name){
	 this.name = name;
 },
AngularJS Back To Top Directive.
Uses AngularJS, jQuery, Font Awesome, and SCSS.