Foundations of Programming Ebook

I’m excited to finally release the official, and completely free, Foundations of Programming EBook. This essentially contains all 9 Foundation parts including a conclusion and some typical book fluff (table of content, acknowledgement and so on). A number of spelling errors were corrected, along with some small technical changes and clarifications – largely based on feedback, so thanks for everyone who provided it! Otherwise it’s exactly the same as what’s been posted here over the past several months.

Download it from http://codebetter.com/files/folders/codebetter_downloads/entry179694.aspx

Download the CodeBetter.Canvas Learning Application to see the foundations applied in practice: http://codebetter.com/blogs/karlseguin/archive/2009/09/01/canvas-gets-a-spark.aspx

 Foundations Of Programming 

If the above link fails, you can also get it from http://www.openmymind.net/FoundationsOfProgramming.pdf

You can also download the raw .docx file from http://openmymind.net/FoundationsOfProgramming.docx

This entry was posted in Foundations. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

57 Responses to Foundations of Programming Ebook

  1. karl says:

    Pavel:
    I’m not convinced that you can’t come up with meaningful messages in a global error handler.

    Even if you can’t, the benefits of centralized errors outweigh those of providing context-sensitive messages. How useful are context-sensitive messages to users (I’m strictly talking about exceptions here, not non-exceptional messages?) Chances are he/she will try again regardless of what you display.

    Anyways, if you’re the one throwing the exception, you can add an Type property to your custom exception that exposes an Enum which you can use to display more meaningful messages.

  2. Pavel says:

    Karl, you wrote:

    “I’ve often seen developers catch exceptions where they occur only to log and rethrow (more on rethrowing in a bit). This causes a lot of unnecessary and repetitive code – better to let exceptions bubble up through your code and log all exceptions at the outer edge of your system.”

    If you catch all exceptions in one place (like using UnhandledException or ThreadException handlers), the problem is with displaying a friendly message to a user. exception.Message may contain not a friendly one. But if you catch exceptions earlier, you know what the current code block is doing and you can show a friendly message, like “Error occurred during loading Excel application” or “Error occurred during saving customer information to the database”.

    What do you think?

  3. Pavel says:

    After several months since I first hear about mocks, I finally understood why you really need to mock your DAL – to make DAL functions return what you need in 1 or a few lines of code, instead of writing many lines of code or even pages of code – to fill your database with data necessary for test to make DAL method return what we need.
    It is your book helped me to suddenly understand it.

    Thank you.

  4. karl says:

    @Pavel:
    I do like to cover each topic more in-depth. I’ve blogged about each topic quite a bit already, for example, you can probably find 10 posts on unit testing. There’s also a lot of other good information out there.

    I don’t know much about DB testing. I pretty much write automated integration tests that hit the DB. That’s it.

    The DB vs ORM debate is old. I’ve found that when it comes to data access, ORM vs Sproc is the least of my performance worries. The other day I converted an sproc that took minutes to run, to an ORM call that took seconds – it had nothing to do with the access strategy, everything to do with writing a smart query. There are situations where direct db calls (via sprocs) will be necessary, but in your average system they’ll likely account for less than 5%. You can use an ORM for the other 95% and save yourself a lot of coding.

  5. Pavel says:

    I am reading chapter 6 – ORM, the section about quick overview of Inline SQL vs Stored Procedures. As for recompiling and abstraction – stored procedures DO able to help here. For example in 2-tier systems (without application server), if you use inline SQL, changes in database schema or query logic can lead to changing all the clients. But if you use stored procedures in such a system – you will more rarely change all your clients when database schema changes. Imho it would be nice if you mention it in the book.

  6. Pavel says:

    Hello Karl,
    I’ve started to read your book a few days ago, for now one half is behind and it seems a really great book! Just 2 moments:
    1) Do you consider go a littler bit deeper on every topic (chapter)? It can be a step-by-step process. I think you are talented on how to give information and what to give – you know what it is better to write and explain, you write very good examples, you also show subtle but popular problems and so on.
    2) Do you consider to write more on database testing? I think this is a very important and interesting task and for me it’s a pain in the ass :) – my tests for database look very ugly, I don’t know why :)

    Great work, keep it on!

  7. karl says:

    @Tower Defense:
    I’ve been meaning to change the license to something less strict. As for translations, I welcome them, but it seems like a hell of a lot of work.

  8. I think it is going to be a good shift in the way they code right now. But their ability to read in English is not that great. Do you know of any translation or are willing to accept any translation to Spanish? I’d offer myself and will thoroughly read the license.

  9. Javier says:

    Great Book Karl.

  10. gr8 book thanks for the book.. like it

  11. Miyagi Coder says:

    You are an MVP in my book…

  12. R says:

    You really should put a PayPal button somewhere, you deserve a beer for such nice initiative..

  13. Desirea says:

    This is just what this trainer needed for student resources.

  14. I’ve been working with Anthony Potts and finally got the application running on a machine with ASP.NET MVC Beta installed. Basically, the solution was to uninstall the Beta System.Web.MVC assembly from the GAC. Dylan Beatie discusses this issue here: http://dylanbeattie.blogspot.com/2008/11/working-on-aspnet-mvc-beta-and-preview.html.

    Anyway, thanks for a great application to learn from.

    Michael

  15. Karl,
    Great book. A couple of people from our local dot net user group (fsdnug.org if you are interested) have read it and so now we are working on learning each of the concepts which you highlight .

    Now, obviously the example program comes with no guarantee of working at all times, but me and another gentleman from our little group have the Beta version of the MVC framework installed and the sample program compiles but then doesn’t like the reference to System.Web.MVC. Where I am most confused is that you have included the dlls from (what looks like) Preview 5, and I didn’t change those references, but it still doesn’t work.

    If you don’t want to support such a thing I understand, if you could recommend a fully fledged sample application that you have seen that you partivularly like that was written targetting the MVC Beta Framework?

    Thanks for all your work on the topic and the work that you put into your blog. I have found it very educational and inspiring.

    Anthony Potts

  16. Bob says:

    just fyi – your book has a typo on page 20: “If you are, than you’re absolutely right (mostly right anyways…for now let’s assume that it’s always a simple process).”

    “than” should be “then”

  17. challenging..you got me!

  18. Vijay Patel says:

    Excellent reading material! I’ve recommended this eBook to my entire development team as well as consultants that we work with.

    It’s unfortunate that developers don’t always have time to learn/practice/experience new ideas and better ways of working, but this eBook is an excellent primer.

    However, let’s not forget that “Domain Driven Design” also requires experience and practice, and getting constant feedback from the business is critical to getting the design right.

    If you’re interested in rapid domain modelling, we offer a tool that creates interactive prototypes directly from domain classes. You can download a trial from our website.

    Keep up the good work!

    Cheers,
    Vijay Patel

  19. karl says:

    Translations are welcomed. Roman, I’ll get in touch and we can speak further.

  20. Román (roman dot fq at gmail dot com) says:

    Karl

    I have a bunch of friends that will love reading something about this, I think it is going to be a good shift in the way they code right now. But their ability to read in English is not that great. Do you know of any translation or are willing to accept any translation to Spanish? I’d offer myself and will thoroughly read the license. Left my email in the Name, please let me know….

  21. Louise says:

    Congratulations Karl !!

  22. MarkFreed says:

    Fantastic book!

    Here are a few minor corrections to consider adding to your list:

    Page 31
    Change the link to the StructureMap website from “http://structuremap.sourceforge.net/)” to “http://structuremap.sourceforge.net/”

    Page 70
    Code example:
    Missing closing brace ‘}’ in the try block.

    Page 71
    Code example:
    In UpgradeException method change:
    _upgradeId = i.GetInt32(“upgradeId”);
    to:
    _upgradeId = info.GetInt32(“upgradeId”);

    In GetObjectData method change:
    info.AddValue(“upgradeId”, _upgradeId);
    to:
    i.AddValue(“upgradeId”, _upgradeId);

    Also consider calling base.GetObjectData(i, c) and adding a closing brace ‘}’ to this method.

    Thanks for such an excellent book.

  23. Yann Trevin says:

    Typo at page 24: again “Updagrades” instead of “Upgrades”.
    Type at page 62: 2 closing parenthesis in 2nd paragraph.
    Format inconsistency at page 66: the final ‘y’ character of “try/finally” has not the expected format.

  24. leo lear says:

    I am so glad I found your pdf. It’s gonna change the way I code forever. Thank you.

  25. Scott Isaacs says:

    Karl -

    Really looking forward to reading the book. Was hoping to read it on my WM6 phone, but the format doesn’t seem to be working for that. Oh well, laptop and/or paper will have to do. :)

    Thanks,

    SI

  26. Yann Trevin says:

    Typo at page 22. In the sample query, you wrote “Updagrades” as table name instead of “Upgrades”.

    Your book is very interesting. I like in particular the examples you have chosen. They are simple, concise, and yet complete and very explicit. Congratulations.

  27. Jason Clark says:

    Simply put, reading this book has helped me understand why I wasn’t happy developing the “MSDN” way, and helped me see what all the fuss was about. Thanks so much for your time and effort in helping effect change in the community.

  28. karl says:

    Yann:
    Thanks. I’m making all corrections as they come in. I haven’t pushed out a new version yet (there hasn’t been anything really major), but I will eventually.

  29. Yann Trevin says:

    Karl, there is a typo at page 14. You wrote: “The first thing we’ll do is create three classes:”, then you list in the example FOUR classes (Car, Model, Package, and Upgrade).

  30. Sean Kearon says:

    Karl – great book, thanks!

  31. DaRage says:

    I’ve been following the series from the begging and I should say that I learned a lot and it pointed me to great ideas.

    Many thanks

  32. Great resource Karl, well worth the read both for beginners and advanced .NET developers in my opinion.

    I’m a bit surprised ‘though that a book on “Foundations of programming” doesn’t include a chapter or at least some notes on Security.

  33. Thomas says:

    Excellent work, Karl. Thanks.

  34. Dragos says:

    Thank you very much for the book!

  35. steve j says:

    Thanks for sharing your hard work.

    I’ve just begun looking at Workflow Foundation. It appears to be an architecture that’s bigger than its name. For example, in the Shukla/Schmidt book, the authors make it a point to favor “WF” over “workflow” (which they insist is “colloquial”, whatever they mean by that).

    I’m early into it but have the sense that everything you’re advocating here –and more– might be subsumed by coding to the WF model/architecture. Among other things, DI is just built in (if not called out as such).

    Microsoft has undersold this piece IMO. Perhaps they’re building on it themselves (like they once did with COM, e.g. VBA, IE, etc.). Sharepoint and Biztalk are just the obvious clients.

    It’s worth a look, anyway.

  36. Janko says:

    What a great idea! Thanks!

  37. karl says:

    @Skwr: unlikely

    @Daniel: manual labor

  38. Daniel says:

    Great contribution! What did you use for your code listings? They look slick.

  39. gi says:

    excellent work ..and it’s also free

  40. giovanni says:

    Excellent work …. and it’s free also

  41. Skwr says:

    Any chance of an A4 version of this?

  42. Andres says:

    Thank you. I really appreciate this.

  43. david says:

    Many thanks for this. The best introduction I’ve come across to the .NET world beyond WebForms + DataSets

  44. Ferry de Boer says:

    Thanks for the great contribution to the community. I’ve read some of your elaborated posts and I definately loved them. I’m going to read this asap.

  45. Iam a big fun of your series. And finally EBook . Its a great resource Thanks Karl

  46. Brendan Tompkins says:

    Oh my God! What an amazing contribution to our field! And under such a great license. This is truly an accomplishment!

  47. karl says:

    Thanks for the love all.

    @mdm
    Damn you! the one part I didn’t have her read over, of course there’d be a typo. I doubt it’s the only one though…I can always hide behind the free part ;) I’ll queue a bunch up and transparently post a new version at some point :)

  48. Dan Martin says:

    Thanks for the book!

  49. Very nice work! Congratulations!

    Eduardo Costa.

  50. at3r says:

    love your articles, more more I want more. No really is there more?

  51. mdm says:

    Hi, there’s a typo in the Acknowledgement “either working, learning, writing our playing” should read “either working, learning, writing or playing”. Am I right?
    Just my 2c.

  52. Stephen Smith says:

    Just an expression of thanks for all the educational and inspirational blogs from all the bloggers I find at codebetter.com. (Jeremy Miller should be blogging at a sustainable pace! Not prolifically.)

    I would attribute half of my effectiveness as a developer to the power of the practices I use so I am always looking to discover more powerful practices and to evangelise them with in my own work environments. I love what I do, I love doing lots of it and each time I do it I love doing it better, smarter based on what I have learnt from doing, from working with others and from my own continuing professional development activities such as the codebetter site and the Alt.NET and Agile/XP community. The ALTernative to writing testable code is writing DEtestable code.

    I would attribute the other half of my effectiveness to my ability to contribute to a team. It is a team that delivers business value, not individuals. The question of what makes a team so much more than the sum of its parts is just as applicable to a development team as it is to a sporting team.

    Having said all that for the lack of Agile/XP/Alt,NET opportunities in the .NET space I find myself a square peg in a round hole on an “MSDN Microsoft” project that has never yet delivered anything after 4 1/2 years. Being a greenfields project we can always upgrade to the latest Microsoft Visual tooling. Several weeks ago the CEO said in summary “we are using the latest Microsoft technologies so it must be good.” I am sure that is what Microsoft Marketing would love to hear. It could be described that the project has degenerated into a research project into the latest Microsoft technologies.

  53. Thanks for this Karl. It is a great read. You’ve done a terrific job.

  54. Grant Palin says:

    Excellent – yay for free ebooks!

  55. Shadi Marei says:

    Excellent idea Karl.

  56. Very cool! Thanks!

  57. Rob says:

    You rock!