Partial classes..
->diffrerent source files and s treated as a single file wen t s compiled.
->like seperating client interfsce details frm implmn of the business logic,avoids confusion
->obj defn s split across diff files
->partial keyword is used
-can help reducing confusions between system generated codes and user defined codes,by putting in different files
eg)
Consider a project with deals with the complex user interface and back end programs.Different developers will do the front and the back ends.It is nt necessary that both will understand each other,but it is necessary that both should be compiled together for proper results.This is achieved by
->diffrerent source files and s treated as a single file wen t s compiled.
->like seperating client interfsce details frm implmn of the business logic,avoids confusion
->obj defn s split across diff files
->partial keyword is used
-can help reducing confusions between system generated codes and user defined codes,by putting in different files
eg)
Consider a project with deals with the complex user interface and back end programs.Different developers will do the front and the back ends.It is nt necessary that both will understand each other,but it is necessary that both should be compiled together for proper results.This is achieved by
partial class user_inter
{
{
};
partial class business_logic
{
{
};
Abstract Classes:
-->We can group together the methods that are common and have virtual functions inside them
-->cannot create an object to this abstract class,because it is not complete.
-->The implementations for the various subclasses from this abstract class may vary so u just specify declare the method in the abstract class and later define it in the subclasses,based on the different class.
-->Can also have concrete methods.
-->a class cant inherit from multiple abstract classes,but a class can implement from multiple interfaces.
-->Can also have concrete methods.
-->a class cant inherit from multiple abstract classes,but a class can implement from multiple interfaces.
Eg)
I think the quadrilateral example fits the best for this.Though it has common attributes lik sides,yet the method to find area for each class inherited from this quadrilateral may vary.So
class quadrilateral
{
int getarea();
};
class triangle:public quadrilateral
{
int getarea()
{//area of triangle
}
};
class square:public quadrilateral
{
int getarea()
{
//area of a square
}
};
getArea() method is an abstract method,nd quadrilateral is an abstract class.
I know it is a very common example,but this explains the gist of it more clearly!
Interfaces:
-->Does not support concrete methods in the base class.
-->Does an action specific to that class
-->Does an action specific to that class
suppose
information is d base class and image,video,text is below this,then in that case
infmn
image text video
infmn
image text video
-->to post the video or text or image the mechanism is different,which can be given in the methods in the implemented classes.
interface info //doesnt accept any concrete methods
{
void post(); //virtual method
};
class img_post:implements info
{
void post(){
//posting an img
}
class video_post :implements info
{void post()
{
//posting a video
}
}
In interface if v include a method in the base class it should be defined seperately in al function this is not necessary in inheritance.
Audio Blog: http://soundcloud.com/ronamaria/audio-recording-8
Delegates And Events!
Delegates:
To put it in simple words delegates are nothing but the function pointers.You create a function of a certain type.No wyou can use this function to create other function pointers..Il explain it to you with an example.public delegate dl_type (float s)
{
}
public dl_type fun_del;
Now fn_del can point to any function which accepts a float as an argument.
Consider
fun1(float d)
{
}
fun2(float e)
{
}
let fun1 and fun2 be 2 functions which takes float as an argument ..
Now allocate...
fun_del =fun1;
fun_del(8.8)
fun_del =fun2;
fun_del(8.0)
This will do the respective functions for fun1 and fun2 respectively..
To execute both simultaneously give
public dl_type fun_del1,fun_del2,fun_del3;
fun_del1=fun1;
fun_del2=fun2;
fun_del3=fun_del1+fun_del_2;
this will execute both fun1 and fun2 respectively..
fun_del3(4.5);
How are delegates useful??
In short they perform some kind of abstraction .
Seriously i don find any other proper use for delegates other than this...
Events:
Events are the delegates which point to a function that are triggered when you do a particular action.
Eg)Consider an array in which you need to sort it in ascending order when element is added and in the descending order when the element is removed.
Create a delegate which is dynamically defined to point to the respective function during runtime depending on if the element is added or removed.
- Sourcebits University
Cloud Computing
www.sourcebits.com
Events:
Events are the delegates which point to a function that are triggered when you do a particular action.
Eg)Consider an array in which you need to sort it in ascending order when element is added and in the descending order when the element is removed.
Create a delegate which is dynamically defined to point to the respective function during runtime depending on if the element is added or removed.
- Sourcebits University
Cloud Computing
www.sourcebits.com
No comments:
Post a Comment