Monday 30 December 2013

Angularjs Simple example

Hello Everyone
 In this tutorial you are going to learn about angularjs with a basic program.
 Angularjs works on SPA framework which means single page application. To run the following
program all you need is to download angular.min.js and save it in the folder which contains 
the following file. Following programs itself explains through comments how angularjs is 
working, It displays a textbox and whatever being entered in the textbox will be displayed 
on the right of the textbox.
 
<!DOCTYPE html>
<html data-ng-app=""> <!-- Here data-ng-app is a directives which tells the
 html new tricks--> 
 <head>
 <title>Learn Angularjs</title>
</head>
<body >
Name : <input type="text" data-ng-model="name"/>{{name}}  <!-- this defines a textbox with variable name - 'name' and {{name}} output the text of the textbox being entered in it by the user. data-ng-model is a directive and {{name}} is a data binding expression -->
<div data-ng-init="names=['ajeet','ankit','bihar','rahul','sunny','chitrank']"> <!-- This div initialises the array 'names'-->
 <br>
 <ul>
  <li ng-repeat="dcmember in names">{{dcmember}}</li> <!-- ng-repeat directives repeats the elements of the array to be listed by the variable dcmember in the array names-->
 </ul>
</div>
<br>
<div data-ng-init="customers=[{name:'ajeet',city : 'Mhow'},{name :'ankit',city : 'Dewas'}]">  <!-- Here customers is an array which consist of name and city of the customer-->
 <input type="text" data-ng-model="nametext">{{nametext}}
  <ul>
   <!--filter will display the result according to the text being entered in the textbox, orderBy will display the list in alphabetical order according to city-->
   <li ng-repeat="cust in customers | filter: nametext | orderBy :  'city'" >{{cust.name}} - {{cust.city}}</li>
  </ul>
</div>
<script type="text/javascript" src="angular.min.js"></script>
</body>
</html>

Monday 23 December 2013

Introduction to javascript

Introduction to javascript : 1

Javascript is a very easy to learn language.

1. Printing text to console:
write the text in double quote which you want to print to console
ex. "This text will be printed on console";

2. Counting length of the string:
use length function to count the length of the string
ex. "sample".length;

3. Data types in javascript:
There are data types in many languages like numbers, string etc.
In JavaScript also there are data types like numbers and string.
The numbers written without double quotes are number ex. 43, 78.9.
The text written within double quotes are considered as string ex. "43", "javascript"

4. confirm function :
Confirm function is used to take response from the user for a particular action.
A confirm box appears on the screen with some display text, ok and cancel button.
ex. confirm("try again?");

5.Prompt function :
Prompt function provides interaction with user. It provides a input box to take input from the user.
ex. Prompt("What is your name?");

Saturday 15 June 2013

Coding to Send Email on a Button Click With and Without attachment

 
Private Sub sendbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sendbutton.Click
        If con.State = ConnectionState.Open Then
            con.Close()
        End If
        Try
            Dim mail, atchmail As New MailMessage
            mail.Subject = subjecttextbox.Text
            mail.To.Add(totextbox.Text)
            mail.From = New MailAddress(usernametextbox.Text)
            mail.Body = bodytextbox.Text
            If attachmenttextbox.Text <> "" Then 'If attachment is there than this code will be executed
                Dim attachment As System.Net.Mail.Attachment
                attachment = New System.Net.Mail.Attachment(attachmenttextbox.Text)
                mail.Attachments.Add(attachment)

                Dim smtp As New SmtpClient("smtp.gmail.com")
                smtp.EnableSsl = True
                smtp.Credentials = New System.Net.NetworkCredential(usernametextbox.Text, passwordtextbox.Text)
                smtp.Port = "587"
                smtp.Send(mail)
            Else 'If there is no attachment than this code is executed
                Dim smtp As New SmtpClient("smtp.gmail.com")
                smtp.EnableSsl = True
                smtp.Credentials = New System.Net.NetworkCredential(usernametextbox.Text, passwordtextbox.Text)
                smtp.Port = "587"
                smtp.Send(mail)
            End If

            MsgBox("Message Sent Successfully", MsgBoxStyle.Information)
            totextbox.Clear()
            subjecttextbox.Clear()
            bodytextbox.Clear()
            attachmenttextbox.Clear()
            usernametextbox.Text = "sample_email@gmail.com"
            passwordtextbox.Clear()
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
        

    End Sub

Crystal Report Chart Expert showing Count instead of Sum

Sometimes in crystal report while showing a bar chart if we want to show the sum or average of some values other than count, the chart expert may not show you all the summary option like average, sum, mode etc. Though the coding is correct and no error is displayed its just that the chart expert doesn't show the summary option other than count or distinct count. This is because the value for which you want to display average or sum is not of desired data-type, for example, if we want to display marks on the change of roll no. than marks should be of data-type like integer or double rather than choosing the data-type like string. So just check the data-type to get rid of this problem.
Happy coding :)

Tuesday 28 May 2013

Inheritance And Its Types

As described in the previous post, Inheritance is the mechanism of deriving a new class from an existing class. It is also known as derivation. The derived class is also known as subclass and the class from which it is derived is known as super-class or base class.There are basically five types of inheritance which are as follows :
  1. Single Inheritance - If only one class is derived directly from the existing class than the inheritance is known as single inheritance. In this there is only one base class and only one derived class or base class. For example :  class 'B' is derived from class 'A' than A is super class and B is derived class. 
  2. Multilevel Inheritance - If a class is derived from another class which itself is derived from some other class than this type of inheritance is known as multilevel inheritance. In this there are two base class and two derived class. For example : class 'C' is derived from class 'B' and 'B' itself is derived from class 'A'.
  3. Multiple Inheritance - If a class is derived directly from two or more classes than this type of inheritance is known as multilevel inheritance. In this there is only one derived class and two or more base classes are there. For example : class 'D' is derived directly from class 'A' , 'B' and 'C'.
  4. Hierarchical Inheritance - If the derivation of class is in the form of hierarchy in which two classes are derived from one class and the two derived classes are the base class of some other classes too, than this type of inheritance is known as hierarchical inheritance. 
  5. Hybrid Inheritance - If a class derived by two class via multilevel inheritance and it is also derived from some other  class which are different from those two class, than this type of inheritance is known as hybrid inheritance. For example : 'C' is a class derived from 'B' and 'D' and 'B' is derived from class 'A'.
          These were the introduction about Inheritance. More details with examples will be discussed in the upcoming posts.                                                            


Saturday 25 May 2013

Concept of Object Oriented Programming languages

Object oriented programming languages uses some concept extensively which are as follows :
  1. Object - An object is a real world entity that have some characteristics and behavior. Objects are run-time entities. Object represents instance of its class. An objects can be defined as the collection of data members and member function of its class. A class can have more than one instance that means a class can have more than one object which may hold their relevant information or data. If a class name is declared than the object of that class must exist to access its properties. For example: A class "Vehicle" can have some properties like vehicle name, registration number etc., these properties are only accessible by the objects of the class vehicle.
  2. Class - A class is a data-type according to which objects are created or a class can be defined as a collection of objects which possesses same characteristics or properties. A class contain data members and member function which are accessible by its objects. For example : Person is a class which have some characteristics like two eyes two legs etc. and Rohan can be considered as its objects who possesses these characteristics.
  3. Abstraction/Encapsulation - Abstraction means hiding the unnecessary details and showing the essential details and encapsulation means wrapping up of data into a single unit called class. In a class all the data and methods of that class are wrapped up into a single unit called class and only the objects of that can class can access private data and the methods which operate on that data. For example : In a car only essential things are visible to the user like steering, gear, clutch etc and not the details like how the steering is moving the wheels internally or how the gear is changing internally.
  4. Inheritance - It is the process of making new class from an existing class or it is the process of transforming the properties from one class to another class. The new class formed is known as derived class and the class from which the class is derived is known as super class or base class. Inheritance are of types : single level, multilevel, hybrid, hierarchical. These are explained in the next post.
  5. Polymorphism - Polymorphism means single name multiple forms. It allows methods or variables to have different meaning for different objects. According to greek terminology it is the ability to take more than one form. overloading is an example of polymorphism.
  6. Dynamic Binding - It is the the ability to of the objects to recognize its class/method at runtime. Dynamic binding is explained in upcoming post with example program.
  7. Message passing - It is the ability of objects to communicate with each other. It is one of the important features of the object oriented programming languages which allows communication from one place to another in a program.

Thursday 23 May 2013

Object Oriented Programming Language

Object oriented paradigm can be describes the concept as 'objects', a real world entity which have some characteristics and behavior. characteristics are some attributes possessed by an object and behavior means the procedure associated with that object. An object oriented program consist of interacting objects which can interact amongst themselves to process the data. Objects are composed of nouns and verbs. Object oriented programming language follows bottom-up approach. In this, objects may be are of different types and number of objects of a particular type are known as instance of that type. Now days there are number of languages that are object oriented in nature but the first object oriented was SIMULA which was developed in 1960.
Some features of object oriented programming paradigm are :
1. Programs are divided into objects.
2. It focuses on data rather than  procedure.
3. Data structures are designed to characterize objects.
4. Methods that operate on data are tied together in the data structure.
5. Data can't be accessed by external methods.
6. Follows bottom-up approach.
7. Objects can communicate with each other.
8. New data and methods can be added.

Object oriented programming language uses some concepts which are as follows :
1. Objects
2. Classes
3. Abstraction
4. Inheritence
5. Polymorphism
6. Dynamic binding
7. Message passing

These concepts are described in the next post.

Procedural Programming Language

Procedural programming means the steps a program must follow to give the desired output. Procedural programming is also called imperative programming and structured programming. It is based upon the concept of procedural call. A procedure is a method, function, routine or a subroutine which contain some number of steps to accomplish a particular task. A procedural program consist of some steps which executes in linear order to give the desired output. It follows top-down approach. In procedural programming language the program is divided into variables, data structures and sub-routines. Data is given for input with the help of procedure call by passing the values in form of arguments and obtaining the output with the help of return statements. It gives less security of data/information as data is not encapsulated. Examples of procedural programming languages are C, C++,  pascal, Fortran, BASIC etc.

Wednesday 22 May 2013

Programming Languages


Programming language is a language developed to communicate with machine or computer. Programmming languages are used to
express algorithms and to interact with machine more precisely with computers. Programming languages are used to write programs
that performs some kind of task/operations.

Programming language has two parts one is syntax and second is semantic. Syntax means what is the form of programming language or the
rules or grammar that governs the way of writing the program. Semantic means what is the meaning of an expression in the program.
Take an example :
c=a+b;
Here '=' is an assignment operator and ';' semicolon specifies termination of the statement. This is known as syntax of the program.
Here the meaning of statement is add 'a' and 'b' and store the result of addition in 'c'. This is known as semantic of the program.


There is a big list of types of programming languages but we are discussing here 3 mejor types of programming languages:

Low level programming language
High level programming language
Very high level programming language

Low level programming language:
Low level programming language is closely related to the machine in which it is built i.e. low level programming languages are machine oriented programming language and it requires intensive and extensive knowledge of computer hardware and its configurations.
Low level programming languages needs no compiler or interpreter to be converted into machine code. A program written in low-level language can be made to run very quickly, and with a very small memory space.Low-level languages are simple, but are considered difficult to use due to various technical information must be remembered.
Low-level languages are further divided into two categories: First generation and second generation.

Machine language: Machine language is the only language which is directly understood by computer and it does not require any kind of translator program. It is also known as machine code and it is t combination of various 0's and 1's. For example, a program instruction may look like this:
1011000111101
It is considered to the first generation language.It is not an easy language for you to learn because of its difficult to understand.
Its only advantage is that program of machine language run very fast because no translation program is required for the CPU.

Assembly Language:
It is the first step to improve the programming structure.Computer can handle numbers and letters, therefore some combination of letters is substituted to numbers of machine code.
The set of symbols and letters forms the Assembly Language and a translator program is required to translate the Assembly Language to machine language. This translator program is called `Assembler’. It is considered to be a second-generation language.
Here is an example of assembly language to reverse the bits of a byte:


       ORG      $400

       MOVE.B   Test,D0       Get the string to reverse

       MOVE.B   #7,D7         Use D7 as a loop counter for 8 cycles

       CLR.L    D1            Use D1 to catch the reversed bits

Shft   LSL.B    #1,D0         Shift the byte one place left � catch ms bit

       ROXR.B   #1,D1

       DBRA     D7,Shft       Repeat 8 times

       STOP     #$2700        Stop execution

Test   DC.B     %11001010     Test string


High-level Programming language:
As we learned that machine language nad assembly language require a deep knowledge of computer hardware and configurations. On the other hand high level languages just need knowledge of english words and logic of the problem irrespective of the type of computer you are using.
High level languages are human understandable language and it needs to be converted to machine language for the computer to understand.
Higher level languages are problem-oriented languages because the instructions are suitable for solving a particular problem. For example COBOL (Common Business Oriented Language) is mostly suitable for business oriented language where there is very little processing and huge output. There are mathematical oriented languages like FORTRAN (Formula Translation) and BASIC (Beginners All-purpose Symbolic Instruction Code) where very large processing is required.
The first high-level programming languages were designed in the 1950s. Now there are dozens of different languages, including Ada, Algol, BASIC, COBOL, C, C++, FORTRAN, LISP, Pascal, and Prolog.

Higher level languages have a major advantage over machine and assembly languages that higher level languages are easy to learn and use. It is because that they are similar to the languages used by us in our day to day life.

very high-level programming language:

A very high-level programming language is a programming language with a very high level of abstraction (abstraction - a concept or idea not associated with any specific instance), mainly used as a professional programmer productivity tool.
Very high-level programming languages are usually limited to a very specific application, purpose, or type of task. For this reason, very high-level programming languages are often referred to as goal-oriented programming languages.

Monday 20 May 2013

Programming Basics

Programming basics are very easy to understand and implement, all you need is to remember some key concept/points.
Following are the points to be remembered for better programming:-
1. Understand the given problem carefully.
2. Think of all the alternate feasible way to solve the problem.
3. Write all the solution in the form of algorithm.
4. Draw Flowcharts for all the algorithm.
5. Analyze all the feasible solutions by checking the number of steps and algorithmic complexity.
6. choose the best alternative which involves less number of steps and efficient in terms of algorithmic complexity.
7. Start coding the algorithm. While coding following points should be kept in mind :-
  1.     Always start coding with comments. On the top give details about the program in comments and     provide necessary information at different places with the help of comments.
  2.     Choose variables and functions such that they are efficient in terms of memory and cpu utilization.
  3.     Make sure of proper indentation. Indentation gives clear idea about the flow of control in the program and makes the program easy to understand.
8. Debug the code and find out the errors and bugs. Resolve them.
9. Run the program and check the output for all the possible input values. This is known as testing.
10.You are done with your program and not just a program but a better program.

Introduction To Programming

The process of designing, writing,testing , debugging, and maintaining the source code of computer programs.
Programming is an art in software engineering and one needs to be a good programmer rather than being just a programmer because there are many code written by a programmer which can solve the purpose but only few are there which can solve the purpose effectively and efficiently. Effective programs are those which can solve the purpose or a given problem and efficient programs are those which can solve the purpose or a given problem as fast as possible with minimum needs of resources.

A good programming skills needs following points to remember
1. Program should be effective.
2. Program should be efficient.
3. Program should be reliable.
4. Program should be robust.
5. program should be easy to maintain.

In software engineering programmers bad programming may increase the (LOC) lines of code of a program to increase the cost of the product but can never ever increase the quality of the software product.

According to Harlan Mills "Programming is similar to a game of golf.  The point is not getting the ball in the hole but how many strokes it takes."

So one should try to be good programmer rather than being just a programmer

This blog will focus on programming concept and many aspects of programming.