Friday, June 24, 2011

Coding Guidelines part2

Code Naming Basics

* It's include the naming of classes, methods,functions and other elements of a programmatic interfaces.

General Principles

Clarity

* Its is good to be both clear and brief as possible.

 * Clarity shouldn't suffer became of brevity  



* In general, don’t abbreviate names of things. Spell them out, even if they’re long:










Coding Guidelines part1

Coding Guidelines

Coding Guidelines 

* It will help you to make your interfaces constant and clear.
* It is also important with frameworks such as version, binary comparability, error handling and memory management.
This topic include information on both naming convention and recommended programming practices.

This article include the naming convention in two group.

Ist Group 

* Code naming Basics.
* Naming Methods.
* Naming  Functions.
* Acceptable Abbreviation and Acronyms.
*  Naming of Instance Variables and Data Types.

2nd Group 

* Tips and Tricks for developers.

read More about the Coding Guidelines 

Coding Guidelines part2

Friday, June 3, 2011

CGRectMake


Function name:- CGRectMake
===========
Declaration
===========
CGRectMake ( CGFloat x, CGFloat y, CGFloat width, CGFloat height );
===========
iOS (2.0 and later)
============
Returns a rectangle with the specified coordinate and size values.
x: The x-coordinate of the rectangle’s origin point.
y: The y-coordinate of the rectangle’s origin point.

width: The width of the rectangle.

height:The height of the rectangle.
Return Value

A rectangle with the specified location and dimensions.
Declaration:- CGGeometry.h
Reference :- CGGeometry Reference
Related API:- CGPointMake , CGSize
Related Documents:- MakeQuartz 2D ProgrammingGuide
Sample Code:-

Monday, May 16, 2011

Apple Push Notification Service

Apple Push Notification Service is available for applications on the following devices:

iPhone
iPad
iPod touch



Push Notification Service requires iOS 3.0 or later.
it requires  a  internet connection.

at least one application which supports the push notification service.


To Verify the Device supports push notifications

check

  Settings > Notifications.  menu


If this menu is not present the device is not support the apple push notification support. For get the Push notification service we need to update the ios version to 3.0 or later.

To receive  the  push notification from the server you need to open the application at least once.
If you want to disable the Push notification service you can disable the service. just go to    
Settings > Notifications. . 

The Apple push notification service also supports the following Features
 
 Sounds :- Alert sound or a music 
Alerts :- can display alert on the screen
Badges:- Display an image/number on the application screen.


Next:- Configure the Push notification Service.


Windows Phone 7 Development : Push Notifications - Understanding Push Notifications

Windows Phone 7 Development : Push Notifications - Understanding Push Notifications


The Windows Phone 7 platform provides developers with three types of push notifications: toast notifications, tile notifications, and raw notifications. All three types follow the same basic principles of operation and processing, yet differ in the way they display notifications. Toast and tile notification types are used only when the application is not running; raw notifications are used to continuously receive messages while the application is running in the foreground. Let's discuss each notification type in detail.


1. Toast Notifications

Toast notifications are displayed as overlays at the top of a phone's screen. Only a message title and a line of text can be controlled by the service or an application sending ("pushing") a toast notification; the icon that appears on the left side of a toast notification is the default icon for the application deployed on the Windows Phone 7 device. You can display toast notifications only when an application is not running; if an application is running when a toast notification is sent, it is not displayed on the phone screen.

Toast notifications are used to display information that is timely and urgent. An example of toast notification is shown in Figure 1, where it appears as "Time to buy..." text at the top of the phone screen. Here, a notification has been received about Microsoft stock becoming an attractive buy. If the user chooses to tap (or click) the toast notification, an application opens up, allowing users to take additional actions within the application.



2. Tile Notifications

Tile notifications can alter the contents of any application tile that is pinned to the Quick Launch area of the phone initial screen (also referred to as Start Experience/Start Screen in Microsoft documentation). Tile notifications are used to communicate information visually, by displaying, say, dark clouds with rain to represent a rapidly approaching storm. Generally, an application tile is a visual representation of an application and its contents or functionality. An application tile typically contains an icon and two strings, and tile notifications can change any of these elements, as well as the background of each tile. To change a tile's background image, a tile notification must include a URI that points to the new image, a URI that can be either local or cloud-based. The string at the bottom of an application tile is referred to as the tile title. The string in the middle and slightly to the right is referred to as the tile counter.

3. Raw Notifications

The third and final type of push notification is the raw notification, which can be used to continuously send messages or updates to a Windows Phone 7 application that is running in the foreground. Contrast this with toast and tile notifications, which are used to send updates to an application when it is not running front and center on the Windows Phone 7 device. Unlike toast and tile notifications, all raw notifications are dropped once an application is no longer running in the foreground on the Windows Phone 7 device. Raw notifications are an energy-friendly alternative to constantly polling web services for data; this type of push notification also eliminates the need to keep connections to web services open for prolonged periods of time.

Each notification type has its "niche," so to speak, or the specific application development scenarios it shines with more than the others. For instance, if an application receives updates only when it's actively used, such as a chat application, then a raw notification is the most appropriate mechanism for transmitting these updates. If an application is ideally suited to communicate updates via the use of visual elements on an ongoing basis, such as weather updates, sports events scores, or stock prices, tile applications are a more appropriate choice. Finally, if text-based messages are the most appropriate form of communication on an around-the-clock basis, such as e-mail receipts, Facebook friend requests, or news alerts, toast notifications would be most suitable.

Having taken a look at three available push notification types, let's turn our attention to the architecture of notification services, since knowing the architecture will help you better understand how to program and troubleshoot push notification services.

Table 1. Characteristics of Windows Phone Push Notification Types

PN Type Must Application Be Running in Foreground? Must Application Tile be Pinned to Start Screen? Use
Toast No No Urgent and time-sensitive data (e.g., storm warning)
Tile No Yes Updates (e.g., count of new messages)
Raw Yes No Continuous data (e.g., Twitter client, stock ticker)


Original Source

Tuesday, April 19, 2011

Oops concepts

1. Data Abstraction


It can be defined as "presenting the functionality to the USER without presenting the
COMPLEXITY of creation..."
For example, a class Car would be made up of an Engine, Gearbox, Steering objects, and many more components. To build the Car class, one does not need to know how the different components work internally, but only how to interface with them, i.e., send messages to them, receive messages from them, and perhaps make the different objects
composing the class interact with each other.

2. Encapsulation


Encapsulation is a process of binding or wrapping the data and the codes that operates on the data into a single entity. This keeps the data safe from outside interface and misuse. This is implemented using classes.

3. Data Hiding
Data Hiding is implemented with the help of access specifiers.
The data defined by the class are referred to as member variables or instance variables. The code that operates on that data is referred to as member methods or just methods, which define the use of the member variables. Each method or variable in a class may be marked public or private. The private methods and data can only be accessed by the code, that is a member of the class. The public method has all details essential for external users.

3. Polymorphism


To be simple it is " One thing in many different forms”. It comes in two flavors.
Static Polymorphism - compile time polymorphism.
Dynamic Polymorphism - Runtime polymorphism.

Compile Time Polymorphism includes Operator and Function overloading. Run Time Polymorphism includes the Virtual Functions.

Function Overloading
Polymorphism means that functions assume different forms at different times. In case of compile time it is called function overloading. Two or more functions can have same name but their parameter list should be different either in terms of parameters or their data types. The functions, which differ only in their return types, cannot be overloaded. The compiler will select the right function depending on the type of parameters passed.

Operator Overloading
In polymorphism operators can also be overloaded (Compile time polymorphism). Operator Overloading means giving different meaning to the operators. With the help of operator overloading standard operations such as + , - , * , etc can be applied on the objects of the class.

Virtual Functions
A virtual function is a member function of the base class and which is redefined by the derived class. When a derived class inherits the class containing the virtual function, it has ability to redefine the virtual functions.

4. Inheritance

Inheritance is the process by which one object acquires the property of another object.
For instance, a "fruit" is a generalization of "apple", "orange", "mango" and
many others. One can consider fruit to be an abstraction of apple, orange, etc. Conversely, since apples are fruit (i.e., an apple is-a fruit), apples may
naturally inherit all the properties common to all fruit, such as being a fleshy
container for the seed of a plant.
In object oriented programming, inheritance is a way to form new classes using classes that have already been defined. The new classes, known as derived classes, take over (or inherit) attributes and behavior of the pre-existing classes, which are referred to as base classes (or ancestor classes). It is intended to help reuse existing code with little or no modification.
5. Abstract Classes
Abstract classes are one of the essential behaviors provided by .NET. Commonly, you would like to make classes that only represent base classes, and don’t want anyone to create objects of these class types. You can make use of abstract classes to implement such functionality in C# using the modifier abstract. An abstract class means that, no object of this class can be instantiated, but can make derivations of this.
An example of an abstract class declaration is:
abstract class AbsClass
{
}
An abstract class can contain either abstract methods or non abstract methods. Abstract members do not have any implementation in the abstract class, but the same has to be provided in its derived class.
An example of an abstract method:
abstract class AbsClass
{
public abstract void abstractMethod();
}
Also, note that an abstract class does not mean that it should contain abstract members. Even we can have an abstract class only with non-abstract members.
For example:
abstract class AbsClass
{
public void NonAbstractMethod()
{
Console.WriteLine("NonAbstract Method");
}
}
Important rules applied to abstract classes:
An abstract class cannot be a sealed class.
Declaration of abstract methods is only allowed in abstract classes.
An abstract method cannot be private.
The access modifier of the abstract method should be same in both the abstract class and its derived class. If you declare an abstract method as protected, it should be protected in its derived class. Otherwise, the compiler will raise an error.
An abstract method cannot have the modifier virtual. Because an abstract method is implicitly virtual.
An abstract member cannot be static.


6. Interfaces
An interface defines a contract. A class or struct that implements an interface must adhere to its contract. An interface may inherit from multiple base interfaces, and a class or struct may implement multiple interfaces.

An Interface is a reference type and it contains only abstract members. Interface's members can be Events, Methods, Properties and Indexers. But the interface contains only declaration for its members. Any implementation must be placed in class that realizes them. The interface can't contain constants, data fields, constructors, destructors and static members.*All the member declarations inside interface are implicitly public.*If*some interface is inherited, the program must implement all its declared members.
The interface doesn't actually do anything but only has a signature for interaction with other classes or interfaces. A good analogy for an interface is a pencil and a pencil sharpener. When we talk of a pencil and a pencil sharpener we generally know what they do and how they interact. We don't have to know the inner workings of a particular sharpener or pencil, only how to use them through their interface.
*
public interface IPencil
{
void Write();
bool IsSharp { get; }
}
*
public interface IPencilSharpener
{
void Sharpen(IPencil pencil);
}
*
* While the compiler does not enforce it, for consistency with the .NET framework it's a good idea to name interfaces starting with a capital 'I'.*
An interface may be considered as abstract base class containing only the function signatures whose implementation is provided by the child class. In C#, you define such classes as interfaces using the interface keyword. .NET is based on such interfaces. In C#, where you can't use multiple class inheritance, which was previously allowed in C++, the essence of multiple inheritance is achieved through interfaces. That's how your child class may implement multiple interfaces.



An interface has the following properties:
An interface is similar to a pure abstract base class: any non-abstract type inheriting the interface must implement all its members.
An interface cannot be instantiated directly.
Interfaces can contain events, indexers, methods and properties.
Interfaces contain no implementation of methods.
Classes and structs can inherit from more than one interface.
An interface can itself inherit from multiple interfaces
Eg:
using System;
interface myDrawing
{
int originx
{
get;
set;
}
int originy
{
get;
set;
}
void Draw(object shape);
}

class Shape: myDrawing
{
int OriX;
int OriY;

public int originx
{
get{
return OriX;
}
set{
OriX = value;
}
}
public int originy
{
get{
return OriY;
}
set{
OriY = value;
}
}
public void Draw(object shape)
{
... // do something
}

// class's own method
public void MoveShape(int newX, int newY)
{
.....
}
}

7. Virtual Functions
A virtual function is a member function that you expect to be redefined in derived classes. When you refer to a derived class object using a pointer or a reference to the base class, you can call a virtual function for that object and execute the derived class's version of the function. Virtual functions ensure that the correct function is called for an object, regardless of the expression used to make the function call.
Suppose a base class contains a function declared as virtual and a derived class defines the same function. The function from the derived class is invoked for objects of the derived class, even if it is called using a pointer or reference to the base class.
Eg:
class Shape
{
public virtual void Draw()
{
Console.WriteLine("Shape.Draw") ;
}
}

class Rectangle : Shape

{
public override void Draw()
{
Console.WriteLine("Rectangle.Draw");
}
}

class Square : Rectangle
{
public override void Draw()
{
Console.WriteLine("Square.Draw");
}
}
class MainClass
{
static void Main(string[] args)
{
Shape[] shp = new Shape[3];
Rectangle rect = new Rectangle();

shp[0] = new Shape();
shp[1] = rect;
shp[2] = new Square();

shp[0].Draw();
shp[1].Draw();
shp[2].Draw();
}
}
Output:
Shape.Draw
Rectangle.Draw
Square.Draw

Objects










An identifiable entity which has its own properties and behaviors.
Everything we see around us are objects. 
eg:- BOOK




Book has Properties
  1. width
  2. height
  3. no. of pages
  4. title

behaviors
  1. turn pages


Mobile-phone has
Properties
  1. display-screen
  2. resolution
  3. keypad
  4. price
  5. ring-tone

behaviors
  1. receive call
  2. make call
  3. ring
  4. switch on/switch off

The properties makes it appear as a mobile-phone. (Determines its state)
The behaviors makes it behave like mobile-phone. (Makes state-change)


all ring switch on/switch off

The properties makes it appear as a mobile-phone. (Determines its state)
The behaviors makes it behave like mobile-phone. (Makes state-change)








Object-Oriented Programming

lesson 3


A computer-programming methodology that focuses on data items rather than processes. 

The object-oriented approach focuses first on the data items (entities, objects) that are being manipulated. 

The emphasis is on characterizing the data items as active entities which can perform operations on and for themselves. 

It then describes how system behavior is implemented through the interaction of the data items.

Procedural Programming

Lesson 2

Procedural Programming
Procedural programming is a programming paradigm based upon the concept of the modularity and scope of program code.

A main procedural program is composed of one or more modules either written by the same programmer or provided in a code library by another programmer.

Each module is composed of one or more subprograms (functions).

Procedural programming offers many benefits over simple sequential programming since procedural code:
is easier to read and more maintainable 
is more flexible 
facilitates the practice of good program design 




Introduction to OOP


Lesson 1
Object Oriented Programming

Paradigm
The way of approaching a problem. 

A programming paradigm means a style of programming. A programming paradigm provides (and determines) the view that the programmer has of the execution of the program.

A programming paradigm is a style or model of programming that affects the way programmers can design, organize and write programs.