Skip to main content

Posts

Showing posts from 2014

Extending Object Oriented Programming concepts further with abstraction and interfaces

Few days back I wrote for Solid and Grasp principles for oops http://www.developerscloud.org/2014/08/oops-beyond-four-pillars-solid-and-grasp.html . Now I am again extending it to make it more matured way to write code. Let start with coupling and cohesion. Loose/Low Coupling low dependency between classes; low impact in a class of changes in other classes high reuse potential High Cohesion measure of how strongly-related or focused the responsibilities of a single module are If methods of a class tend to be similar in many aspects, then the class have high cohesion In highly-cohesive system, code readability and the likelihood of reuse is increased, while complexity is kept manageable. Also check Encapsulate what varies Favor Composition over Inheritance Program to interface not implementation Strive for loosely coupled design between objects that interact For Interfaces Like an abstract base class: any non-abstract type inhe...

OOPs beyond the Four Pillars - SOLID and GRASP

As we know  Object oriented programming is a type of programming paradigm based around programming  classes  and instances of classes called  objects . These can be objects that appear on the screen (e.g., pictures, textboxes, etc.) or are part of the programming (e.g. actors, connections, particles, etc as mentioned in my post  http://www.developerscloud.org/2013/02/what-is-oop-basic-concepts.html   written ages ago. Here we are going to extend the oops beyond its four pillars i.e. Abstraction Encapsulation Polymorphism  and Interfaces i.e.  Inheritance So first we will go through  SOLID and then GRASP SOLID Principles are principles of class design. • S RP: Single Responsibility Principle – An object should have only a single responsibility & all the responsibility should be entirely encapsulated by the class. – There should never be more than one reason for a class to change • O CP: Open/Closed Principle ...

Unit Testing, In a right way.

This blog is aimed at those developer who have little development and unit testing experience. Please refrain yourself to proceed if you don't know development. What is Unit Testing ? By Definition, In computer programming, unit testing is a method by which individual units of source code are tested to determine if they are fit for use. A unit is the smallest testable part of an application. In procedural programming a unit may be an individual function or procedure. Unit tests are created by programmers or occasionally by white box testers. Some Benefits of Unit Testing: Bug Tracking Code Maintenance Understandable code How the above things help in actual scenario ? Suppose you have developed a code from scratch and it went to maintenance. Now you left the company, there are no unit test written and a bug came via customer. The app went for a hot fix and some other guy fix it, and  his fix created another which in turn creates another issue. So the creation of i...

Decoding the date sorting in Javascript, efficient faster and native way.

Coming from the previous post  (   http://www.developerscloud.org/2014/05/decoding-underscore-js-sortby-sorting.html ) ,  where we have used the underscore to sort the array, with the limitation of sorting in descending order, I will show you in below post how to sort effectively using javascript native functionality. Lets use the same array we have in the previous post. var datesArray = ['6-01-2014','2-01-2014', '4-01-2014', '5-01-2014', '3-01-2014', '1-01-2014']; datesArray is now [" 6-01-2014 ", " 2-01-2014 ", " 4-01-2014 ", " 5-01-2014 ", " 3-01-2014 ", " 1-01-2014 "] Running the for loop making each item of array a date type object. for(var i = 0; i< datesArray.length; i++){ datesArray[i] = new Date(datesArray [i]); } After which datesArray will become [Sun Jun 01 2014 00:00:00 GMT+0530 (India Standard Time), Sat Feb 01 2014 00:...

Decoding underscore js SortBy - Sorting in javascript

Sorting can be the developers worst nightmare especially if it is done in more then one field. So what can help, recently doing research on it I came across underscore js sortBy (underscorejs.org/#sortBy) function which will help you to sort the array very effectively. So I was going through the documentation and found it very useful, but there are one drawback of it. Will let you know that: How to order in Ascending Order _.sortBy([6, 2, 4, 5, 3, 1], function(num){ return num }); [ 1 , 2 , 3 , 4 , 5 , 6 ] How to order in Descending Order _.sortBy([6, 2, 4, 5, 3, 1], function(num){ return -num }); [ 6 , 5 , 4 , 3 , 2 , 1 ] The underscore sort by will also work with string literals Ascending _.sortBy(['6','2', '4', '5', '3', '1'], function(num){ return num }); [ " 1 " , " 2 " , " 3 " , " 4 " , " 5 " , " 6 " ] Descending _.sortBy(['6','2'...

Reflection in Dot Net (.Net)

According to msdn , putting all the definition at one place:- Reflection provides objects (of type Type) that encapsulate assemblies, modules and types. A type represents type declarations: class types, interface types, array types, value types, enumeration types, type parameters, generic type definitions, and open or closed constructed generic types.  You can use reflection to dynamically create an instance of a type, bind the type to an existing object, or get the type from an existing object and invoke its methods or access its fields and properties. If you are using attributes in your code, Reflection enables you to access them. Below is the code example for it. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Reflection; namespace reflection {   class Program    {      static void Main( string [] args)        {        ...

Refresh the Jquery Css for a HTML control using knockout in Javascript.

If you are a JavaScript developer then you might have come across a situation where you load your HTML controls after the page load has happen, which is like dynamic binding of controls. And then you see your input type text doesn't have the proper Css as other inputs. You also load select (dropdown)  that also doesn't have the proper css. You are in chrome and press F-12 to inspect the element, y ou see that nothing is there in control, it is not applying the JQuery css. But the controls that are loaded in page load have it. What to do, no options just to manually copy the CSS classes. VERY BAD IDEA? Just do this, In HTML < input type ="date" data-bind ="i nputsRefresh: $element, value: $data.EndDate " /> and in JS binding handler

JavaScript is too cool and so is the inheritance.

I can say million words about Javascript, it is so cool. We will start with the   inheritance  in the JAVASCRIPT which will make our concepts a little shaky as it implements prototypical inheritance which are not bad the point is we are not used to code in JS. As almost everyone in this world are from JAVA or .NET background. Inheritance is an important topic in most programming languages. In the classical languages (such as Java), inheritance (or extends) provides two useful  services. First, it is a form of code reuse. If a new class is mostly similar to an existing  class, youonly have to specify the differences. Patterns of code reuse are extremely  important because they have the potential to significantly reduce the cost of software  development. The other benefit of classical inheritance is that it includes the  specification of a system of types.  This mostly frees the programmer from having to  write exp...

SQL Joins

The JOIN keyword is used in an SQL statement to query data from two or more tables, based on a relationship between certain columns in these tables. Tables in a database are often related to each other with keys. A primary key is a column (or a combination of columns) with a unique value for each row. Each primary key value must be unique within the table. The purpose is to bind data together, across tables, without repeating all of the data in every table FULL OUTER JOIN A JOIN is made matching a column on a table to a column on the other table. After a FULL OUTER JOIN, for a given value (red), for a given row with this value on one table ([ red | 9999 ]), one row is created for each row that matches on the other table ([ red | OOOOOO ] and [ red | LLLLLL ]). If a value exists in only one table, then a row is created and is completed with NULL columns. FROM table_1 FULL OUTER JOIN table_2 ON table_1 . common_value = table_2 . common_value ...