Archive for April, 2009

Presentation Material on Design Patterns for INETA Live

I’d like to thank INETA for hosting the event and everybody who attended to it. As promised, here’s a link where you can download the material (slides and samples). See you next time!  🙂

Leave a comment

Virtual BBM April 23 2009: follow-up

We’ve had our second Virtual Brown Bag Meeting today. At some point, there were 15 attendees; I noticed some were at the first meeting, and some were new to it. Hopefully we’ll see this number increasing in the future.

Here are the things we’ve covered this week (I’m sorry, but I just don’t have time to put more details here. Check out the link to the recording at the bottom of this post to watch the meeting):

  • Entity Framework with POCO
  • VS tip
    • How to set keyboard shortcuts to increase/decrease the editor’s font site (look for the IncreaseTextEditorFontSize and DecreaseTextEditorFontSize macros).
  • May/June 2009 CODE Magazine (the “open source” issue): good articles on Windsor Castle, NHibernate, Mocks and Stubs…
  • Karl’s Seguin free book on “Foundations of Programming”
  • Uncle Bob’s blog post: Code Inevitable? Rumblings from ACCU
  • WPF: Dependency Properties, Attached Properties, Attached Behaviors, Model-View-ViewModel and DataTemplates
  • Refactoring code to use a fluent interface
  • Alternative to dynamic instantiation (DynamicMethod versus Activator.CreateInstance)

Here’s a link to the recording, in case you’ve missed it or want to go back and revisit some of the points.

Next week I will be out to a client and won’t be able to attend to the meeting. We’ll find somebody to start off the meeting and promote others to presenter as the meeting goes on.

Leave a comment

Material from Presentation at the Lubbock .NET User Group

I’m back from my quick trip to Lubbock, TX. I did a presentation on OOP over there. We’ve covered the core concepts, as well as the S, O, and I parts of SOLID. We’ve also squeezed some explanation on delegates, events, Action and Predicate, some brief functional programming with C#. Not bad, I don’t think. 🙂

The material from the presentation can be downloaded here.

Leave a comment

Virtual BBM April 16 2009: follow-up

Last week we’ve had our very first Virtual Brown Bag Meeting (click here to learn more). About 14 people showed up, which was beyond my expectations, since it was just the first meeting, and I had only announced it in a few places (my own blog, Twitter, and VAN’s Google Group). I’ve heard some great feedback about it, so we’ll keep this going.

Things We’ve Covered

Here are a few things we’ve covered in the first meeting:

Things I’ve Adopted or Will be Adopting Soon

I’ve been using SlickRun for several years now. It’s the very first tool I install right after installing the O.S. And I use it a LOT! I’ve always heard of people using both SlickRun and Launchy, since they complement each other. When I saw Executor at this 1st Virtual BBM, I just knew I had to take a serious look into it. Executor is much like a mix of SlickRun+Launchy; it has pretty much the best of both, and more. I’ve adopted it as my main launcher tool, and I’ll probably have a separate post just about it. I’m still going to keep SlickRun around because I use it’s Jot feature quite often.

Another thing I’ve had at the back of my mind for quite some time now is AutoHotKey. After seeing a little demo of it at this last BBM, I’m convinced I also have to take a serious look into this tool, too. My immediate use is going to be for creating BDD-style test names, but I can see how I’m going to be using it for many other things. However, I’ll need to spend some time learning its scripting language.

Things We’ve Learned in General About How to Handle the Meeting

We’ve recorded the session, but I’ve made the mistake to not record it to the LiveMeeting servers, so I only have it on my computer. I’ve uploaded it so you can download it here, though.

One thing we’ve established at the meeting was that whoever has anything to share must change the “Feedback” flag on LiveMeeting to “yellow”:


That helps the facilitator (that is, whoever’s helping the group stay on track as the main presenter) to promote the person to a presenter. Once you’ve been promoted to a presenter, go to the LiveMeeting toolbar at the top of your screen, click Content, Share, and then either pick Share a Program or Share Your Desktop, depending on what it is exactly that you want to share:


Also, we’re using LiveMeeting’s voice-over-IP features for the audio part, so make sure you have a microphone and speakers plugged in (for better quality, trying using a headset).

What’s Next?

That’s it for now. Do not forget our next Virtual BBM is tomorrow (Thursday), at 12pm Central Time. Bring in your tips and let’s share!

If you have any suggestions or comments, please don’t hesitate in letting me know, so we can improve the experience for everybody.

Leave a comment

Learn and Share at the Virtual Brown Bag Meetings

When I do my presentation on “productivity”, one of the things that I always mention is “brown bag meetings”. The concept has been introduced to me by good buddy Lynn Evans, and we’ve been doing it at the company (less often than I’d like) for some time now. I’ve also got some of our clients into doing it, and they always give me feedback saying they’re glad I got them into it, and they’ve been holding weekly meetings every since.

The idea is simple: once a week, people bring their “brown bag lunch” to the conference room, and we share tips and tricks. Unfortunately, there are developers who are either:

  • The only developer in the company, or
  • Working for a company that wouldn’t support such effort, or
  • Working as an independent developer

So who’d they have “brown bag meetings” with?

In order to cater for that, we’re starting a “virtual” brown bag meeting. The meetings are going to be hosted by the Virtual ALT.NET website through LiveMeeting (one of the most important aspects of ALT.NET is “continuous improvement”, and that’s what the brown bag meeting is all about!).

We’ll start doing it every Thursday, from noon to 1pm (Central Time). Depending on how things go, maybe different groups can held the meeting at different times so to account for different time zones.

In order for this to work, it’s vital that more than one person bring something to share. Of course, if we end up having a large number of people, it may not be possible for everybody to share, but we’ll figure something out if that turns out to be the case.

So all you have to do is to log on to the meeting by clicking here, and then watch people giving tips away while you eat your lunch, and between one bite or another, you contribute with some tip yourself! 🙂

Here are some ideas of things you can bring in as something to share with others:

  • A shortcut in Visual Studio, Windows, whatever, that you’ve learned or have been using for a while;
  • A tool (free or commercial) that you can’t live without it;
  • A tool that you may have run across, find it to be interesting, but are not sure about it yet. Maybe somebody else already uses the tool and can jump in;
  • An article, book, or blog posts you’ve read and want to talk about. It may be something you’ve read and couldn’t quite understand; maybe somebody else can shed a light on it for you;
  • Some command, language feature, workaround, design pattern, etc., anything you’ve learned or run across and could share with the others;
  • Something that you’ve found a way to implement but still think that there’s got to be a better way to do it; maybe somebody else can tell you what the other way is;

So that should allow us to get started. Join us, share, learn, get to know other people. It’s a win-win, isn’t it?  🙂

When: every Thursday, from noon to 1pm (Central Time)
Where: that’d be wherever you are. Just connect to

See you online!

Leave a comment

Material from my presentation at the Bartlesville .NET UG yesterday

I’ve posted the material here. Thanks everybody who showed up! (quick post… got busy here).  🙂

Leave a comment

Follow up to my “Intro to LINQ” session at the MS TechDays

As promised during my session, I’m going to be addressing every unanswered question from my session in this post (we just didn’t have much time to take many questions…). So here we go!

“…don’t forget to mention how to update/delete/add to the database using LINQ”

Those operations are taken care of by the “DataContext” object. That object keeps track of changes made to the result set you get back from the query. So you make changes to the objects, and whenever you’re done, make a call to SubmitChanges() on the datacontext object.

“Is type inference related somehow to dynamic language features, javascript, and stuff?” and “isn’t c# losing its strongly typed features with LINQ?”

Nope, not at all. Dynamic language features aren’t checked during compiled time. The type inference feature in C# does check typing information during compile time. When we use type inference we must assign a value to the variable in the line where we declare it, because that’s the only way the compiler is able to infer the type based on the value being assigned to the variable. Also, an anonymous type is a strongly typed object, even though we don’t define those classes ourselves; the compiler will generate IL code for those types based on how we’ve initialized the type (what property names and type of values we’ve assigned to them).

“Can you have a return result (vs. void) in the foreach delegate/lambda?”

Not in the ForEach method, no. That method takes in an Action<T> delegate, which returns void. That method is specifically designed to go through every item in the list and perform some sort of action using the item. There are methods that take either a Function or Predicate delegate, which do have a return type. If you look up those delegates you’ll find examples of using it.

“Can the .dbml file be used to build up the class of the underlying schema; or is there a better approach; or is it off base to want to know some much about the actual underlying database structure (break separation of concerns). What should one do to get a deep sense of the database schema?”

I’m not entirely sure I understand the questions, but let me try to clarify that: the dbml file is a file containing classes that model the underlying database. For example, for a given “Northwind” database, you’ll have a “NorthwindDataContext” class, which in turn will have Customers and Products properties. Those properties are a kind of collection of Customer and Product types, which are classes that model those tables in the database, and therefore, have properties that map to columns in those tables.

You should probably do some research on Object-Relational Mappers (ORM), and things like NHibernate, in order to get a good understanding of separation of concerns regarding the impedance mismatch between objects and databases.

“Why is “foreach” always underlined in blue when you type it?

I’m guessing you’re asking the about the connector lines between the braces. That’s a CodeRush feature.

“Is LINQ working with WMI queries?”

I haven’t messed with that myself, but I’ve found this for you: LINQ to WMI. I hope this helps. 

“You mentioned about the same performance using LINQ vs. traditional foreach. Are there circumstances where performance does become an issue?” and a related question “is that right that you said there is virtually no performance difference between using LINQ, and doing it manually with for loops?”

Correct. LINQ ultimately performs a foreach, so whether you do the foreach yourself, or let LINQ do it, performance is about the same. However, check the answer to the next question. There’s the Hooked on LINQ website.

“Is there a performance gain in using LINQ"?”

Not currently. However, there will be when the next version of Visual Studio comes out. We’ll get what’s called “parallel extensions”. With that will be able to just add a call to .AsParallel() to our query expression, which will cause the query to have items processed in parallel in multi-core machines (which is the case of pretty much every new computer).

“Do you have any good reference for more LINQ?”

I like the chapters in this book covering LINQ, because it explains things under the hood: C# in Depth. I’ve heard great comments about LINQ in Action, but haven’t had a chance to check it out myself.

There’s the Hooked on LINQ website, and also a few blog posts of mine here, here, here, and here.

“If the query is only invoked when it is referenced first time, only every time it is reference; hence is it important to cache it if it is to be referenced multiple times?

When the query expression is defined, and query does not get executed. Every time there’s a foreach against the query expression, it does get executed. If you need to run multiple foreach’s on the query, but don’t want the query to be executed every time, just call .ToList() on the query expression, which is going to execute the query once, put its results into a List object, and then you can iterate through that list as many times as needed.

“Can LINQ query a database other than SQL Server?”

LINQ to SQL is specific to SQL Server. LINQ to Entities, on the other hand, uses the Entity Framework, which can be targeted to databases other than SQL Server.

“Why is LINQ written in reverse order?”

I assume you’re referring to the fact that in traditional SQL (such as T-SQL), “select” comes before “from”, whereas in LINQ, “from” comes first, and “select” comes last. That’s also something that bothered me on the beginning: I had been working with T-SQL and the built-in SQL that Visual FoxPro had had for so many years, and then I was faced with this weird thing that had a “select” coming at the end. Once I saw the reasoning behind that decision, I started seeing old SQL as the “reversed” one.  🙂

I’ll explain. First, think of Intellisense support. We type “select “, and then what? How would any tool know what list of columns to display so I could pick from it? The list could show all tables with their related columns, but what if we are also going to have JOINs in that query? Until we’ve actually provided the FROM and the JOIN parts of our query, it’s impossible for Intellisense to know what list to show for the “SELECT” part.

Second, coming to think about it, SELECT coming first doesn’t even make sense for somebody reading the code. If we think about what we want the results of our query to look like, the following thought seems to make sense: “first I need to know from which main source I’ll be retrieving the data, then I need to know whether I need to join that source with others, then I need to know how I want that data filtered, then I need to know how I need the data grouped and/or ordered. And finally, out of all of that, I need to finally decide the shape of the results, such as which columns I want, or even whether the product of my query is going to be a more complex, hierarchical object”.

In order words, the “select” can only be satisfied at the end of the expression, once all the other things have been established.

I have an example from the real world that always comes to my mind when I think about the whole “from/select” in LINQ. In Brazil, the address format looks like this:

Rua Marcos Moura, 243
Some City, State – 12345

Notice that the first thing we see is the name of the street, or avenue, or whatever, and only after that we get to see the number. I think that makes a lot more sense than the address format in the U.S. Why? Let’s say somebody is about to die, and she asks you to deliver a very important message to somebody. She tells you the message, and then starts saying the address: “they live at 987…”, and then bang! she dies. Now what the heck do you do with just that number? We can knock at the door of every place whose number is 987.

On the other hand, if the person said “They live at Whatever Av…”, and then dies, at least you could narrow the number of doors you’d have to knock at in order to deliver the message.  🙂

“superb, superb – bravo – sat through 2 hours of a talk this past weekend on the same concepts. Claudio’s explanation is far superior”

That’s flattering. Thank you. It’s always great to know I’ve been able to clarify something to somebody.  🙂

Leave a comment