Monday, May 31, 2010
A short, fun, animated approach, showing you what SharePoint is all about.




Saturday, May 29, 2010


Testing cannot show that software is free of defects, but it can identify their existence. Thus, the purpose of testing is not to show that a program works, but to find its defects. Following are several practices for testing software.


1-
Generate functional test cases from defined scenarios. These scenarios represent common transactions that reflect the tasks that the users will carry out. These test cases should be included in a regression test suite.

2- Use a code coverage tool. The reason for using a code coverage tool is that it provides quantitative evidence on how thorough a test effort is. Weigers illustrates the value of a code coverage tool when he said:

“Good programmers testing without benefit of a coverage tool are only achieving about 80 percent code coverage, while average programmers are getting 50 to 60 percent, and poor programmers are hitting less than 30 percent. Test strategies that emphasize only the functional behaviors of the software may cover the requirements adequately, but this is no guarantee that the internal structure of the program has been thoroughly exercised.”

3- Perform basis path testing. Basis path testing independently tests each conditional predicate of a module. That is, the outcome of each condition that can affect control flow is independently tested. Thus, basis path testing localizes a defect to a single subpath of a module because there are no interactions between decision outcomes.

A further benefit of this approach is that the size of the testing effort is predictable before testing begins, whereas other techniques are predicated on examining the ongoing progress of a test effort. In basis path testing, the required number of test cases for a module is exactly its cyclomatic complexity, which is computed by counting the number of conditional predicates of a module plus one (each separate case of a case statement counts as one). In sum, basis path testing is an effective, efficient, and quantifiable software testing technique that catches about two thirds of all defects.

Consider the following function, which computes the factorial of a number, and its associated flow graph, shown in the following figure.

clip_image001

clip_image002

The cyclomatic complexity of this function is 2, indicating that two edges exist in the flow graph: one test case is required for the condition 2 <= n and another one when 2 > n. Hence, n equals 1 and n equals 2 are two valid inputs that will transverse every edge of the control flow graph of the Fibonacci function, as shown in the previous table.

clip_image003

Note that many people have suggested breaking up complex modules into smaller modules, as measured by cyclomatic complexity. This is not necessarily a good thing for two reasons:

First, decomposing a module into multiple modules may not make sense because it may be difficult to decompose the larger module into smaller ones, each having specific responsibilities. Thus, decomposition may turn out to be arbitrary and not very meaningful.

Second, decomposing a module into more modules actually increases the testing effort. Consider, for example, how one might decompose the greatest common denominator function

4- Examine the boundary conditions affecting the control flow of a program. Test predicate variables in a condition by testing the two values one unit of measurement from the specified value. For example, if a predicate is x == 1, where x is an integer value, test cases should be written so that x is bound to 0 and 2 when the condition is executed. For the factorial function in the previous example checking the boundary conditions would yield the two test cases corresponding to n equals 1 and n equals 3. By choosing the input values wisely for basis path and boundary value testing, one can reduce the total testing effort. For this example, there are three unique test cases — n equals 1, 2, and 3 — that satisfy the structural testing procedures identified by Practices 3 and 4, which are shown in Table of factorial function. For the greatest common denominator function of the previous factorial algorithm, three boundary value conditions occur, which are satisfied by the wise selection of the inputs for basis path testing.

Furthermore, examine loop statements, which are a special case of boundary value testing, using the following heuristics.

- Execute each loop statement zero, one, and two times. This is more-or-less performing boundary value testing of the initial step of the iteration variable. In addition, it has been shown that executing a loop twice can detect some unique initialization problems.

- When using nested iteration statements, select a constant value for all iteration variables except the one being tested, vary it as previously described, and then repeat this process for the remaining nested iteration variables. This heuristic reduces the number of required test cases.

5- Verify data and file usage patterns of a program. That is, check that a program opens files before it operates on them and that it closes files before it terminates. Similarly, verify that a program declares and initializes data before it operates on the data, and that it reclaims all data before it terminates.

6- Verify that invalid and unexpected inputs are handled, as well as valid and expected ones. People often detect numerous defects when they use a program in proper but unexpected ways. Consequently, test cases containing unexpected and invalid inputs often find greater numbers of defects than do test cases containing valid input. In addition, an important class of inputs — command languages and data formatting protocols — should be rigorously tested.

Useful heuristics include:

(1) Executing repeated rewrite rules to find limitations in buffer sizes;

(2) Violating syntactic rules;

(3) Reversing syntactic tokens and other forms;

(4) Creating the null program;

(5) Creating null expressions (e.g., {});

(6) Examining code for missing, wrong, and too many delimiters; and

(7) Checking code for field value errors.

One might consider writing a syntax checker that mutates valid input strings in defined ways, which requires a formal definition of the syntax.

7- Verify all critical timing modes and time-out conditions. A critical timing mode occurs whenever execution timing is mission critical, consisting of:

(1) A fixed number of tasks, threads, or event-handlers running concurrently on a critical processor;

(2) A fixed allocation of functions to tasks, threads, or event-handlers; and

(3) fixed priorities and frequencies for each task, thread, or event-handler.

8- Verify that systems work in a variety of configurations as many as practical. Use the same hardware and software environments that the deployment sites will use during the integration test. The benefit of this is that an organization will detect defects unique to host environments of the field sites before it deploys software to them.

9- Verify the accuracy of the documentation. This includes verifying the correctness of the software installation procedures. Following this practice is important because documentation defects represent 10 to 25 percent of all delivered software defects.

Software Quality By :

Ahmed Abdelhamid
Software Quality Engineer
Interactive Saudi Arabia Ltd.
An Economic Offset Program Co.
http://www.il.com.sa/ahamid

 



Friday, May 28, 2010

I published a new post lists the new and enhanced features available in Visual Basic 2010.

http://blog.waleedmohamed.net/2010/05/why-we-should-move-to-visual-studio.html

Waleed Mohamed
Software Development Director
http://blog.waleedmohamed.net
http://blog.flair-systems.com



Wednesday, May 26, 2010

What’s AppDomain (Application Domain):

When 10 users browse a page say (login.aspx) in a published website, ASP.Net Worker Process (w3wp.exe) creates 10 application domains to host the page assembly into it for each client, thus creates 10 appDomains.

appDomain

assembly

App_Web_Login.aspx.fdf7a39c.dll


So, what’s the story?

When run any application, the operating system hosts it in a process (p1) to be ran by the processor . and if the run another different application(OS hosts it into another process (p2)).if app1 wants to access an assembly (dll or exe) form app2, the accessing will be managed by OS which is slow.

The another solution:-

Host the assemblies you want into an application domain (which is a logical boundary you create to host many assemblies as you wish). the appDomain is managed by .net framework but process is managed by the operating system (which is slower)

Operating system:

Process1

appDomain1

assembly

App_Web_Login.aspx.fdf7a39c.dll

assembly

DataAccessLayer.dll 

appDomain2

assembly

App_Web_EmployeeData.aspx.fdf7a39c.dll 

End of the story;

C# fast-food by:
Eng.Waleed abou-zaid
Senior Software Developer
Harf Information Technology
MCSD.Net,MCAD.Net,MCP,A+,N+ certified
walid.abouzaid@gmail.com



Inasha’ ALLAH it will be a series of new features that comes in VS2010:

VS2010 presents anew future called Call Hierarchy of Methods that provides you with a tree view at design time

This tree view contains all (methods, prop., or whatever called the method) that calls the applied method

here is how try that in VS2010.

 

Suppose coming Code :
protected void Page_Load(object sender, EventArgs e)
{
   BindDataControls()
}
private void BindDataControls()
{
   //DataBinding here
}
protected void Button1_Click(object sender, EventArgs e)
{
   BindDataControls();
}

 

 

End of the story;

C# fast-food by:
Eng.Waleed abou-zaid
Senior Software Developer
Harf Information Technology
MCSD.Net,MCAD.Net,MCP,A+,N+ certified
walid.abouzaid@gmail.com



override
public class Base
{
    public virtual void SomeMethod()
    {
        //print base
    }
}
public class Derived : Base
{
    public override void SomeMethod()
    {
        //print child
    }
}
//...
Base b = new Derived();
b.SomeMethod();
new
public class Base
{
    public virtual void SomeOtherMethod()
    {
        //print base
    }
}
public class Derived : Base
{
    public new void SomeOtherMethod()
    {
        //print child
    }
}
//...
Base b = new Derived();
Derived d = new Derived();
b.SomeOtherMethod();
d.SomeOtherMethod();
Out put Out put
  Child   base
     Child

 

So what’s the matter:

Virtual keyword makes the method on the base type prone (عرضة) to any derived ones override it by writing override keyword before it

So when calling it from the parent object, parent object looks for if any overrides exists to implement it and eliminates the current virtual method code

But the new keyword make a new version from the method actually it’s a new one at all;

So when calling it on the parent object, although it was initialized by a child one, but now this method (public new void SomeOtherMethod()) is another one totally so the parent object implements its own method

End of the story;

C# fast-food by:
Eng.Waleed abou-zaid
Senior Software Developer
Harf Information Technology
MCSD.Net,MCAD.Net,MCP,A+,N+ certified
walid.abouzaid@gmail.com



Tuesday, May 25, 2010

I read This White Paper Yesterday and its very good to share ,

Read and discuss it with me why do you think our It project fail ?

View more documents from Flair Systems.

Waleed Mohamed
Software Development Director
http://blog.waleedmohamed.net
http://blog.flair-systems.com



Q. How to consume REST based-services?

Assume we have REST based-service contains method Add which takes two operands op1 and op2 and return the summation.

A) Create any project type (Console, Windows or even Web-based application) and add the below lines :

Code Snippet
  1. using System.Net;
  2. using System.IO;


B) Write some code to consume the service:

Code Snippet
  1. string parameters;
  2. string response;
  3. // Create the request obj
  4. WebRequest request = WebRequest.Create("serviceURL/Add");
  5. // Set values for the request back
  6. request.Method = "POST"; //REST based-services using Post method
  7. request.ContentType = "application/json"; //tells request the content typs is JSON
  8. parameters = "{\"op1\":2,\"op2\":\"1\"}";
  9. request.ContentLength = parameters.Length;
  10. // Write the request
  11. StreamWriter requestWriter = new StreamWriter(request.GetRequestStream(), System.Text.Encoding.ASCII);
  12. requestWriter.Write(parameters);
  13. requestWriter.Close();
  14. // Do the request to get the response
  15. StreamReader responseReader = new StreamReader(request.GetResponse().GetResponseStream());
  16. response = responseReader.ReadToEnd();
  17. responseReader.Close();



Response value should be 3 if you implement Add method correctly :))

 

C# FastFood by :
Eng.Ramy Mahrous
http://ramymahrous.wordpress.com/about/



Sunday, May 23, 2010

I couldn't sleep in the middle of the night and something I saw these days triggered me to get up and write this article.

The Governorate of Sixth of October City and the Traffic Department recently started to install traffic light systems in many locations, these locations are:

  • A pedestrian light traffic in front of Hyper One and in front of MUST University.
  • A Cross Road Traffic light at Guhyna Roundabout, Housry Roundabout and Magda Roundabout.

These systems are installed with a primitive designs and not according to the latest technologies not mentioning the poor quality and bad alignment of the poles.

Note:(see the picture and the relative between the vertical alignment of the Mosque Maazana and the Pole)


image


I think what they thought is we need to put a traffic light here so let's buy a traffic light with a countdown timer (WOW) and this will solve the problems.


Let's study the pedestrian traffic lights at Hyper one and MUST University:


1- The traffic light was installed only in the Main road and should also be installed in the service roads.


image


2- The Traffic light should have included a request for cross button at the pole where pedestrian will press if they require to cross the road, pressing this button will close the light to vehicles and open it to pedestrians after some delay from pressing, first it will give a yellow light to vehicles and then stop light and enough time for pedestrian to cross it will also take into considerations when was the last time it was closed to vehicles to allow good flow of vehicles without repeated interruptions from Pedestrians, not using this feature will mean that the traffic light will turn into red and green based on time intervals, pedestrians may not be available to cross at this time and drivers may get bored specially at early morning and late hours, they will break the light specially with no red light cameras available, this will lead to not respecting the traffic light in normal hours as well by the drivers. The request to cross is a method used all over the world to organize pedestrian crossing, it sometimes also included with a high volume beeping speakers to help blind people to realize the crossing time and location.


image


As for the Roundabout lights, the design is unprofessional at all, the roundabout design is used when the flow is low or the roundabout is big enough to absorb the volume of vehicles with respecting the roundabout rules which is the priority is always for the vehicle already inside the roundabout and vehicles entering to the roundabout should wait until the roundabout is clear to enter without forcing the vehicles inside to press brakes.


Since these roundabouts receives high volumes during the day the design should automatically go to using traffic lights, but due to the size of these roundabout my opinion is to remove the roundabout totally and use it as a normal cross road design shown below in the picture.


image


This design is more useful with traffic lights and allows faster flows instead of going through the roundabout.


In most of the countries right now they are applying what is called the Intelligent traffic light system, using loop sensors, which is sensor in the ground that sense there is a vehicle above it, can give us a lot of information to organize and predict traffic flows.


For example: why to open the traffic lights on time based while there is always one side has lower traffic, sensing the cars presence will allow me to open the light for sides that have more volumes until cars arrive at the other side's then the sensors will tell the system there are group of cars waiting to cross, the system then will give them their fare time to cross.


image


Using these sensors also detects wrong direction and it can give a signal to cameras to snapshoot the plate license, where intelligent Digital Signal Processing can read the plate and send the violation to traffic departments, using wireless technology.


Also using the sensor the system can know if someone has violated the red light by using two sensors one before the white line and one after. If car crossed the one after the white line when the signal is red then he violated the traffic light and signal is sent to the traffic cameras.


Speed violation can also be determined and snapped using the sensors when using two sensors with a known distance between them the system can know the car speed hence the system can snap the violation.


Loop sensors has many features it can calculate the vehicle crossing then predicting the time limit for each traffic light and so on, these information also can be used for statistics on road flows for roads designs.


image


I know that may be the budget was a problem to apply these traffic lights, but a little more effort could make it better.


The Intelligent traffic Light System is a great invention and our country need it so Flair Systems is announcing sponsoring a graduation project next year for any group of students deciding to use it as their graduation project to build an Egyptian product with low cost, that will help our traffic system to be better.


Technology and society By:
Abdalla Shebl
Managing Director



Generic types like BindingList<T> are very powerful because they allow a developer to easily create a strongly typed instance of the generic type. For instance

BindingList<string> myStringList;

defines a strongly typed collection of type string.

Similarly BindingList<int> myIntList;

defines a strongly typed collection of type int. Since both myStringList and myIntList are “of type” BindingList<T>, you might think they are polymorphic—that you could write one method that could act on both fields. But you can’t. Generic types are not inherited, and thus do not come from the same type. This is highly counterintuitive at first glance, but nonetheless is a fact of life when working with generic types.

In order to treat instances of a generic type polymorphically, or to do type checks to see if those instances come from the same type, the generic type must inherit from a non-generic base class or implement a non-generic interface. In the case of BindingList<T>, the generic type implements IBindingList. So both myStringList and myIntList can be treated as IBindingList types.

C# fast-food by:
Eng.Waleed abou-zaid
Senior Software Developer
Harf Information Technology
MCSD.Net,MCAD.Net,MCP,A+,N+ certified
walid.abouzaid@gmail.com




You must see the 2 attached pictures to be admired with the difference


image image


Client-Side Callback


ASP.NET 2.0 includes a new client callback feature that enables you to retrieve page values and populate them to an already-generated page without regenerating the page. This makes it possible to change values on a page without going through the entire postback cycle; that means you can update your pages without completely redrawing the page. End users will not see the page flicker and reposition, and the pages will have a flow more like the flow of a thick-client application.


To work with the new callback capability, you have to know a little about working with JavaScript. This book does not attempt to teach you JavaScript. If you need to get up to speed on this rather large topic, check out Wrox's Beginning JavaScript, Second Edition, by Paul Wilton (ISBN: 0-7645-5587-1).


Comparing a Typical Postback to a Callback


Before you jump into some examples of the new callback feature, first look at a comparison to the current postback feature of a typical ASP.NET page.


When a page event is triggered on an ASP.NET page that is working with a typical postback scenario, a lot is going on. The diagram in Figure 4-13(see the "postback.gif" attached picture) illustrates the process.


In a normal postback situation, an event of some kind triggers an HTTP Post request to be sent to the Web server. An example of such an event might be the end user clicking a button on the form.


This
sends the HTTP Post request to the Web server, which then processes the request with the IPostbackEventHandler and runs the request through a series of page events. These events include loading the state (as found in the view state of the page), processing data, processing postback events, and finally rendering the page to be interpreted by the consuming browser once again.


The process completely
reloads the page in the browser, which is what causes the flicker and the realignment to the top


of the page.


On the other hand, you have the alternative of using the new callback capabilities, as shown in the diagram in Figure 4-14(see the "callback.jpg" attached picture).


In this case, an event (again, such as a button click) causes the event to be posted to a script event handler (a JavaScript function) that sends off an asynchronous request to the Web server for processing.

ICallbackEventHandler runs the request through a pipeline similar to what is used with the postback- but you notice that some of the larger steps (such as rendering the page) are excluded from the process chain. After the information is loaded, the result is returned to the script callback object.


The script code
then pushes this data into the Web page using JavaScript's capabilities to do this without refreshing the page. To understand how this all works, look at the simple example in the following section.


Next mail will contain the example




C# fast-food by:


Eng.Waleed abou-zaid


Senior Software Developer


Harf Information Technology


MCSD.Net,MCAD.Net,MCP,A+,N+ certified

walid.abouzaid@gmail.com






IF u have a client server application and 2 clients are updating the same record from a table named Employee(ID, City, Salary)


The record they are attempting to update is (1,'Cairo',100)


1st client makes the following update (1,'Alex',100) to the previous data (1,'Cairo',100) according to PK


2nd client makes the following update (1,'cairo',200) to the previous data (1,'Cairo',100) according to PK


The 1st client as its update reaches the SQLServer first the row will be updated to (1,"Alex",100)


The 2nd client come as the blind donkey and make the record be (1,"cairo",200)


Then the first update of city will be overwritten.


Then what is the SOLUTION


the solution is the smart data type "TimeStamp" one of the sql server datatypes : it is a stream of binary didgits(0's & 1's)


When u add a column of type timestamp, as row first created It will have a binary value, but, each time the row updated the column updates its value at this row by a random binary value differs from any binary value in any row


The table will be (id, city, salary, StampeClo) the "StampeClo" of type time stamp


The update statement will be :


UPDATE Student SET City=@ City,Salary=@Salary WHERE StampeCol=@StampCol AND [ID]=@ID


Returning to our problem:


1st Client Update Statement: UPDATE Student SET City='Alex',Salary=100 WHERE StampeCol='110' AND [ID]=1


//the statement as reaches first and the


//StampCol value become say '111' (the number will be auto generated I put these values only for //explanation purpose )


2nd Client Update Statement: UPDATE Student SET City='cairo',Salary=200 WHERE StampeCol='110' AND [ID]=1


//the statement as later


//and StampCol value become say '111' not '110', update statement will not be updated, here u can inform //user "data of this record has //been changed by another client load the page again if it was a webpage for //example


Note:in .NET, U will give the mapped property of that column the datatype of "byte[]"


C# fast-food by:


Eng.Waleed abou-zaid


Senior Software Developer


Harf Information Technology


MCSD.Net,MCAD.Net,MCP,A+,N+ certified

walid.abouzaid@gmail.com






These files are just in time (JIT) compiled --- so they don't exist until you
run the app. The way I do this is:


  • Load the application (in 2.0 each page is it's own assembly by default, so
    browse to the page you wan to see)

  • Open: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary ASP.NET Files

  • Open the folder that's the same name as web project

  • Open whatever folder you find twice (not the _shadow). mine looked like 5365350a\c79f3d9b

  • Then you'll see a bunch of dll's name something like App_Web.asldjkasldj.dll

  • Use any Reflector(like .NetReflector), and open each one up until you see your file. You should see an ASP and _ASP namespace.

 

 

C# fast-food by:
Eng.Waleed abou-zaid
Senior Software Developer
Harf Information Technology
MCSD.Net,MCAD.Net,MCP,A+,N+ certified
walid.abouzaid@gmail.com



Static ClientID

When writing JavaScript code to get any control in a page, We don’t know the control client ID. Now in ASP.Net 0.4 you can make the client id of the control fixed

By making your control implement the following interface:

“ INamingContainer “ and set the ClientIDMode property to Static.

For example, here is the codebehind for a simple web user control (ASCX) with a label in it.

Code Snippet
  1. public partial class WebUserControl1 : System.Web.UI.UserControl, INamingContainer
  2. {
  3. protected void Page_Load(object sender, EventArgs e)
  4. {
  5. this.ClientIDMode = ClientIDMode.Static;
  6. }
  7. }

That's all you need to do, and the control gets rendered to the page with an ID of Label1.

C# fast-food by:
Eng.Waleed abou-zaid
Senior Software Developer
Harf Information Technology
MCSD.Net,MCAD.Net,MCP,A+,N+ certified
walid.abouzaid@gmail.com



First what is meant by software design pattern?

It’s a standard solution for a recurring problem. that many developers before u faced the same problem u r facing now and most of them did a similar solution to it, so it became a standard solution (pattern) to this problem.

Singletone Design Pattern. It’s a situation when u want ur class’s object to be created once and any coder want to make another object,  ur class code will check if there is an instance was created before, if so, it will references the new object to the existing one, if not, it will return a new one.

Actually this technique does this by making this object to be returned as a static object, thus to be resident(cached) in memory and any attempt to make another instance like it will be referenced to its place in memory.

How To DO?

Simply u make a protected constructor(so no one can create an instance directly by a new keyword).then define a private static null field of the same type of ur containing class. then code a static method returns the same type of ur containing class (thus, first time the method called an object is created and the method will check is the private static field is null ,if so ,it will create a new one as it can access the constructor as it’s a member of the class) and will assign the new instance to that private static field and return it.

Next time any code attempting to create a new instance by calling the static method it will check the nullability of the static field and will find it != null. So it will return it, not creating a new one.

Code Snippet
  1. class SingleTone
  2. {
  3. static SingleTone _instance = null;
  4. protected SingleTone()
  5. {
  6. }
  7. public static SingleTone NewInstance()
  8. {
  9. if (_instance == null)
  10. {
  11. _instance = new SingleTone();
  12. }
  13. return _instance;
  14. }
  15. }
  16. static void Main(string[] args)
  17. {
  18. SingleTone singleTone1 = SingleTone.NewInstance();
  19. //first call create a new object
  20. SingleTone singleTone2 = SingleTone.NewInstance();
  21. //further calls will return the first created object
  22. }

 

C# fast-food by:
Eng.Waleed abou-zaid
Senior Software Developer
Harf Information Technology
MCSD.Net,MCAD.Net,MCP,A+,N+ certified
walid.abouzaid@gmail.com



Task Parallel Library

Code Snippet
  1. void SeqMatrixMult(int size, double[,] m1, double[,] m2, double[,] result)
  2. {
  3. for (int i = 0; i < size; i++) {
  4. for (int j = 0; j < size; j++) {
  5. result[i, j] = 0;
  6. for (int k = 0; k < size; k++) {
  7. result[i, j] += m1[i, k] * m2[k, j];
  8. }
  9. }
  10. }
  11. }

The previous code heavily consume processor ,although you have 4-quad processor. is there any way to make your 4-quad processor (or your 4 processor) help you? what if u let the iterations divided into 4 portions (each processor processes a portion)

There new class in .net framework called “Parallel” which has static methods called “For”, and “Foreach”

This class is in the TPL “Task Parallel Library”(see the note at the end of the article.)

you just add the follwoing namespace

Code Snippet
  1. using System.Concurrency;
  2. void ParMatrixMult(int size, double[,] m1, double[,] m2, double[,] result)
  3. {
  4. Parallel.For( 0, size, delegate(int i) {
  5. for (int j = 0; j < size; j++) {
  6. result[i, j] = 0;
  7. for (int k = 0; k < size; k++) {
  8. result[i, j] += m1[i, k] * m2[k, j];
  9. }
  10. }
  11. });
  12. }

“Parallel.For” is a static method takes the start and end index of the loop and the third parameter is the value of the index loop  to pass to the processor. But it has some constraints .that the inner loops do not depend on the outer loops.

Meaning that the next iteration does not depend on the current iteration (in other words, does not wait for a value from the prev. iteration - the index loop variable is already passed to the processor(actually, it’s a thread running on the other processor).

For the non-numeric values there is the Parallel. Foreach

End of the story.

Note:

TPL is being created as a collaborative effort by Microsoft® Research, the Microsoft Common Language Runtime (CLR) team, and the Parallel Computing Platform team. TPL is a major component of the Parallel FX library, the next generation of concurrency support for the Microsoft .NET Framework

 

C# fast-food by:
Eng.Waleed abou-zaid
Senior Software Developer
Harf Information Technology
MCSD.Net,MCAD.Net,MCP,A+,N+ certified
walid.abouzaid@gmail.com



Here I’ll talk about some new features of C# 4.0

At the beginning remember that; 

In every new release of c# there is a major new feature than the oldest one

Remember in C# 2.0 (Generics), C# 3.0 (Linq), and here (dynamic programming support)

1. Named and optional parameters: Now declare optional parameters simply by providing a default value for it. And call params by name: like so,

        // Definition of the method
public void Method(int x, int y = 1, int z = 2)
{

}

// Using the optional params
Method(1); // same as Method(1, 1, 2);
Method(1, 2); // same as Method(1, 2, 2);
Method(1, 2, 3);

// Named params called, note arbitrary order and missing y
Method(z: 1, x: 2);


2. dynamic object:



A new type has been introduced called dynamic. The idea is that you can call any operation on the dynamic type you want, the compiler won’t check it at compile-time, but figure it out at runtime. A dynamic object is assumed to support any operation at compile-time, only at runtime will you get an error. The result of any dynamic operation is of type dynamic.





        // Instantiation
dynamic d = 7; // implicit conversion
dynamic d = GetStudentData(); //GetStudentData() returns object of type Student class

// Operations on dynamic types

d.f = d.P; // getting and settings fields and properties
d["one"] = d["two"]; // getting and setting thorugh indexers
int i = d + 3; // calling operators

// in the previous examples if f,p are not properties on the Student class and also there is no indxer it will be compiled successfully ,it will be detected at runtime.


C# fast-food by:



Eng.Waleed abou-zaid

Senior Software Developer


Harf Information Technology


MCSD.Net,MCAD.Net,MCP,A+,N+ certified



walid.abouzaid@gmail.com



All of us when calling a method call it just like this “LoadChildrenOf(employee)”

Say the signature of the method is

Public List<Child>  LoadChildrenOf(Employee emp)
{
Return DatabasePortal.LoadChilds(emp);
}

And in this method u normally do not edit or change the emp object so why u pass it by value.

So what is meant by pass by value?

The method takes a local copy from the object u have sent to it, thus copying it into memory reserving again a space in memory for this copied object and give it the associated data, although here in the previous method u did not change the status(changing props. Or fields).then I want u to sent this object by REF

So what is meant by pass by ref?

Here the method will take a reference to the outside object not the object data itself, thus the object in the method will still references the outside object

In this case it’s preferable to pass the object by ref.

But if the code inside the method will change the object state so pass it by value, thus the method will work on its local copy and any changes will never affect the outside object and thus after the CLR out from the method the object will be out of scope but it will resides until GC comes and kill it.

C# fast-food by:

Eng.Waleed abou-zaid
Senior Software Developer
Harf Information Technology
MCSD.Net,MCAD.Net,MCP,A+,N+ certified
walid.abouzaid@gmail.com



Friday, May 21, 2010

Jquery.Timepickr

jquery.timepickr was created in a attempt to make the process of inputing time in a form as easy and natural as possible.

Demo: http://haineault.com/media/jquery/ui-timepickr/page/#s-intro 

image

AutoSprites - A jQuery Menu Plugin

Demo:
http://www.newmediacampaigns.com/page/autosprites-jquery-menu-plugin

image

In-Field Labels jQuery Plugin

This is a simple plugin that turns properly formatted HTML forms into forms with in-field label support.
Demo:
http://fuelyourcoding.com/scripts/infield/
image
AutoSuggest jQuery Plugin

This one is really awesome. Just 7kb minified. AutoSuggest is a very lightweight jQuery plugin that makes auto-completing extremely easy.

Demo: http://code.drewwilson.com/entry/autosuggest-jquery-plugin 

image

Password Strength

Password Strength tries to calculate how many possibilities the hacker needs to try to guess your password.

Demo: http://www.unwrongest.com/projects/password-strength/

image

clip_image002 clip_image004 clip_image006clip_image008clip_image010


Sunday, May 9, 2010

clip_image002 clip_image004 clip_image006clip_image008 clip_image010

Software as Services Video form 2 years ago form Microsoft Riyadh Conference @ KSA , www.flair-systems.com ,this video about software as services and Microsoft vision.

 

clip_image002 clip_image004 clip_image006clip_image008 clip_image010