Thursday, 13 September 2007

Lesson 3: Compressing Streams

Compression - useful in real-world projects to save space or bandwidth. .NF supports 2 new stream classes that can compress data.
  • GZIP & DEFLATE - 2 mthds inside .NF. Use industry-std compression algorithms. No intellectual-property issues.
  • size limit - can compress upto 4GB of uncompressed data.
  • said comp. mthds exposed by .NF as GZipStream() & DeflateStream().
  • gzip or DEFLATE? - GZIP allows for headers for xtra info. Thus if internal use DefalteStream - slightly smaller but if distributing externally use GZIP.
  • GZipStream() - allows comp.

How to Compress Data with a Compression Stream

  • Compression streams don't write to a resource (e.g. a file, memory) - they write to other streams.
  • typical scenario - read an existing file & write to a new compressed version of the file.
  • GZipStream compStream = new GZipStream(destFile, CompressionMode.Compress) - a compression stream wraps the stream that contains (or will contain) compressed data.

Wednesday, 12 September 2007

lesson 2: Using Common Ref Types II

Understanding Readers & Writers

  • TextReader/TextWriter - abstract classes fro mwhich StreamReader/Writer are derived.
  • StringReader/Writer - to read/write to/fro in-memory strings.
  • StringWriter uses a 'StringBuilder', so it is very efficient at creating ever larger strings.
  • BinaryReader/BinaryWriter - for handling binary data to/from streams (i.e. binary files).
  • long number = reader.ReadInt64(); byre[] bytes = reader.ReadBytes(4);...
  • MemoryStream class - func. to create in-memory streams.
  • When use MemoryStream? Do time-intensive work inthe MemoryStream and then open the dest. file, flush the data to it, and close the file quickly.
  • BufferedStream - to wrap streams to improve performance by buffering reads & writes thro the stream. Writing out data to a stream directly does not perform very well. BufferStream wraps another stream object, to allow for writes to happen to a buffer. Only when the buffer is flushed does the data get pushed into the underlying stream.

Monday, 3 September 2007

lesson 2: Using Common Ref Types.

Ref Types Vs Value Types

  • Ref variable - holds the address of data rather than the data itself.
  • Assigning one ref. var to another - doesn't copy the data - merely creates 2nd copy of ref to same data.
  • 2500 built-in ref types - everything NOT derived from System.ValueType

Strings/StringBuilder

  • Immutable - cannot change - System.String.
  • Avoid temporary strings - s = "a"; s+= "qwerty"; - 2 strings created, of which only the last will have a ref. 1st garbage collected. Avoid unnecessary garbage collection here by using String class's Concat(), Join() & Format() mthds. Or use StringBuilder class to create mutable strings.
  • StringBuilder class - can span multiple stmts.

Create/Sort Arrays

  • int[] ar = {3,1,2};
  • Sort using static mthd - Array.Sort(ar);

Streams (System.IO.Stream)

  • common type - means of reading from/writing to disk.
  • StreamReader/StreamWriter - simplest - enable reading from/writing to txt files.
  • sr.ReadToEnd();

Exceptions

  • Catch block - skipped if no error encountered in try block.
  • define own exceptions - derive from System.ApplicationException.
  • Filtering Exceptions - mutiple catch blocks - runtime will only execute the 1st Catch block with a matching exception. THUS ORDER CATCH BLOCKS FROM MOST-SPECIFIC TO LEAST SPECIFIC.
  • Finally{} - runs whether an exception occured or not.
  • All code in try/catch blocks.

Monday, 20 August 2007

70-536 - Ch1 - Lesson 1 - Using Value types.

  • .NET Framework (.NF) - an integral Windows component.
  • Value types (VT) - simplest types in .NF.
  • Contain their data directly - no ref to data stored elsewhere.
  • Instances of VT stored on stack.
  • 3 general VTs: built-in types, user-defined types, enumerations. Each is derived from System.ValueType.

Built-in VTs

  • Base types, provided by .NF. Other types are built from these.
  • Optimizing performance - runtime optimizes perf. of Int32 & UInt32. For F.P use Double.
  • VTs function as objects - you can call methods on them (e.g. ToString() ).
  • In .NT, all types are derived from System.Object.

Declaring VTs

  • declare symbol as instance of that type.
  • VTs - implicit constructor - declaring them instantiates the type automatically. (No ''new' keyword).
  • Constructor assigns a default value to new instance (e.g. o or null).
  • Best practice - explicitly initialize within declaration - bool b = false;
  • C# is case-sensitive.
  • Nullable - new type in .NF 2.0 - allows one to determine whether a value has been assigned or not.
  • Nullable b = null;
  • Shorthand - bool? b = null;
  • HasValue and Value members - if (b.HasValue) ... else ...;

Creating User-Defined Types

  • UDFs - structures/structs.
  • structs - composite of other types - easier to work with related data.
  • example - System.Drawing.Point.
  • explicit construction - System.Drawing.Point p = new System.Drawing.Point(2,3);
  • define own structures ~ struct keyword.
  • Class/Struct - former created on heap & is ref type, latter created on stack & is VT.

Creating Enumerations

  • Enums - related symbols that have fixed values.
  • Use to provide a list of choices to developers using your class.
  • E.g. - enum Titles : int { Mr, Ms, Mrs, Dr };
  • Use when developers consuming your types must choose from a limited set of choices for a value.

---------------------------

Structs

  • struct - UDT. A lightweight class.
  • similar - constructors, methds, fields, properties, operators,...
  • diffs - dont support inheritance (cant inherit from any other class + implicitly sealed), or destructors. Class ref type, struct VT.
  • structs - use only for types that are small, simple, and similar in behaviour and characteristics to built-in types.
  • structs - > efficient in arrays, <>
  • structs - can implement mult. interfaces.
  • diffs - no custom default (i.e parameterless) constructor. Also cannot init. an instance fld in a struct (e.g. private int xVal = 50; )
  • structs - can create without 'new' - though not recommended - more difficult to read.
  • struct - override ToString() - prevents boxing. (e.g. when passing -> WriteLine() ).

Thursday, 19 July 2007

70-536 and everything after...

I'm writing this at work...feeling good...work's under control, my headphones are on...TMS...1st day of the 1st test, Lord's - England Vs India - England are batting, 225/2. Geoff Boycott's laying into Andrew Strauss, who has just fallen. I love Geoffrey Boycott...

OK. Now for the science bit (courtesy of MSDN):

The following list includes the topic areas covered on this exam. The percentage indicates the portion of the exam that addresses a particular skill.
•
Developing applications that use system types and collections (15 percent)
•
Implementing service processes, threading, and application domains in a .NET Framework application (11 percent)
•
Embedding configuration, diagnostic, management, and installation features into a .NET Framework application (14 percent)
•
Implementing serialization and input/output functionality in a .NET Framework application (18 percent)
•
Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features (20 percent)
•
Implementing interoperability, reflection, and mailing functionality in a .NET Framework application (11 percent)
•
Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application (11 percent)


This is pretty clear, and I'll use the attached percentages to divvy up my effort. So based on a (maximum of) 2 months to cover this syllabus, I'll...well...you can do the maths yourself.

Also I've ordered a few books:

http://amazon.co.uk/o/ASIN/0735622779/ref=s9_asin_image_3-2259_g1/202-8371832-7578263?pf_rd_m=A3P5ROKL5A1OLE&pf_rd_s=center-1&pf_rd_r=12BJF7MXNZ4C67NYW1KR&pf_rd_t=101&pf_rd_p=139042191&pf_rd_i=468294
http://amazon.co.uk/o/ASIN/0764578472/ref=s9_asin_image_1-2259_g1/202-8371832-7578263?pf_rd_m=A3P5ROKL5A1OLE&pf_rd_s=center-1&pf_rd_r=1WP63H8EZH83BTCGGFYE&pf_rd_t=101&pf_rd_p=139042191&pf_rd_i=468294
http://amazon.co.uk/o/ASIN/1590595890/ref=s9_asin_image_1-2259_g1/202-8371832-7578263?pf_rd_m=A3P5ROKL5A1OLE&pf_rd_s=center-2&pf_rd_r=07KEWJYGJB8HXWN2G908&pf_rd_t=101&pf_rd_p=139046091&pf_rd_i=468294

The first one is the recommended MS Press text, which has got pretty good write-ups. The other two are deliberately not from the Microsoft List - my team leader, Ben, sensibly suggested that getting a non-Microsoft view of their technology often reveals things which you wouldn't get from the party mouthpiece.
Well I've changed one thing already - there's no way I can achieve this within a year. I spoke to a guy on my team, Sachin, who has 'previous' re. all this, and whilst he managed a staggering 5 exams in 9 months, he was putting in on average 30 hours study a week. I couldn't, and nor would I want to, commit this much of my time to this venture. Farah my wife would divorce me or kill me (or both), and besides which, there has to be time for the finer things in life like playing squash, and sitting down and having a cup of tea, whilst watching someone else sit down and have a cup of tea (aka Big Brother). Instead I'm gonna pitch myself at 10-hours a week - 1.5hrs per weekday, and 2.5 hrs over the weekend. At that rate I reckon I'll be good for an exam every 3 months - I'll plan for that anyway. I thinking 2 months to cover a syllabus, and one month exam prep. Let the games begin...

Ground Zero.

Right. My mission, should I chose to accept, (which I have), is to obtain an MCPD from scratch, within 18 months. Fleshing that out a bit, I intend on taking the following exams in the following order:

70-536 (Application Development Foundation),
70-526 (Windows Dev),
70-528 (Web Dev),
70-529 (Distributed Apps Dev), and then finally the PRO exam...
70-549 (Designing and Developing Enterprise Applications).

Oh, and there'll (probably) be one for the road:

70-445 (Sql Server 2005 Business Intelligence)

So that's 6 exams to study for and pass...today's 19th July, 2007...is it realistic to have successfully completed all this by Christmas 2008? Truth is, I don't know. I'd like to think so, and I'll start out planning accordingly, but...