1 / 57

بسم الله الرحمن الرحيم

بسم الله الرحمن الرحيم. اللهم صلي على محمد و ال محمد. مدخــــــــــل الى عالم البرمجة. اعداد علي Perl_sourcer@yahoo.com. What is programming?.

burian
Download Presentation

بسم الله الرحمن الرحيم

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. بسم الله الرحمن الرحيم اللهم صلي على محمد و ال محمد

  2. مدخــــــــــل الى عالم البرمجة اعداد علي Perl_sourcer@yahoo.com

  3. What is programming? • Computer programming (often shortened to programming or coding) is the process of designing, writing, testing, debugging / troubleshooting, and maintaining the source code of computer programs. This source code is written in a programming language. The code may be a modification of an existing source or something completely new. The purpose of programming is to create a program that exhibits a certain desired behaviour (customization). The process of writing source code often requires expertise in many different subjects, including knowledge of the application domain, specialized algorithms and formal logic.

  4. Programes vs. Scripts

  5. Compiled vs Interpreted

  6. Dynamic vs. Static

  7. Source vs. binary

  8. Desktop vs. Web

  9. ServerSide vs. ClientSide

  10. What do you need? • Text Editor • Compiler or Interpreter

  11. What do you need ? • Or just use and IDE:

  12. What do you need ? • Or just use and IDE:

  13. What do you need ? • Or just use and IDE:

  14. What do you need ? • Or just use and IDE:

  15. What do you need ? • Or just use and IDE:

  16. Program. Langs. Categorization • Microsoft(Windows): vb, asp, C#, .NET..etc • Unix: C|C++, python, perl, php, ruby…etc • Sun JVM: Java, Groovy, Fortress, Scala, Jython…etc.

  17. Programming Paradigm: • A programming paradigm is a fundamental style of computer programming. (Compare with a methodology, which is a style of solving specific software engineering problems.) Paradigms differ in the concepts and abstractions used to represent the elements of a program (such as objects, functions, variables, constraints, etc.) and the steps that compose a computation (assignment, evaluation, continuations, data flows, etc.).

  18. Programming Paradigms: • Procedural • Object Oriented • Event driven • Functional

  19. Procedural Prog.

  20. Sequenced • Like get two numbers, add them, return the result. • {my $number =1; • my $number2 =2; • print $number+$number2; }

  21. Control Structeres • IF statement: • if ($user eq "Ali") • {print "Access granted!"} • Adding else: • else{ print "I don't know you"} • Introducing more conditions: • elsif($user eq "fatima") • {print "I love u!"}

  22. Control Structeres • Unless: • unless($a == 10) • { • print "The number isn't 10";} • if ($a != 10) • { • print "The number isn't 10"; • }

  23. Control Structres: • FOR • for (1..10) • {print "looping 10 times!\n"} • Long style: • for ($a=0;$a<10;$a++) • {print "loop $a"}

  24. Control Structers • Foreach : • my @list = qw/Ali Sara YosraMamdoh/; • foreach (@list){ • print $_, " You are a member of the family!\n"; • }

  25. Control Structers: • WHILE • $a= 10; • while ($a != 0) • {print $a--;} • Ouputs: 10987654321

  26. Control Structers: • Introducing until: • my $controller = 10; • until ($controller == 20) • { • print"going up unitl 19\n"; • $controller++; • }

  27. Control Structers • given( $name ){ • when("Ali"){ say "welcome $name your are the 1st"} • when("Saleh"){say "welcome $name your are the 2nd"} • when("Hashem"){say "welcome $name your are the 3d"} • default{say "I don't know you"}}

  28. Control Structures • use Switch; • switch ( $name ){ • case "Ali" { say "welcome $name your are the 1st"} • case "Saleh" {say "welcome $name your are the 2nd"} • case "Hashem" {say "welcome $name your are the 3d"} • else {say "I don't know you"} • }

  29. Expression Modifiers • use 5.010; • $bool = 1; • $a = 5; • say "I am in love" if $bool; • say "false" unless $bool; • say "my name is", ($a++) while $a < 9;

  30. Records • Variable : can hold one item only; • my $number = 1; • Array: can hold more than one item • my @array = qw\ali yasser salman\; • print $array[0];

  31. Records • Null value: • if (defined($my_total)){} • my $var = undef;

  32. Records • Hashes: • my %hash= qw/ • 0555555 ali • 0666666 yasser • 0899999 basem/; • foreach $phoneNumber(keys %hash) • { • print "$phoneNumber = $hash{$phoneNumber} \n"}

  33. Subroutines: • Chunks of frequent used code: like headers, footers,..etc • &hello(); sub hello(){ • print "welcome to ali website";} • Passing parameters: • &hello("Visitor1"); sub hello(){ • $name = shift; • print "welcome to ali website\n"; • print "welcome $name";}

  34. Subroutines: • Passing more than one item: • &hello("Visitor1","Visitor2"); • sub hello(){my ($name1, $name2) = @_; • print "welcome to ali website\n"; • print "welcome $name1"; • print "welcome $name2";} • Returning: • print &hello(); sub hello(){ • return 1;}

  35. Scoping: • $total = 10; • $number = 12; • &adding($number); • sub adding() • { • $number = shift; • $total = $total + --$number; • } • print $number; • print $total;

  36. Naked block Control Structer • { • my $name = "Ali", $age="24", $location="SA"; • print $name; • print $age; • print $location • }

  37. Regular Expressions: • if($string =~ m/(A|E|I|O|U|Y|a|e|i|o|u|y)/)  {print "String contains a vowel!\n"} • $string =~ s/Ali Yami/Ali Qahtani/; • Change everything to upper case: $string =~ tr/[a-z]/[A-Z]/; • Change everything to lower case $string =~ tr/[A-Z]/[a-z]/;

  38. Modules • Ready to use libraries for the language: • Like bindings for GUI libraries, or facilities to work with internet, etc. • CPAN…

  39. Object Oriented • Objects • Data fields • Methods • Classes

  40. Inheritence

  41. Polymorphism

  42. Overloading vs OverRiding

  43. Pure OO vs Hybird

  44. GUI programing:

  45. Event Driven programing:

  46. Exceptions

  47. Exceptions: • Eval • $total = 13/0; • print $total; • Program fails with: Illegal division by zero

  48. Exceptions • Defensive programming: • $a= 10; • $b = 0; • if ($b == 0){ print"you are trying to divide by zero"} • else { print $a/$b;}

  49. Extreme Programing

  50. Tests • use Test::Simple tests => 2; • use Date::ICal; • my $ical = Date::ICal->new; # create an object • ok( defined $ical ); # check that we got something • ok( $ical->isa('Date::ICal') ); # and it's the right class

More Related