Sunday, April 21, 2013

Finding the Root Cause of WCF Exceptions

When setting up a WCF service, calls can fail for many reasons. The frustrating part is that we typically get a generic error:

The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.8380000'.

In order to find out exactly what was wrong, simply configure tracing, by placing this in the config file of the WCF service:


  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel"
              switchValue="Information, ActivityTracing"
              propagateActivity="true">
        <listeners>
          <add name="traceListener"
              type="System.Diagnostics.XmlWriterTraceListener"
              initializeData"c:\temp\Traces.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>

Note: The above configuration is from http://msdn.microsoft.com/en-us/library/ms733025.aspx.

After trying the WCF call again, open Traces.svclog and find the activity in red:


After clicking on the activity, click on the description/error in the right window pane:


The bottom pane will show you exactly what's wrong:



Books I've Read - Software

There are 89 books listed below. Out of those 89, I have chosen the five that have had the most influence on my career, and that I consider the best of them all. These are in no particular order.

My Top 5

1. Agile Principles, Patterns, and Practices in C# [Martin]
2. Head First Design Patterns [Freeman, et al.]
3. Peopleware: Productive Projects and Teams [DeMarco, Lister]
4. Joel on Software [Spolsky]
5. The Mythical Man-Month [Brooks]


C#/.NET
  1. Programming C# 5.0 [Griffiths]
  2. C# in Depth [Skeet]
  3. Programming .NET Components [Lowy]
  4. Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries [Cwalina, Abrams]
  5. Effective C#: 50 Specific Ways to Improve Your C# [Wagner]
  6. C# Cookbook, 2nd Edition [Hilyard, Teilhet]
  7. Introducing .NET 4.0: With Visual Studio 2010 [Mackey]
  8. CLR via C#, Third Edition [Richter]
  9. Expert C# 2008 Business Objects [Lhotka]
  10. Programming .NET 3.5 [Liberty, Horovitz]
  11. Essential Windows Communication Foundation (WCF): For .NET Framework 3.5 [Resnick, et al.]
  12. MSDN (magazine) - many


Design/Practices
  1. The Mythical Man-Month [Brooks]
  2. Agile Principles, Patterns, and Practices in C# [Martin]
  3. Design Patterns [Gamma, et al.]
  4. Head First Design Patterns [Freeman, et al.]
  5. Clean Code: A Handbook of Agile Software Craftsmanship [Martin]
  6. The Pragmatic Programmer: From Journeyman to Master [Hunt]
  7. Refactoring: Improving the Design of Existing Code [Fowler, et al.]
  8. Code Complete: A Practical Handbook of Software Construction [McConnell]
  9. Applying UML and Patterns [Larman]
  10. Software Engineering: A Practitioner's Approach [Pressman]
  11. UML Distilled [Fowler]
  12. Pragmatic Unit Testing in C# with NUnit [Hunt, Thomas]
  13. Practices of an Agile Developer: Working in the Real World [Subramaniam]
  14. Head First Object-Oriented Analysis and Design [McLaughlin, et al.]
  15. Data Modeling Essentials, Third Edition [Simsion, Witt]
  16. The Object-Oriented Thought Process [Weisfeld]


Architecture

  1. Patterns of Enterprise Application Architecture [Fowler]
  2. Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions [Hohpe, Woolf]
  3. Service Design Patterns: Fundamental Design Solutions for SOAP/WSDL and RESTful Web Services [Daigneau]
  4. Microsoft® Application Architecture Guide
  5. Microsoft® .NET: Architecting Applications for the Enterprise [Esposito]
  6. The Process of Software Architecting [Eeles, Cripps]
  7. REST in Practice: Hypermedia and Systems Architecture [Webber, et al.]


Web

  1. JavaScript and jQuery [McFarland]
  2. Programming ASP.NET MVC 4 [Chadwick, et al.]
  3. HTML5 and CSS3 [Castro]
  4. HTML5: The Missing Manual [MacDonald]
  5. Silverlight 4 in Action [Brown]
  6. Head First Ajax [Riordan]
  7. Programming ASP.NET [Liberty, Hurwitz]

Leadership/Project Management
  1. Agile Project Management with Scrum [Schwaber]
  2. Succeeding with Agile: Software Development Using Scrum [Cohn]
  3. The Five Dysfunctions of a Team: A Leadership Fable [Lencioni]
  4. Leadership: Enhancing the Lessons of Experience [Ginnett, et al.]
  5. The Leadership Challenge [Kouzes, Posner]
  6. A Guide to the Project Management Body of Knowledge, Third Edition [PMI]
  7. Project Management: A Systems Approach to Planning, Scheduling, and Controlling [Kerzner]
  8. The Power of IT: Survival Guide for the CIO [De Sutter]
  9. Ship it! A Practical Guide to Successful Software Projects [Richardson, Gwaltney]
  10. Creating a Software Engineering Culture [Wiegers]
  11. Peopleware: Productive Projects and Teams [DeMarco, Lister]
  12. The Project Manager's MBA: How to Translate Project Decisions into Business Success [Cohen, Graham]
  13. Adventures of an IT Leader [Austin, et al.]
  14. What Got You Here Won't Get You There: How Successful People Become Even More Successful [Goldsmith, Reiter]
  15. Manage It!: Your Guide to Modern, Pragmatic Project Management [Rothman]
  16. CIO Survival Guide: The Roles and Responsibilities of the Chief Information Officer [Schubert]
  17. The First 90 Days: Critical Success Strategies for New Leaders at All Levels [Watkins]
  18. Harvard Business Review (magazine) - many
  19. Introduction to Information Systems Project Management [Olson]
  20. Earned Value Project Management [Fleming]
  21. Applied Software Project Management [Stellman, Greene]
  22. Introduction to Project Management [Schwalbe]

Other/Advice/Culture
  1. Big Ball of Mud [Foote, Yoder]
  2. Building Windows 8 Apps with JavaScript [Sells, Satrom]
  3. Building Windows 8 Apps with C# and XAML [Likness]
  4. C Programming Language [Kernighan, Ritchie]
  5. WPF 4 Unleashed [Nathan]
  6. Programming Entity Framework: Code First [Lerman, Miller]
  7. Joel on Software [Spolsky]
  8. More Joel on Software [Spolsky]
  9. The Best Software Writing I [Spolsky]
  10. Programming Language Pragmatics, Third Edition [Scott]
  11. Data Communications and Computer Networks: A Business User's Approach [White]
  12. Manufacturing Execution Systems (MES): Optimal Design, Planning, and Deployment [Meyer, et al.]
  13. Workflow Modeling [Sharp]
  14. The Data Warehouse Lifecycle Toolkit [Kimball]
  15. Computer Networks, Third Edition: A Systems Approach [Peterson, Davie]
  16. Statistics for Business and Economics, 6th Edition [Anderson, et al.]
  17. Information Nation: Seven Keys to Information Management Compliance [Kahn, Blair]
  18. Who: The A Method for Hiring [Smart, Street]
  19. The Guru's Guide to Transact-SQL [Henderson, Celko]
  20. Computing Concepts with Java 2 Essentials [Horstmann]

Linux

Saturday, April 13, 2013

An Implementation of the Dispose() Pattern - For Reference

Awesome SO answer on proper use of IDisposable here.

The Bad Code Problem - The Smooth-talking Garbage Guy


I think there is a major, fundamental problem in the software development industry. And it's a difficult, tricky problem to solve. That problem is managers hiring developers that write truly poor code, not knowing it, and letting them run amok, and even letting them guide other developers and teams.

The root of the issue is management not knowing the true quality of the programmers they hire. It's all too easy for a smooth-talking developer (that actually writes garbage code, hence smooth-talking garbage guy) to make himself look like the right answer in front of a manager that can't refute anything he says. It's especially more problematic when not examining a developer's code before a manager hires the developer. And even worse if a manager looks at the code and doesn't truly know if it's good code.

The problem is further compounded when misled manager guy (MMG) touts his developer to others within the organization. And to make matters even worse, the root of all evil in a company, the BOYM (bend over yes men) who are afraid to do or say anything about it.

Developers (and somewhat decent developers) can sometimes be awed by this STGG. I think I know why now. His systems are complex balls of mud, yet he can explain things in a way that can seem to make sense. Only through seeing through the bullshit, and going back to the basics of simple, clean, and elegant code, can you truly appreciate STGG for what he has built: an ugly system because he doesn't know how to do otherwise.

Good systems, regardless of architecture, have code that is simple, clean, and elegant. Period. A system with an awesome architecture, backed by terrible code, is a terrible system.

Bringing in a new developer, or architect, that knows how to do things better than the way things are currently being done, won't change things. At least not anytime soon. The system is the system, and the folks left to deal with it are constrained by it. In time, these new resources will look bad because they'll be associated with the current crop of problems. This is exasperating, especially if STGG has moved on/up to other departments.

How is this fixed? In enlightened companies this isn't even a problem. Software development is valued as a first-class citizen, and top-notch developers tend to run things. In unenlightened companies, it's almost impossible. The only thing I can think of is to hire an outside firm to do an objective analysis of the system. This can be expensive (although much, much less expensive than the hidden cost of not doing it at all), and since the system "works," nothing is usually done.

How do we stop this from happening?