Free eBook: Foundations of Better Programming
- Posted: Jun 26, 2008 at 11:06 AM
- 42,535 Views
- 23 Comments
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation,
please create a new thread in our Forums,
or
Contact Us and let us know.
Follow the Discussion
Oops, something didn't work.
What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in. You need to be signed in to Channel 9 to use this feature.What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in and view them all on your notifications page.sign up for email notifications?
I'm only into the second chapter, and I just had to say - fantastic book!
Most of the books out there tend to be just API references, but to have this kind of stuff down on "paper" in a coherent manner is extremely useful.
Have you ever thought about writing a full length, in depth book?
I agree with you that many are just rehashes of the API with simple, almost unusable samples with each. One of the things I liked about Karl's book is that he teaches you not just how to build software but how to build better software.
As for me writing a book, I'm knee deep in co-authoring a Coding4Fun book actually
As for a more in-depth book, it depends on what you mean. A lot of the larger books (1,200 ASP.NET page books) only cover each topic in 15 pages, but they cover a LOT of topics, just not deeply. Then there are single books that go very deep, and those are good if you want to know what the heck is actually happening like Jeffrey Richter's CLR via C#. I'm probably best suited for an applied book with actual projects as documenting APIs to me isn't personaly interesting, but showing how and when to use those APIs in an application is. As for a Richter-type book, I'm not the right person and I don't think I could compete with him anyways
There are a couple of other books that I think the .NET community needs though -
Pragmatic Business Intelligence for Developers - SQL Server 2008 BI using real-world examples like US Census data, Technorati search data, YouTube video popularity, etc.
Simple, Beautiful WPF Designs for Developers - This was a personal pain for me having read multiple WPF books and flipped through several including Expression Blend books - almost none of them show you how to make something attractive. Go to a bookstore and flip through WPF/Blend books and you'll see terrible-looking UIs with big green and red blocks. This book would be a collection of WPF control skins, quick usability guidelines, and instructions for how to reuse and structure them in your applications.
Cheers,
-Dan
By December, it's due out by the first week of August (gasp!) Here's the book on Amazon, note that the title isn't final
True. Coding stuff that works is only part of the goal; coding it well is another matter entirely. It's the main reason why Steve McConnell's Code Complete (2nd edition) is downright the best programming book of all time. I use stuff I learned from that book every single day.
Cheers,
Karl
Keep up the good work!
Cheers,
-Dan
I am however a bit sceptical about whether O/R mappers, or NHibernate in particular is suited for most projects.
They can lead to much less development time, yes, but as far as I've understood from different blog and forum posts, they can cause all kinds of other headaches, when you try to do something a bit complex.
The last thing i would want to be forced into, is designing my system around an O/R.
I do feel that writing my DAL manually, is a time consuming process. It does however give me an extra sense of control, and a few abilities that wouldn't be possible using an O/R.
Karl mentions in his book that what you really need to do, is take a leap of faith, but with the O/Rs available today, it seems impossible to me that you can avoid designing your system around the shortcomings of the O/R.
I haven't tried building a system on an O/R mapper yet, since I just don't trust it. But if you have different experiences, please tell me that I have the wrong idea. I'm particularly interested in whether it holds up in an enterprise service environment.
I was just looking at some older code we wrote and thought it might alleviate [some of] your concern. Essentially:
public abstract class NHibernateDataStore : IDataStore
{
public User GetUserByCredentials(string userName, string password)
{
_session.CreateQuery(from User where UserName ....).UniqueResult<User>();
}
public abstract ProductResult SearchProducts(...);
}
public class MySqlDataStore : NHibernateDataStore
{
public ProductResult SearchProducts(...)
{
//hand coded sql, sproc, whatever
}
}
95% of the logic is within the NhibernateDataStore, but some queries needed special optimizations (after profiling) or were just too complex, so were hand-coded the SQL within the MySqlDataStore.
This seems like a win-win, you get the quicker development time, with no constraint on flexibility. NHibernate will only box you in if you let it - but it's pretty easy not to get yourself in that situation (and pretty easy to get out of it anyways).
Would that address part of your concern or is there something more to it? I certainly don't advocate NHibernate in every situation, but I do believe that people who aren't familiar with it will probably never end up using it even when it's the perfect fit.
I see what you're getting at. And I realize how that could be utilized.
Some of the functionality that I'm quite sure I would need at some point, and not really sure whether is supported by NHibernate, is something like this:
For the sake of argument, let's take a User object that needs to be persisted with NHibernate, this User has a property called Name which is of the type Name that is a combination of Firstname and Lastname. Here's some code for clarification:
public class Name
{
public string Firstname { get; set; }
public string Lastname { get; set; }
}
public class User
{
public Name Name { get; set; }
}
How would i go about mapping Name.Firstname and Name.Lastname into my Users table Firstname and Lastname column? Is it even possible?
And how about reading it back from the database? What if my Name type can only be initialized with a constructor that has both firstname and lastname as parameters?
As for the first question, NHibernate handles this via composition, and the Name example is actually the one they give in their documentation (http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html_single/#components-dependentobjects).
I think I've had trouble mapping on one or two occasions. Typically, the cause of that has been my own ignorance about NHibernate, or a design decision that ended up not being the best. If you use it enough, and depending on what you do, I do think you'll run into situations that no longer map nicely. I guess in those situations, you hand roll your own mapping, or move to an even more flexible O/R mapper (never used it, but i think iBATIS is what people who recommend in those situations).
Perhaps I should be a bit more optimistic, and read through the documentation to get a proper picture of what can be done.
One last question. I have multiple times tried to get used to writing unit tests, but usually sorta give up, because I feel lost when it comes to what should be tested, and how deep my tests should go.
Can you from the top of your head mention a book or other writing that you felt was useful when you were learning?
Thanks for the pointers so far.
I know that there's some backlash starting to grow about interaction testing, but I still think the best think to do is learn a good mocking framework (RhinoMocks) and start with some interaction testing. This will first and foremost immediatly highlight tight coupling in your code, which you then must fix using some type of IoC (StructureMap's Dependency Injection comes to mind) and with that done you start to see far more meaningful tests. The Ebook covers it all, although it's high level and the end to end code examples are a little few and far inbetween.
Regarding the test tool, is there anything wrong in using the unit test tool built into VS2008 instead of NUnit?
Regards
Johan Lindfors
Microsoft Sweden
Thanks for the feedback. Honestly, I never even thought about it (which I realize highlights the problem you'd like to see addressed). I'm not even sure I'd know what to talk about.
Would you say that people who do server-centric programming (be that websites or web services) generally worry less than people doing desktop development? I mean, assuming the server is hardened, I don't have to worry about someone modifying my libraries, invoking private members, or manipulating system memory. The security I do worry about tends to be application specific - roles, permissions and input validation. Even the security protocol is pretty high level - SSL or some type of asymmetric key exchange.
I guess what I'm saying is that even though I'm more than willing to wing my "expertise" on some topics, security isn't one of them.
If you have any resources for me, I'd be more than happy to learn.
Primarily, my concern is that there are such obvious inconsistencies -- such as a comment about pointers being unavailable in C#, soon followed by an example of using them in C# -- and glaring omissions.
In particular, while the text mentions .NET 3.5 in the present tense, I failed to see any discussion about LINQ as a pattern for data access. Indeed, the only discussion of .NET's data stack appears limited to .NET 2 -- the DataSet stack. I'm fine if you want to be a cheerleader for NHibernate (I have no desire to use it, personally), but even NH is building a LINQ layer. It comes off as either careless (you overlooked, somehow, the single biggest feature of .NET 3.5, and pretty much the only feature which could have stopped Orcas from shipping), or disingenuous (you intentionally failed to discuss it). I refuse to believe the latter possibility, but the former is pretty bad in itself.
My suggestion would be to have a couple hard-core technical reviewers, both ALT.NET and MS if that's your preference, who can guide you to make sure your discussion is sound and complete. You have the core of a good, informal guide (my manager is having our new grad hire lead a discussion of it) but I wouldn't call it ready in the context of what it's purporting to discuss.
(I admit, I'm not volunteering -- I've already done my technical review for a book. I'm making up for lost sleep now.. but seriously, good luck and I hope to see your project continue in good directions.)
Remove this comment
Remove this thread
close