Difference between revisions of "OOP Class14"

esse quam videri
Jump to: navigation, search
m (Text replacement - "<csharp>" to "<syntaxhighlight lang="csharp" line="1" >")
m (Text replacement - "</csharp>" to "</syntaxhighlight>")
Line 23: Line 23:
 
                         shortsP[i] = 1;
 
                         shortsP[i] = 1;
 
                     });
 
                     });
</csharp>
+
</syntaxhighlight>
  
 
Demo
 
Demo
Line 59: Line 59:
 
             return "count is " + Count;
 
             return "count is " + Count;
 
         }
 
         }
</csharp>
+
</syntaxhighlight>
  
  
Line 85: Line 85:
 
             sw.Write("Hello World!!!");
 
             sw.Write("Hello World!!!");
 
             sw.Close();                                  //close writer
 
             sw.Close();                                  //close writer
             fs.Close();                                  //close file stream</csharp>
+
             fs.Close();                                  //close file stream</syntaxhighlight>
  
 
http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class14/hellowrite.cs
 
http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class14/hellowrite.cs
Line 95: Line 95:
 
                 Console.WriteLine(sr.ReadLine());
 
                 Console.WriteLine(sr.ReadLine());
 
             }
 
             }
             sr.Close();</csharp>
+
             sr.Close();</syntaxhighlight>
  
 
http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class14/echoFile.cs
 
http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class14/echoFile.cs
Line 118: Line 118:
 
     SmtpMail.SmtpServer = "localhost";
 
     SmtpMail.SmtpServer = "localhost";
 
     SmtpMail.Send(strFrom, strTo, strSubject, strBody);
 
     SmtpMail.Send(strFrom, strTo, strSubject, strBody);
%></csharp>
+
%></syntaxhighlight>
 
http://iam.colum.edu/oop/classsource/class14/mail.aspx
 
http://iam.colum.edu/oop/classsource/class14/mail.aspx
 
[[http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class14/mail.aspx -source]]
 
[[http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class14/mail.aspx -source]]
Line 166: Line 166:
 
</tr>
 
</tr>
 
</form>
 
</form>
</csharp>
+
</syntaxhighlight>
  
 
Parse the multipart form and save the file msdn library. System.Web.HtmlInputFile.PostedFile Property
 
Parse the multipart form and save the file msdn library. System.Web.HtmlInputFile.PostedFile Property
Line 199: Line 199:
 
     }
 
     }
 
}
 
}
</csharp>
+
</syntaxhighlight>
  
 
http://iam.colum.edu/oop/classsource/class14/up.aspx
 
http://iam.colum.edu/oop/classsource/class14/up.aspx

Revision as of 18:28, 25 January 2016


Parallel

http://msdn.microsoft.com/en-us/library/dd460713(v=vs.110).aspx

samples: http://code.msdn.microsoft.com/windowsdesktop/Samples-for-Parallel-b4b76364

for

 1 long count = 200000000;
 2 short[] shorts = new short[count];
 3 for (long i = 0; i < count; i++)
 4                 {
 5                     shorts[i] = 1;
 6                 }
 7 </pre>
 8 
 9 Parallel.For
10 <pre>
11 short[] shortsP = new short[count];
12 Parallel.For(0, count, i =>
13                     {
14                         shortsP[i] = 1;
15                     });

Demo

http://iam.colum.edu/oop/classsource/class15/AsyncConsoleApplication.zip

http://iam.colum.edu/oop/classsource/class15/WindowsFormsApplicationAsync.zip

Async

http://msdn.microsoft.com/en-us/library/hh191443.aspx

 1 private void buttonBlock_Click(object sender, EventArgs e)
 2         {
 3             textBox1.Text =  DoLongCount();
 4         }
 5 
 6         //Async call to async method
 7         private async void buttonAsync_Click(object sender, EventArgs e)
 8         {
 9             textBox1.Text = await DoLongAsyncCount();
10         }
11 
12         private string DoLongCount()
13         {
14             System.Threading.Thread.Sleep(1000);
15             Count++;
16             return "count is " + Count;
17         }
18 
19         //Async Task
20         private async Task<string> DoLongAsyncCount()
21         {
22             await Task.Delay(1000);
23             Count++;
24             return "count is " + Count;
25         }


Final Review

OOP Final Review

  • Be very familiar with c# syntax
    • Basic object types (int, bool, string)
    • Conditional and Branching statements
    • Arrays and Generics ie List
  • Understand Classes and Inheritance.
  • Use some advanced class features such as abstract classes and virtual methods that are overridden
  • Understand class relationships
    • Is A
    • Has A
    • Uses A
  • Understand Encapsulation, Abstraction and Polymorphism
    • Abstraction
Each class should abstract its behavior in order to increase usability, reuse, and organization.
    • Encapsulation
Each class should contain all of the properties and methods it needs. It should only expose what is necessary to outside classes.
    • Polymorphism
many forms, same code interface but interchangeable classes
  • Be able to read and create UML Diagrams
  • Be able to recognize and use simple design patters

The final will be consist of two sections the writtens section and the practical section. The practical section will be open everything excpet open mouth (yes open note open book open web). You will not be ablt to use any of theese resources during the written section.