The Education of a Programmer (Me)

Just another WordPress.com site

Tag: C#

Out-thinking, but not outwitting myself

Like any good programmer, I keep trying to re-factor some of my code to make it more efficient, better, etc. Now that I’ve become more comfortable with Linq to EF and Oracle together, I realized it would be time to re-write our Hot Calls program. (Not what you think folks). Even though Syncfusion has come out with one of their Succinctly series books on NHibernate, I don’t know that I’m going to make the switch just yet. I would like to try it as a test some day so I can get familiar with it, in case I ever have need of it.

However, I started with the Poller which scans a database of incoming calls and takes the newest calls to a series of temp tables for the logic program to handle. This program doesn’t really lend itself well to either EF or Linq for that matter; so I’ve written the SQL by hand but I still wanted to tweak it. The headache was the first place which lends itself best to the tweaking was the exception handling. Finally, I’ve wrapped my head around overloading my functions enough that I’ve built workable overloaded mailing and logging functions which I can reuse as I’ve wanted to do for some time. Doing this appears to remove nearly 40% of my code base. That is going to be a huge difference across all of these functions. I know I have more re-factoring to do along the way and soon it will be even tighter. (Don’t worry, the commenting is still as verbose as always.)

Yay! Hail the little victories here and there when you can get them.

Advertisements

Book Review – Microsoft Visual C# 2013 Step by Step

I’ve recently been reading Microsoft Visual C# 2013 Step by Step by John Sharp. As usual, the disclaimer is that I received a copy of the book for free in return for the review. I’ve not linked to the book because I blog as part of O’Reilly’s reader review program and recently Microsoft Press books have been removed from their site. Out of courtesy to them, I am not going to link to Microsoft’s site for the book.

The book is aimed, as you read it, for programmers who are wanting to get a foundation in the basics of C#. As such, the book is a good reference work. It takes apart each of the different parts of the language and shows you how they are used in basic format. The first part of the book introduces you to the language, it’s absolute basics, and Visual Studio. The second part, getting the object model under control. Part 3 extends it, and finally, part four shows you how to build something simple for Windows 8.1; as that is Microsoft’s application focus currently.

Overall, Mr. Sharp does an excellent job describing the basics. If you’re a more experienced programmer wanting to see what’s new in the language, this isn’t really your book. But that’s not a negative. It’s not designed for that level of programmer. The examples are clear and concise. However, my one concern is that, as with most beginning books, what you’re learning along the way doesn’t build on itself until the final portion of the book when it all builds at once. However, if you’re going to be new to C# and you’re not coming from Java, this is certainly a good book to start with.

The more I know…..

Well, the next part of the line is “The less I understand.” However, that really isn’t accurate right now. I am understanding more. Not necessarily getting where I want to go, but I’m understanding more. So far, in building the new admin section for the program suite, I’ve been able to get comfortable with a basic MVC program. Really it doesn’t have to do much, it does simple CRUD against the database and I have built custom tables for it to work with. There were a few neat tricks I’ve learned along the way which have made it much prettier. Now my headache is trying to get it deployed on IIS 7.5. I just can’t get it past showing me the front screen at the best I’ve got. Now the latest error is “System.BadImageFormatException: Could not load file or assembly ‘Oracle.DataAccess, Version=4.112.4.0, Culture=neutral, PublicKeyToken=89b483f429c47342’. This assembly was compiled for a different processor” which implies that, though I matched the odp.net dll to the version which is on the server and is in the GAC, it still is fighting me.

Oh well! Back to the drawing board.

 

Down the road, I want to start implementing more SOLID principles along with Unit Testing and Mocks. It will be more detailed, but just as much fun to learn….

Book Review: F# for C# Developers

I recently read F# for C# Developers by Tao Liu. As usual, the disclaimer is that I received a copy of the book for free in return for the review. This one was a challenge. Not because of the programming paradigm shift from imperative driven programming in C# to functional programming in F#, but because the density of the book and my having read a different book on F# rather recently.

Mr Liu is most certainly an expert on F#, both from his work at Microsoft and this book. However there were times when I felt a little frustrated in reading the book. My favourite chapter of this book was Chapter 3 where he examines design patterns which can be found in C# and then applies these patterns to F# code. It remains dense reading, but it demonstrates those patterns very well. Mr Liu takes the notion, as I read this, of showing you how to do something you typically do in C# and redo it in F#. The biggest question about the code samples included is why do I want to? Unlike other books I’ve read where the idea of functional programming and how it can do more in fewer lines can easily be demonstrated with examples like a quick Fibonacci Sequence; many of his earlier examples really don’t show any savings in coding at all. They do demonstrate that if you can do something with C#, you can also do the same thing with F#, but really I never got a lot of benefit analysis or convincing as to why I want to do this at all.

To me, this book really is written for a programmer who has started hearing more about F# and wants to know what could be done with it and wants to get his or her feet wet with the language. I have a feeling if I would have read this before the other O’Reilly book I reviewed on F#, I would have been far more impressed with it and gotten a tonne more out of it. It’s a good book, well written and full of exemplar code which builds on itself, but I felt like I’d covered too much of the same ground with a better guide earlier. That should not, in any way, dissuade a C# programmer who is curious from picking up the book. However, if you have a good deal of exposure to F# through other avenues, this will be a bit redundant.

My recommendation is if you want to get started, get this, then graduate to the other book I reviewed a while back. Both books will make more sense that way!