Francesco's blog

 Saturday, July 01, 2006

My new C# book has been released a few months ago, but I was so busy with my everyday activities that I didn't even blogged about it. Instead of going to the beach, today I sat down a prepare a home page for the book, from where you can download two sample chapters: Chapter 5 "Arrays and Collection" and Chapter 10, "Custom Attributes", as well as all the code samples and the errata doc.

Books | C#
7/1/2006 10:35:25 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 

At last I found the time to sort all the notes from readers, pointing at typos and mistakes in my VB2005 book, and to update the errata document that you can download from the book's home page. I have clearly marked the additions with a "New" marker. Most of these notes are typos that don't affect how code works, with the notable exception of the fix to the Evaluate function in Chapter 16 (regular expression).

My grat thanks to all the readers who took the time to write me to inform of the mistakes they found, with a special mention to Dan Karmann, who actually methodically proof-read the book and found about twenty of them.

 

7/1/2006 9:01:26 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [1]  | 
 Monday, May 29, 2006

I have been so busy in May that I couldn't update the blog, not even to mention that my latest Microsoft Press book had been released and is now available on all major US bookstores. With fewer than 600 pages, Programming Microsoft Visual C# 2005: The Base Class Library is surely the shortest book I wrote. Not only that: it's also the book that took me less time to wrote. In fact, this book is basically the translation to C# of the second half of my VB 2005 book, more precisely of the chapters that have to do more with the .NET Framework and less with the C# language itself. Here's the Table of Contents:

1. .NET Framework Basic Types
2. Object Lifetime
3. Interfaces
4. Generics
5. Arrays and Collections
6. Regular expressions
7. Files, directories, and streams
8. Assemblies and resources
9. Reflection
10. Custom attributes
11. Threads
12. Object serialization
13. PInvoke and COM interop

Even though the book isn't specifically on the C# language, it adequately covers most of the new features of C# 2.0, such as generics, iterators, and anonymous methods.

Why a book on the BCL? Well, in these years I realized that far too many developers focus solely on high-level features - such as Windows Forms, ADO.NET, and ASP.NET - and often fail to leverage the full potential from other portions of the .NET Framework. For example, I have seen many apps that use verbose and unefficient validation rules that might be replaced by a single regular expression. Or apps that could be written in a fraction of time (and lines of code) if the author had been conscious of the full potential of reflection and custom attributes. Not to mention the fact that new .NET 2.0 features, such as generics, could make things only worse.

In general I find that most books that are "translated" from a different programming language are disappointing, so you might wonder why this book should be different. First, when I signed the contract for my VB 2005 book I already knew that the book would have been translated to C#, thus I planned the book so that its structure wouldn't be too VB-centric. Secoond, in the last four years I have been using C# in virtually all my programming projects - in fact I have surely written more C# code than VB code. For this reason, you'll find that the C# code is carefully optimized to use all the usual C#-specific techniques, such as iterators and anonymous delegates.

Shortly I will prepare a home page for the book on this site, with a couple of sample chapters. In the meantime, you can read more about the book (and hopefully order it) on Amazon's home page.

5/29/2006 8:50:45 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [4]  | 
 Tuesday, February 28, 2006

A few minutes ago I made all the code samples for Programming Microsoft Visual Basic 2005: The Language available on the book home page. It's a 7.5M download that contains several thousand lines of carefully crafted, optimized, reusable source code, including the following:

  • a VB class that works with fractions
  • a base form for simplified data entry
  • a class to cache text files
  • several custom iterators for better For Each loops
  • tons of examples with generics
  • two expression evaluators, the former built on regexes, the latter implemented via on-the-fly compilation
  • a utility to display project statistics (a demo for regexes)
  • a RegexTester stand-alone utility, to help you build, test and compile regular expressions
  • an example of custom provider for My.Settings
  • an example of how you can intercept ANY event from ANY set of Windows Forms controls
  • attribute-based benchmarks
  • a complete infrastructure for writing Windows Forms plug-ins
  • an attribute-based library to write data-centric N-tier applications
  • several Visual Studio macros
  • Visual Studio visualizers for files, regex, and images
  • .... and a lot more

On the same page you can also find an errata document for typos and mistakes found after the book went to print.

Enjoy the code (and buy the book if you like it! :-) )

2/28/2006 7:10:13 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 Sunday, February 12, 2006

Great news for yours truly.

Practical Guidelines and Best Practices for Visual Basic and Visual C# Developers won an Excellence Award from the Society of Technical Communication, which selects the best books, sites, and coursewares published in the year. Not just programming-related or computer-related publishing, but technical publishing in the wider sense. As a matter of fact, among the books that won the award, only about ten have to do with software. And the book I co-authored with Giuseppe Dimauro (the other Italian RD) is the only book from Microsoft Press that won the award. I guess it's something we can be quite satisfied of :-)

It's an important acknowledgement and I am especially happy because it's the first book I wrote that isn't part of the "Programming Visual Basic" series, which now counts four editions (VB6, 2002, 2003, and 2005). The "Practical Guideline" book is a truly unique book, the first and only coherent collection of guidelines for .NET developers.

 

2/12/2006 8:51:08 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [1]  | 
 Monday, January 16, 2006

If I could get istantaneous results for the following simple two-question survey

  1. Is Visual Studio the application that you use most often?
  2. Did you ever use regex searches in the VS Find dialog box?

I'd bet that 80% of you would answer YES to the first question, but 99% of you would answer NO to the second question, which would be a rather weird result. Regex searches are among the most powerful VS features, yet few developers use them or even know that they exist.

IMHO, the real problem is that VS regex's syntax is completely different from the syntax you use with the Regex class, therefore using this feature requires that you learn yet another regex dialect. This is a bit too much for most developers. Microsoft should allow the standard regex syntax in this dialog: they could implement this change very easily and in a short time, without caring about backward compabibility issues.

While waiting for Microsoft to offer this little-big innovation, you can have fun with what you have today. Here are a few examples, excerpted from my new book Programming Microsoft Visual Basic 2005: The Language:

:i = :z   Search assignments of an integer constant (:z) to a variable (:i). In VB, but more rarely in C#, it can deliver false matches, when the = operator is used in an expression.

:i = :q   Search assignments of a quoted string constant (:q) to a variable.

(Dim|Private|Public) :i As String   Search for variable declarations of string type (VB only). You can easy adapt it to other data types.

Dim <(:Lu(:Ll)*)+> As   Search for local VB variables that use a PascalCase naming convention and therefore violate Microsoft's guidelines. (Local variables should use the camelCase convention.)

^:b*'.+\n   Search for comment lines in VB, that is, lines that begin with an apostrophe. (It doesn't consider the REM keyword.) You can replace the apostrophe with // to use this search pattern in C# as well.

Dim {:i} As (.|\n)#<\1>    Highlights the portion of code between the declaration of a local variable and the first occurrence of that variable in the method. You can repeat this search for all the local variables in a method and check whether you should refactor your code by moving the declaration closer to where the variable is used for the fist time. (See effect in figure below.)

1/16/2006 5:13:02 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 Saturday, January 07, 2006
In a week or two my new book, Programming Microsoft Visual Basic 2005: The Language will be available on Amazon and other online stores. Towards the end of January it should be available in most bookstores in the US.

In the meantime, you can get a taste of how the book looks like by reading two online chapters: Chapter 11, "Generics", and Chapter 18, "Reflection".

1/7/2006 4:53:16 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 Friday, December 16, 2005

As I anticipated yesterday, here is the TOC of my newest Programming Microsoft Visual Basic 2005, to be available in stores in early January.

Part I : The Basics
 1. Introducing the .NET Framework
(12 pages): a quick overview of basic concepts in .NET programming.
 2. Basic Language Concepts (70 pages): modules, classes, variables, arrays, operators, etc. plus what you need to know about inheritance and attributes so that you can read next chapters, before chapter 8 and 19.
 3. Control Flow and Error Handling (40 pages): If, Select, For, For Each and other basic statements; error handling, with many not-so-obvious techniques to improve code efficiency and programming style.

 4. Using Visual Studio 2005 (56 pages): the many new features of VS2005 IDE, plus many old features that not all developers know; how to write a code snippet for VS2005; templates, refactoring, and a brief but intense tutorial on VS macros.

 5. Debugging and Testing (56 pages): breakpoints and tracepoints, data tips, how to write a cusom visualizers, trace commands and trace listeners (including custom listeners), benchmarks and profiling, unit testing, and code coverage.

Part II : Object-Oriented Programming
 6.
Class Fundamentals (42 pages): the "usual" story about classes, methods, properties, etc. plus the new partial classes and operator overloading, all peppered with the description of relatively unknown programming techniques.
 7. Delegates and Events (26 pages): a small chapters with many details and secrets on how to use these VB features in real-world apps. It includes the new custom events.
 8. Inheritance (34 pages): inheritance at its best, including visual (form) inheritance and many real examples.

 9. Object Lifetime (28 pages): everything you might need to know about garbage collection, the Dispose/Finalize pattern, weak references, GC generations, object resurrection, and other advanced techniques that can take your app to the next level
10. Interfaces (28 pages): how to define a custom interface and, above all, how to leverage those that .NET provides you with, such as IComparer and IEnumerable.
11. Generics (40 pages): half of what you want to know about this new great .NET 2.0 feature (the second half is in chapter 13), including constraints, nullable types, and many examples of programming techniques that are based on generics.

Part III : Working with the .NET Framework
12. .
NET Basic Types (50 pages): working with strings, numbers, and dates at their best, including many little/big new features of .NET 2.0
13. Arrays and Collections (53 pages): arrays, jagged arrays, "traditional" and generics collections, plus many tricks for writing less code that runs faster.
14. Regular Expressions (40 pages): a reference of regex syntax, plus many practical examples on data validation, data parsing, and even code parsing. If you aren't familiar with regexs you are missing a great occasion for writing better code in less time.
15. Files and Streams (42 pages): an overview of all the types in System.IO and the many new features in .NET 2.0, including ACL support, compressed streams, and the TextFieldParser type.
16. The My Namespace (48 pages): how to use the My namespace and how to extend it as you need.
17. Assemblies and Resources (44 pages): despite of their importance, resources (either simple or localized) are used rarely and unproperly by most developers; this chapter includes a complete description of the many important features added to NGEN.

Parti IV : Advanced Topics
18. Reflection
(58 pages): there is a lot to say about reflection; among the many examples I wrote an app that generates code on the fly, a scheduler for undoable actions, and a universal comparer class.
19. Custom Attributes (46 pages): this chapter includes a few complete and nontrivial examples of how a custom attribute can make your coding simpler, for example by means of Windows Forms plugins and a framework for n-tier apps.

20. Threads (54 pages): the Thread object, asynchronous delegates, thread pool, the SyncLock statement, all the synchronization types, including the new Semaphore. Plus a section on threading in Windows Forms aoos.
21. Object Serialization (32 pages): binary and SOAP serialization, version-tolerant serialization in .NET 2.0, the new attributes for serializatoin, custom serialization, serialization surrogates, the IObjectReference interface, and more.
22 PInvoke and COM Interop (40 pages): How to interact with unmanaged code: calling "classic" DLL and Windows API methods; using COM components (including the new registration-free components); writing .NET components that can be used from COM apps.

As I already explained, this book isn't a mere VB 2005 reference. Better, in addition to being a complete reference book, it is a digest of the many programming techniques that you can implement by leveraging the features of the language and the .NET Framework 2.0, including generics, threads, reflection, custom attributes, serialization, delegate, regular expressions, and more. All descriptions aim to writing faster and more robust code. I looked hard for a similar book on the market before writing this one. I believe I finally wrote a book that does VB justice.

It has been a real tour de force, which kept me busy from May, summer included. Today I have completed the very last edit to PDFs, then everything goes to the printer!

12/16/2005 2:32:12 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 Thursday, December 15, 2005

Many readers are sending emails asking whether I was writing the 2005 edition of Programming Microsoft Visual Basic .NET. The answer is "yes and no".

Yes, I am writing the new edition of this book, updated to Visual Basic 2005.

No, I am not really writing a new edition of that book. The book I am finalizing this week is actually a brand new book, titled Programming Microsoft Visual Basic 2005: The Language. I decided to keep the title similar enough to the original one, to emphasize that the author is the same and that the approach is similar; however, I decided to added "The Language" postfix, to ring a bell in the mind of potential buyers who might otherwise believe that this is "just" an update to VB2005 and .NET 2.0.

The new book focuses only on the VB language and the .NET Base Class Library (BCL). It covers both old and new keywords as well as topics such as .NET data types, arrays and collections, streams, reflection, serialization, threading, PInvoke and COM interop. It does not cover high-level stuff such as Windows Forms, ADO.NET, and ASP.NET, though.

I thought hard about the Table of Contents of this new book, literally for months. In the previous edition I managed to squeeze in "only" 1400 pages virtually anything you need to work with .NET Framework 1.1, including advanced topics such as serviced components and remoting, Windows Forms and Web Forms custom control creation, security, and so forth. However, .NET 2.0 is much more complex that 1.1, and I estimated that I would have either needed to split the book in two volumes or be less specific on most topics. Both choices were unsatisfactory to me.

Also, I couldn't help noticing that there are too many great books around about Windows Forms or ASP.NET programming, and a single core-reference book is bound to be less complete than those books with a narrower focus. Granted, a book from a single author and that covers all these topics can offer a unified view of what is important in .NET programming, but I am sure that developers who are deeply interested in a specific area will buy a book that specializes in that area.

While I was taking note of what else could be found on bookstore shelves, I found out that all these high-level books often overlook the basics, for example out to get the best out of the language or basic data types such as DateTime, arrays, and collections. Most .NET developers know how to write great Windows Forms or ASP.NET applications, yet they don't know how to optimize string-intensive programs effectively. And I am not talking about the usual String vs. StringBuilder example, I am thinking of techniques such as this, this, or this. Another example is memory optimization: you can speed up your code by an order of magnitude using caching techniques based on the WeakReference type, or by means of a correct Dispose-Finalize pattern. Not to mention advanced techniques based on delegates and reflection, such as this, this,or this.

In the end, I realized that I could write a very good book on just the Visual Basic language and the most important facets of the BCL. Rather than (or in addition to) being a plain reference for VB keywords and .NET types, this book is more similar to a complete compendium of programming techniques that you can implement with these features. For example, there is one entire chapter devoted to custom attributes, with a few advanced examples of how they can help you in the design of your n-tier apps. In other words, instead of just listing what are your tools this book will explain how to leverage them using intermediate-to-advanced techniques, including nonobvious techniques based on generics, on-the-fly compilations, advantage use of delegates and custom events, and so forth.

Another important topic that Programming Visual Basic 2005: The Language book covers is Visual Studio and how to take advantage of its many editing and testing features. The book includes two long chapters (112 pages in total) which covers basic and advanced topics, including macro creation, unit testing (with Team System), debugging techniques, and more. I have never found a language book that focuses on productivity inside the IDE and I hope this new book fills this gap.

The book consists of 22 chapters, for more than 1000 pages. I'll publish its Table of Contents in another post very soon, hopefully tomorrow.

12/15/2005 1:56:08 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 Thursday, December 08, 2005

Last spring I co-authored this book, Practical Guidelines and Best Practices for Microsoft Visual Basic .NET and Visual C# Developers, arguably the longest title in Microsoft Press's history. The book is a reasoned list of guidelines that all .NET developers should follow, actually is by far the largest collection of its kind you can find anywhere. It covers language syntax, memory usage, Windows Forms and ASP.NET applications, security, and more.

Unlike most other similar collections, though, we clearly divide the "rules" in guidelines (naming guidelines, comment usage, etc.) and best practices. The difference is subtle but important: most guidelines are primarily a style matter, whereas best practices impact the scalability, the speed, or the robustness of your application. This means that our guidelines are arbitrary and in fact we often offer alternate rules and clearly explain the pros and cons of each style.

You can learn more about the principles we used in the book's Introduction and in John Robbins's Foreword. (Unlike most foreword writers, John actually read each and every page in the manuscript and gave us some great advice about improving it.) Or click the figure to jump to the book's home page, where you can read three sample chapters and download the book's source code.

Today I have uploaded a 30-page Word document that contains a summary of all the rules covered in the book, orderly grouped by topic and with a reference where in the book each rule is explained. You can edit this document as you see fit, delete or edit the guidelines you aren't interested in, and so forth. We routinely use this document in internal code reviews or when we consult at customers' places, so we hope it will be useful to you as well.

P.S. You must register to access this material. We swear we'll never send you anything that vaguely resemble spamming, just 100% technical contents!

12/8/2005 2:50:28 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 Tuesday, November 22, 2005
I work with Microsoft Press since 1998 and I wrote as many as 5 books for them (plus 3 more books I am working on right now). Every three months I get a check with my royalties from my US books and the translation rights for versions published elsewhere in the world, but without specifying which languages the books have been translated into.

For some reason I always forgot to ask for a list of the languages my books had been translated into, until a couple of months ago, when by acquisition editor made a search and returned this the following list. Every now and then, readers ask whether the book has been translated to their language, therefore I decided to post the information here.

Programming Microsoft Visual Basic 6 : English, Italian, Japanese, Korean, Spanish, Chinese (simplified, China), Chinese (traditional, Taiwan) + local English-language version in India.

Programming Microsoft Visual Basic .NET: English, Italian, French, Arabic, Japanese, Korean, Spanish, Chinese (simplified), Chinese (traditional) + local English-language versions in China and India.

Applied Microsoft .NET Framework Programming in Microsoft Visual Basic .NET (with Jeffrey Richter): English, Italian, Korean, Chinese (simplified), Chinese (traditional) + local English-language in China.

Programming Microsoft Visual Basic .NET Version 2003: English, Italian.

Practical Guidelines and Best Practices: English, Italiano, Russian + local English-language in China.

I can't help admitting that being translated into as many as ten languages is truly thrilling. :-)

11/22/2005 1:40:29 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 Friday, October 28, 2005

I was so excited to announce the new version of the dotnet2themax site that I forgot to introduce myself, as is customary in any weblog. On the other hand, if you have attended dotnet2themax.com in the past, odds are that you already know me, perhaps because you've read one of my books or one of my articles on programming magazines. But I will summarize my professional life here, if only to provide links to other places where you can find more interesting material.

I live and work in Bari, Italy, but I often travel to speak at conferences such as VSLive!, WinDev (US), DevWeek (UK), TechDays (Switzerland), and a few others.

I am one of the two Italian MSDN Regional Directors and in the last two years I have served as the chairman for Windows Professional Conference, the largest Italian conference for developers, and routinely speak at DevDays and other Microsoft events in Italy since 1998. I have been giving classes for Wintellect in the US until mid-2004, when I decided not to spend abroad 5 or 6 months of each year.

In 2002 I founded Code Architects, a software company that focuses on .NET and Microsoft technologies, together with Giuseppe Dimauro (the other MSDN Regional Director for Italy). Code Architects provides training and consulting services for many Italial government agencies and large companies, including Microsoft. Code Architects markets a line of programming tools that I authored (or co-authored), including CodeBox, Form Maximizer, and the award-winning VB Maximizer. The Code Architects Team include some of the most skilled .NET experts in Italy. If you can read Italian, you might find a lot of interesting stuff in our Team Blog.

I wrote about 80 articles for Visual Studio Magazine (formerly Visual Basic Programmer's Journal), with which I collaborate since 1996, and also wrote a couple of articles for MSDN Magazine and for developer's sites such as DevX. For example, you can go here to read nearly 300 tips and short articles I wrote for DevX, mostly on VB6.

I don't write only for US magazines, though. I wrote my first article back in 1983, then I wrote dozens of columns for Computer Programming, the leading Italian magazine for developers. In 1995 I founded Visual Basic and .NET Journal (formerly Visual Basic Journal), the only Italian magazine entirely devoted to .NET Framework programming.

 


English

Italian

While I still am the editor-in-chief of my own magazine, in recent years I decided to write fewer articles to focus on my books and my own vb2themax.com Web site, which I founded in 1999 and that a few years ago was expanded into dotnet2themax.com to match the new C# and VB.NET contents. This site is now sponsored by Code Architects, together with the Italian web sites dotnet2themax.it and ugisharepoint.it.

Microsoft Press published my first book in 1999. Since then Programming Microsoft Visual Basic 6 has sold around 150,000 copies all over the world, including translations to Italian, Japanese, Chinese, Korean, and Spanish, and continues to sell more than many VB.NET books. In 2002 I wrote Programming Microsoft Visual Basic .NET, which the next year was upgraded into Programming Microsoft Visual Basic .NET 2003, a 1400-page textbook that cover virtually everything you need to know about VB.NET and the .NET Framework. It has been one of the VB.NET bestseller and as of today it nearly alwways appears in Amazon's Top Ten list for Visual Basic and .NET books. I also co-authored Applied Microsoft .NET Framework Programming with Microsoft Visual Basic .NET (with Jeffrey Richter) and the newer Practical Coding Guidelines and Best Practices for Visual Basic .NET and C# Developers (with Giuseppe Dimauro), a collection of over 700 rules and tips for writing robust and efficient .NET applications.

While Visual Basic is still my pet language, I write a lot of C# code as well. I am especially interested in programming techniques, algorithms, optimization, .NET internals, client-side (Windows Forms) and ADO.NET programming. I love to write addins, macros, code generators, and other tools that can make programming a more pleasant (and faster) experience, and I'll use this blog to share my findings with you all.

What else? I love music - a bit of everything, but especially jazz and fusion - and in my previous life I was even tempted to become a professional musician, until I realized that programming can be as much fun. I played my alto sax with many local combos and orchestras, but I probably reached by peak - on the fun side, at least - with Don Box's Band on the Runtime. If you are among the few millions who never listened to the Band, you can grab a video here or here. You can find some lyrics here and here.

Books | Misc
10/28/2005 4:25:13 PM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
 
Get RSS/Atom Feed
RSS 2.0 | Atom 1.0
Search in the blog
Archive
<July 2009>
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678
Categories

Powered by: newtelligence dasBlog 1.8.5223.1