Stroustrup’s thoughts on future C++


Some rules that an applications programmer shall follow for keeping his code clean


computer ip address checker

A clean code

  1. contains classes that
    • are named with noun
    • are minimal, expressive, simple
    • do one thing well i.e. should have one, and only one reason to change
      (SRP:Single Responsability Principle)
    • are simple and direct
    • can be read like well-written prose
    • are literate
    • always look like they were written by someone who cares
  2. contains names that
    • are meaninful, intension-revealing
    • avoid disinformation
    • make meaninful distinction
    • are pronounceable
    • are searchable
    • are not encoded
    • don’t mappe mental
  3. contains methods that
    • are named with verbs or verb phrases
    • are minimal
    • do one thing
    • have one level of abstraction
    • respect the stepdown rule
    • have descriptive names
    • have the minimal number of arguments (zero is ideal)
    • have no side effects i.e. do only one thing at a time
    • don’t repeat themselves i.e. avoid duplication
  4. contains comments that
    • are legal
    • are informative
    • explain intents
    • clarify
    • amplificate
    • are not redundant
    • are not mandated/delegated
    • are not like a journal

View original post 136 more words


Lambdas v Closures


Scott Meyers posted this explanation of the difference between a lambda and a closure.

The distinction between a lambda and the corresponding closure is precisely equivalent to the distinction between a class and an instance of the class. A class exists only in source code; it doesn’t exist at runtime. What exists at runtime are objects of the class type. Closures are to lambdas as objects are to classes. This should not be a surprise, because each lambda expression causes a unique class to be generated (during compilation) and also causes an object of that class type–a closure–to be created (at runtime).

He also managed to squeeze in mention of Universal References (in the context of the managing the lifetime of a closure).

View original post


iDev: Statistical Formulas For Programmers


Linked List, Queue, and Stack Implementations in Python

Graham's Code

Screen Shot 2013-05-23 at 3.37.05 PM
# Programmer: Graham Nedelka
# Linked List, Queue, and Stack Implementations

import random

class Node(object):

def __init__(self, other = None):
self.other = other = None
self.previous = None

def __str__(self):
return str(self.other)

class List(object):
def __init__(self):
self.head = None
self.tail = None

def append(self, value):

newNode = Node(value)
if self.head == None:
self.head = newNode
self.tail = newNode

else: = newNode
newNode.previous = self.tail
self.tail = newNode

def __str__(self):
someString = “”
current = self.head
while current != None:
someString = someString + current.other
current =
return someString

class Queue(List):
def enqueue(self, value):

def dequeue(self):
self.temp = self.head
self.head =
return self.temp

class Stack(List):
def push(self, value):

def pop(self):
self.temp = self.tail
self.tail = self.tail.previous
return self.temp

def main():
list1 = List()
for i in xrange(0, 100):
print list1
queue = Queue()
for i in xrange(0,100):
for i in xrange(0,100):
print queue.dequeue()

View original post 26 more words