Tuesday, November 30, 2010

Algorithms every software developer must know

Basics in algorithms

What is Big O notation? (link Stackoverflow)
It is relative representation of the complexity of an algorithm

Sorting Algorithms

Sorting algorithms are often classified by
  • Computational complexity 
    • of elements in terms of the list size
    • of swaps
  •  Memory usage
  • Recursion
  • Stability
  • Adaptability

Popular sorting algorithms

Simple sorts : Insertion sort, Selection sort
Efficient sort: Merge sort, Heap sort, Quick sort
Bubble sort


Resources

http://stackoverflow.com/questions/33923/what-is-tail-recursion
http://stackoverflow.com/questions/tagged/algorithm

Tuesday, November 23, 2010

Modifiers in C#

Modifiers are used to modify declarations of types and type members. Following are the modifiers comes in C# (MSDN)

sealed #

  • In classes, sealed modifier prevents other classes from inheriting from it.
  • Can also use sealed modifier on a method or property that overrides a virtual method or property in a base class
    • Enables you to allow classes to derive from your class and prevent them overriding specific virtual methods or properties 
  • When applied to a method or property sealed must always used with override 
  • Structs are implicitly sealed, they cannot be inherited. This is because structs are value types 

virtual #



  • Virtual is used to modify methods, properties, indexers or event declarations and to be overriden in a derived class. 
  • virtual member can be changed in a derived class with override modifier. 
  • By default methods are non-virtual. Therefore you cannot override a non-virtual method. 
  • Virtual members are an implementation of type-based polymorphism. When you have a base class and a derived class, the derived class can re-implement the base class virtual method thus giving you dynamic entry point to the class type.
  • You cannot create private virtual members. You'll get virtual or private members cannot be private Exception.
  • virtual properties behave like abstract methods, with few differences.


http://www.dotnetperls.com/virtual

abstract #

  • indicates thing being modified has a missing or incomplete implementation
  • abstract method is implicitly virtual

default (SO)

  • For a reference type returns null
  • For a value type other than Nullable<T> returns 0 initialized value
  • For Nullable<T> returns empty value


const 

- Cannot change (compile time constants)

readonly

- Can change in the constructors. (runtime constants)


  • async
  • event
  • extern
  • new
  • override
  • partial
  • static
  • unsafe
  • volatile

Saturday, September 11, 2010

Principles in Software Development

When designing a software there are various principle you should follow 
to make the software better in different aspects. 
In this article we'll go through some of those principles.

Principle of least astonishment

Basically you should not astonish people when it comes to implementing something. For example if you have a method toString() which returns a string "not implemented", it is breaking of least astonishment principle. 

see wikipedia and Programmers - StackExchange 

Cargo cult programming
inclusion of a code or program which does not have any real purpose
wikipedia, Programmers SO 

GRASP

Consists of guidelines for assigning responsibility to classes and objects.  See this wikipedia article and this.

KISS (Keep it simple stupid)

States most systems works best if they are kept simple rather than complicating. Therefore simplicity should be a key goal in designing a system.

YAGNI (You aren't gonna need it)

It's a principle of Extreme Programming. It states that programmer should not add functionality unless deemed necessary. See wikipedia.


Other

Having a good software design is important to avoid bad design which will cause us very badly. According to Robert martin there a 3 things we must avoid when designing software.
  • Ridiglity : It's hard to change because changes affects too many other parts of the system
    • every change causes a cascade of subsequent changes in dependent modules. Can grow 2 day work to multiple weeks
  • Fragility : When you do a change, unexpected parts of the system breaks. Has a close connection with Ridiglity.
  • Immobility: It is hard to reuse component in another area of the application.
  • covariance and contravariance
Memoization 
In computing, memoization is an optimization technique used primarily to speed up computer programs by storing the results of expensive function calls and returning the cached result when the same inputs occur again.

source
Memoization in JavaScript


https://www.cs.utexas.edu/~scottm/cs307/handouts/deepCopying.htm

Tuesday, August 10, 2010

Introduction to Python

Python is an interpreted, high-level, general-purpose programming language. Instagram and Google uses Python in there backend. Over the years Python has grown its territory massively

Python can be used for

  • server to create web applications. 
  • can be used alongside software to create workflows. 
  • can connect to database systems. It can also read and modify files. 
  • can be used to handle big data and perform complex mathematics. 
  • can be used for rapid prototyping, or for production-ready software development.

You can install Python from website.

Recommend tool to use python with Visual Studio Code. You can install Python extension for ease of use. 

References
https://stackoverflow.blog/2017/09/06/incredible-growth-python/

Saturday, August 7, 2010

Do not break these User Interface Design Principles


Keep the following as a checklist next time when you're designing an interfaces

  1. Keep things clear without confusing the user
  2. Make user know what is preferred action is. Especially for new users
  3. Keep user interface interaction controls close to relevant content
  4. Keep good set of default settings
  5. Guide user on what they must do. Next
  6. Give feedback for interactions
  7. Breakdown complex actions into set of simple step by step action set


Resources
Photo credit : msdn

Tuesday, May 11, 2010

Creational design patterns

Factory

Provides an interface to create objects. Rather than creating new objects using new keyword, we ask the factory to create and return them for us. 

Factory in JavaScript : method1 (addyosmani) and method2 (carldanley)





Builder

http://www.oodesign.com/builder-pattern.html

Lazy initialization

Creation is deferred until it is first used. Useful for complex objects. 

C# : http://msdn.microsoft.com/en-us/library/dd997286%28v=vs.110%29.aspx


Object pool

Useful when cost of initializing a class instance is very high.  Therefore when requester requires an instance, he can get one of already created instance.

Prototype




Singleton 

http://stackoverflow.com/questions/327955/does-functional-programming-replace-gof-design-patterns?rq=1

Saturday, May 1, 2010

Introduction to Testing


Testing is a mechanism we use to evaluate whether the software we are developing satisfies the specified requirements. Testing is a very broad subject. Here we'll just look in to some high level overview of what it is.


Types of testing

  • Manual testing
    • Takes the role of an end user and checks for unexpected behavior 
    • There are few levels like unit testing, integration testing, system testing and user acceptance testing
    • Uses test plan, test cases or test scenarios to test
  • Automation testing
    • Also known as Test Automation
    • Testers writes scripts and use other software to do testing
    • Rerun test scenarios quickly and repeatedly
    • Use tools like Selenium, VS Test Professional, IBM Rationale function tester

Testing methods

  • Black box 
    • Without having any knowledge of interior workings of the application (UI level)
  • White box
    • Detailed investigation of internal logic
  • Grey box
    • Testing with limited knowledg

Sunday, April 4, 2010

Behavioral Design Patterns

Observer

Object (subject) maintains list of its dependencies (observers). Subject will then notify observers whenever any state change occurs in it. 

Related patterns are Publish-Subscribe pattern, mediator and singleton 
http://weblogs.asp.net/fmarguerie/events-references-garbage-collecting-memory-leaks-and-weak-delegates


Iterator



Mediator

Defines an object which encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects referring from each other explicitly.

http://www.dofactory.com/net/mediator-design-pattern  
Template method
http://www.oodesign.com/template-method-pattern.html
Null object

Strategy

Defines set of algorithms that can be used interchangeably. Basically you create an interface and derive implementations from that. Clients can couple themselves with the interface. 

http://robdodson.me/javascript-design-patterns-strategy/
http://sourcemaking.com/design_patterns/strategy

Command


Saturday, March 27, 2010

Basics in C#

C# is a multi paradigm programming language which has,

  • strong typing (error if argument pass to a function does not match expected type. See strong typing vs static typing)
  • imperative (statements which changes the state in contrast to functional programming- see diff)
  • declarative
  • functional
  • generic
  • object oriented and
  • component oriented 
program disciplines.

Data Types

Value type
Directly contain data in its own memory location
Each instance has its own copy of data
Value type can be divided into Simple, Enum, Struct and Nulllable types
http://stackoverflow.com/questions/1769306/why-are-net-value-types-sealed

Reference type
Stores a reference o the data (object)
Can be divided into Class, Interface, Array and Delegate types

It is not exactly true that value types goes on stack and reference types goes on the heap


Notes
A variable is an association between a name and a slot of memory. Variable has a value which the content of memory slot is associated with. The size depends on the type of the variable.

Value of a reference type is always a reference or null. If it's a reference it should be compatible with type of the variable. The slot of memory associated with the variable is size of the reference (Int32 : 4 bytes).

Value of value type is always data for an instance of the type itself. The slot of memory is large enough to hold its value (struct with 2 integers). Value type cannot have null. Null means variable of a reference type does not point to anything. 

local variables are stored on stack, including reference type variables. 

http://jonskeet.uk/csharp/memory.html

Mutable vs. Immutable 

  • Mutable : can change, Immutable : Cannot change
  • A mutable string can be changed, immutable string cannot
  • Immutable type is a class or struct written so that it cannot be changed once it is created. 
    • Once a string is constructed, it cannot be changed. All the functions you can call on a string return a new string, instead of manipulating the string they are called on
  • Instances of immutable types are inherently thread-safe (No thread can modify it)
  • source , mutable structs are evil
  • Always make value types Mutable (Eric Lappert)

Tuesday, March 16, 2010

Structural Design Patterns

Decorator

Allows behavior to be added to an individual object either statically or dynamically, without affecting the behavior of other objects from the same class. FileReader in C# is a good example for this. Also check this article from codeproject for C#. Explore the Decorator pattern in JavaScript

Source
Example

Facade

Provides simplified interface to larger body of code such as a class library. Checkout this article by dofactory for C# and addyosmani section for JavaScript.


Source

Composite

Describes that group of objects to be treated same way. The objective is to "compose" objects into tree structures to represent part-whole hierarchies.


Proxy

It's a class acting as an interface to something else. This can be a network connecting, web service or some other resource which is expensive or impossible to duplicate


Module pattern

See (http://en.wikipedia.org/wiki/Module_pattern)


Resources

http://en.wikipedia.org/wiki/Software_design_pattern

Tuesday, February 2, 2010

Web Services with ASP.NET

Web services provide infrastructure to create distributed computing applications. Simply web services resides in a web server and enables clients to invoke its methods. In .NET, clients can communicate with web services using proxies. Usually HTTP handlers are used to implement web services.
Source : developer.mulesoft.com
You can generate the proxy class using WSDL.exe if you have the web service description which conforms to WSDL. When you use this tool a single proxy class is generated. 

See creating an XML web service proxy (MSDN)
How to generate web service out of WSDL (SO)

WSDL (Web Service Definition Language)
Describes the web service

SOAP
It is a programmable application logic accessible via standard Web protocols. SOAP (Simple Object Access Protocol) is one example. SOAP uses XML for data description and HTTP for transport. 

SOAP message consists of,
  • SOAP envelop
  • SOAP headers
  • SOAP body
RESTful Web Services
RESTful web services does not contain any contract or WSDL file. It is simple to implement and supports different data formats (JSON, XML etc.)

Serialization in Web Services
Web Services use XMLSerialization for serializing response. 
https://msdn.microsoft.com/en-us/library/564k8ys4(v=vs.110).aspx

Resources
Powered by Blogger.


Software Architect at Surge Global/ Certified Scrum Master

Experienced in Product Design, Software Engineering, Team management and Practicing Agile methodologies.

Search This Blog

Facebook