- Full Description
Beginning C# Object-Oriented Programming brings you into the modern world of development as you master the fundamentals of programming with C# and learn to develop efficient, reusable, elegant code through the object-oriented programming (OOP) methodology. Take your skills out of the 20th century and into this one with Dan Clark's accessible, quick-paced guide to C# and object-oriented programming, completely updated for .NET 4.0 and C# 4.0.
As you develop techniques and best practices for coding in C#, one of the world's most popular contemporary languages, you'll experience modeling a real world application through a case study, allowing you to see how both C# and OOP (a methodology you can use with any number of languages) come together to make your code reusable, modern, and efficient.
With more than 30 fully hands-on activities, you'll discover how to transform a simple model of an application into a fully-functional C# project, including designing the user interface, implementing the business logic, and integrating with a relational database for data storage. Along the way, you will explore the .NET Framework, the creation of a Windows-based user interface, a web-based user interface, and service-oriented programming, all using Microsoft's industry-leading Visual Studio 2010, C#, Silverlight, the Entity Framework, and more.
What youll learn
- Learn to use the Universal Modeling Language (UML) to quickly design an application correctly from the first time
- Understand object-oriented programming principles and how they benefit your work in today's dual Web- and Windows-based world
- Integrate OOP fundamentals when developing code in C#
- Discover the .NET Framework and how it can help you create applications quickly and efficiently
- Walk along as the author develops a complete Windows- and Web-based application using the techniques and best practices covered inside
Who this book is for
- If you're a beginning C# programmer who wants to gain a foundation in object-oriented programming along with the C# language basics, this book is for you.
- Programmers transitioning from a procedure-oriented programming model to an object-oriented model will also find many practical suggestions and walkthroughs inside.
- In particular, Visual Basic developers who want to transition to C# programming, but lack a firm grasp of object-oriented programming principles, will find this book an excellent starting point for their journey into C#.
- Table of Contents
Table of Contents
- Overview of Object-Oriented Programming
- Designing OOP Solutions: Identifying the Class Structure
- Designing OOP Solutions: Modeling the Object Interaction
- Designing OOP Solutions: A Case Study
- Introducing the .NET Framework and Visual Studio
- Creating Classes
- Creating Class Hierarchies
- Implementing Object Collaboration
- Working with Collections
- Implementing the Data Access Layer
- Developing Windows Applications
- Developing Web Applications
- Developing and Consuming WCF Services
- Developing the OSO Application
- Wrapping Up
- Fundamental Programming Concepts
- Exception Handling in C#
- Installing the Required Software
- Source Code/Downloads
Please Login to submit errata.On page 86:
Point #4 is missing the word "Forms". The first sentence should read:
Click the Windows Forms Application template.
Additionally, the screen shot is for Visual Studio 2010 and the Visual C# 2010 Express which you recommend for your book has a slightly different dialogue box.
On page 86:
Since you recommend the Express version on page xvi, you should have "File > New Project" in point #1 instead of "File > New > Project".
On page 97-99:
Conditional breakpoints cannot be performed in Visual C# 2010 Express. As well, there is no Breakpoints tab in the Output window. These features have been intentionally left out by Microsoft.
On page 104:
The AddEmployee() method is incorrect. The last line of the method returns EmployeeID which has not been declared in the method (or at least explained in a comment).
On page 105:
In point #2, your second sentence ends with "... and then click Open.". It should read "... and then click Add."
On page 109:
The first sentence has the descriptions of the first and second methods backwards. It should read:
"Because the parameters type list of the first method (string, string, string, string) differs from the parameter type list of the second method (string, string), the compiler..."
On page 120:
Point #5 should start with "Select Debug > Start Debugging." You are missing the last word.
The point #3 at the bottom of the page says "Switch to the frmTeller code..." but should read "Switch to the TellerForm code...".
On page 124:Code example shows:
throw new Exception(....
The Framework Design Guidelines (ISBN 0-321--24675-6) on page 197, section 7.3.1 states that System,Exception should not be thrown by application code. The correct exception is probably System.InvalidOperationException.
There is a similar issue on page 119 where an ArgumentException (or a sub-type) should be thrown.
On page 127:
Point #1 starts with "Open the frmTellor form..." but should read "Open the TellerForm form..."
Point #4 should start with "Select Debug > Start Debugging." You are missing the last word.
On page 130:
The first full paragraph starts with "A class implements the interface by using a semicolon followed by...". It is not a semicolon, but a colon which is used.
On page 132/133:
Not an error, but a suggestion. Since the IDE inserts text automatically during step #5, it would be nice to give a warning. Maybe you could devise a symbol which could sit in the margin next to code.
On page 135:
When you execute the first point #5 there will be errors for Program.cs because in point #2 on the previous page you commented out the code in the Account.cs but not the Program.cs.
On page 140:No errors to report, but some comments on "Understanding Delegation". In earlier parts of the book when you anticipated a question, you posed it and answered it. I think this is another place where that could have been done. A Delegate sounds an awful lot like the abstract class and interface which you described earlier. Why not use them?
For your SortIntegers() method, I would suggest pointing out that by passing the method names of AscendOrder and DescendOrder to the CompareInt constructor, one is actually passing a pointer to the method that should ultimately be executed when CompareInt is used to compare two integers.
As well, you may want to devise a different example as http://msdn.microsoft.com/en-use/library/ms173173(v=vs.80).aspx suggests the following:
One good example of using a single-method interface instead of a delegate is IComparable or the generic version, IComparable<(Of <(T>)>). IComparable declares the CompareTo method, which returns an integer that specifies a less than, equal to, or greater than relationship between two objects of the same type. IComparable can be used as the basis of a sort algorithm. Although using a delegate comparison method as the basis of a sort algorithm would be valid, it is not ideal. Because the ability to compare belongs to the class and the comparison algorithm does not change at run time, a single-method interface is ideal.
On page 141:In the section "Responding to Events", the last three lines of program code start with "Data odata = new Data()". Where did this class come from?
As well, to be consistent with your earlier code, the variable odata should be oData.
On page 142-143:Since you recommend the Express version on page xvi, you should have "File > New Project" in point #1 instead of "File > New > Project".
Point #2 has "Windows Application" but should be "Windows Forms Application".
Since you are dealing with novices like me who are going to take what you write quite literally, Table 8-1 should be changed a little. In the "Property" column, "Name" should be "(Name)".
On page 144:It would be worth warning that when the second line of code in point #3 is entered the IDE will create the method for point #4. Of course, the "throw new NotImplementedException" it creates has to be replaced with the MessageBox of point #4.
Point #6 should be "Select Debug > Start Debugging to run the project" You are missing "Debugging".
On page 145:Point #1 says "...by right-clicking the frmLogin in the Solution Explorer...". Actually, it still shows as Form1.cs and one needs to right-click on the name in Solution Explorer and rename it to frmLogin.cs.
Figure 8-2 shows the "F" in "File and the "x" in "Exit" underlined, but your steps do indicate how to get the underlining to occur.
On page 152:Since you recommend the Express version on page xvi, you should have "File > New Project" in point #1 instead of "File > New > Project".
Point #2 has "Windows Application" but should be "Windows Forms Application".
On page 153:Table 8-2 can be made easier for people like me who take things literally by changing the "Property" column so that "Name" is shown as "(Name)" which is how the IDE displays it.
Point 6 starts with "Add as static..." but should be "Add a static...".
In point #7, the second sentence should start with "Double-click...". You are missing the hyphen. Further in point #7 it reads "... and displays the results in the form's text property.". Change "results" to "result".
On page 153:Point #9 should start "Select Debug > Start Debugging." You are missing "Debugging".
Point #9 also says you will get a FileNotFoundException. Actually you get a DirectoryNotFoundException because you never asked for te directory to be created.
Point #4 should start "Select Debug > Start Debugging." You are missing "Debugging".
On page 155:Point #3 should start "Select Debug > Start Debugging to run the project." You are missing "Debugging".
Point #3 will not work as described unless you tell the reader to create c:\Test
Point #6 should start "Select Debug > Start Debugging to run the project." You are missing "Debugging".
Point #9 does not need the comma.
On page 157:Since you recommend the Express version on page xvi, you should have "File > Open Project" in point #1 instead of "File > Open > Project".
On page 158:In table 8-3, in the "Property" column, change the "Name" to "(Name)" to match what the IDE displays.
In point 6, the third sentence starts "Then create StreamReader object..". It should be "Then create a StreamReader object...".
On page 168:The output in figure 9-2 does not completely match the program code from the previous page. The first few lines of the program code are not in the output of figure 9-2.
On page 169:The explanation should include what exactly the value for "capacity" means. It is not clear from the explanation that more space than is required is allocated and that "capacity" reflects this allocated space.
On page 170:Since you recommend the Express version on page xvi, you should have "File > New Project" in point #1 instead of "File > New > Project".
On page 173:Point #4 should start with "Select Debug > Start Debugging to run the project" You are missing "Debugging".
The last paragraph starts with "Although the two dimensional array...". It needs a hyphen to make "two-dimensional".
On page 174-175:What appears to be point #4 really is two points. What should be point #5 should start with the line that begins "After the ArrayList is populated,...". This means points #5 to #8 on page 175 should be renumbered #6 to #9.
The program code in point #4 (in the portion which should be point #5), the Console command in the foreach loop causes an error ("ArrayList not found"). This is because the IDE automatically puts "using System.Collections.Generic" and is needs to be "using System.Collections".
Point #5 (which should really be #6), should start with "Select Debug > Start Debugging to run the project" You are missing "Debugging".
Point #7 (which should really be #8), should start with "Select Debug > Start Debugging to run the project" You are missing "Debugging".
Point #8 (which should really be #9) does not need the second comma.
In the section "Using Generic Collections", you could mention that we first saw generic collections in Chapter 7, p131.
On page 176:Near the end of the last paragraph there is a sentence which reads "The CustomerSorter class shown next sorts a list of Customer by CompanyName.". It needs the word "type" so that it reads "The CustomerSorter class shown next sorts a list of type Customer by CompanyName."
On page 177:Since you recommend the Express version on page xvi, you should have "File > New Project" in point #1 instead of "File > New > Project".
On page 178:In point #6, it would be good to warn the reader the last bit of the program code is automatically created by the IDE with something that needs to be replaced with the code you provide.
Point #8 should start with "Select Debug > Start Debugging to run the project" You are missing "Debugging".
Point #11 says "Add the following code in the Main method of the Program class prior to the. Console.WriteLine method." Not only is there an extra period after "the", but it is wrong. It should read "Add the following code in the Main method of the Program class after the foreach loop containing the Console.WriteLine method."
Point #12 should start with "Select Debug > Start Debugging to run the project" You are missing "Debugging".
On page 179:I would suggest pointing out to your readers that generic and non-generic versions of Stack and Queue objects exist.
On page 188:In the sample program code at the bottom of the page, the variable lastInitial is used but is never defined. It seems to come out of nowhere.
On page 199:Step 7, code at the bottom of the page. The fill adapter should be (authorDataSet, "Authors"). Author in quotes should be Authors.
On page 204:Step 10. Binding would not work between the stores table and the sales table. In order to get this to work I had to make the following changes:
At the Form2 class leve I added I added two binding statements:
BindingSource dgvStoresBindingSource = new BindingSource();
BindingSource dgvSalesBindingSource = new BindingSource();
I rewrote the btnGetData_Click event as follows:
dgvStores.DataSource = dgvStoresBindingSource;
dgvSales.DataSource = dgvSalesBindingSource;
StoreSales storeSales = new StoreSales();
StoreSalesDataSet = storeSales.GetData();
dgvStoresBindingSource.DataSource = StoreSalesDataSet;
dgvStoresBindingSource.DataMember = "Stores";
dgvSalesBindingSource.DataSource = dgvStoresBindingSource;
dgvSalesBindingSource.DataMember = "StoresToSales";
This corrected the problem, but I'm not sure if this is the best solution. Please advise.
On page 294:Code at the top of page. Fourth line down starting with "String strSQL", Description should be Drscript.
On page 320:Last sentence on the page (under the Arrays heading):
... so you declare an array data type by placing square brackets () immediately following the variable name, like so:
But I don't think you place the square brackets immediately following the variable name. You place square brackets immediately following the data type as you show in the example.
On page 321:Third paragraph on the page, starting with: "C# supports multidimensional arrays. When you declare the array, you separate the size of the dimensions by commas. The following declaration creates a two-dimensional array of integers with five rows and four columns:
string[,] name = new string[4,3];
The error is your example. It is not declaring an array of integers, nor is it creating five rows and four columns.
On page 330:For the condition in the while statement, it should be
while (validLogin == false)
or even simply
In C#, one has to use == for equality comparison, and if a variable is Boolean, there is no need to check if it is equal to false or true again...
On page 336:"These classes need to inherit from System.ApplicationException" - this is not correct now.
Please see http://msdn.microsoft.com/en-us/library/system.applicationexception%28v=VS.100%29.aspx and note the advice "If you are designing an application that needs to create its own exceptions, you are advised to derive custom exceptions from the Exception class. It was originally thought that custom exceptions should derive from the ApplicationException class; however in practice this has not been found to add significant value. For more information, see Best Practices for Handling Exceptions."