Tag Archives: Review

Review: Core Java for the Impatient

I’ve just finished reading Core Java for the Impatient by Cay S. Horstmann. I also own Scala for the Impatient by the same author, and I really loved that book. Having had previous experience with Scala, I was excited to read up on the newer features introduced in Java 8. Maybe it’s because I’m a C# developer professionally, but I’m really impressed with the new Java 8 features.

Horstmann’s books are excellently written for existing developers to quickly become familiar with newer languages and technologies. This book isn’t meant for a beginning programmer to dive right into software development using Java 8, but if you have C#, Java, Scala, or other C-style experience you’ll be set. The pace is excellent and the book flows really well.

While it’s expected that you’re already a proficient programmer, I didn’t get the feeling that it was expected for the reader to understand functional programming. Java 8 introduces a lot of functional style which I’ve seen existing Java developers complain about. I’ve also seen C# developers complain about Java verbosity. While I can’t help people who dislike functional programming, I can say as a C# developer that Java 8 really helps reduce the verbosity of the language.

Before Java 8 you’d have to construct a whole new class that implemented a single method if you wanted to create a Runnable (I have limited experience with pre-Java 8, so forgive me if that’s incorrect). In Java 8, you can assign a runnable to a lambda expression. The compiled code will still contain a one-off class but you as a developer don’t have to worry about those details. This kind of syntactic sugar really makes for more readable and more maintainable code. This is the first material I’ve read which covers Java 8, so I assume Horstmann has covered everything. I actually don’t think Java could have packed anything else into Java 8 that wasn’t covered in this book. It’s hard to believe so much great content was presented in less than 500 pages.

The book is written to appeal to the applications programmer, so Horstmann offers a lot of material such as functional concepts in the Collections and Streams chapters, annotations support, date/time improvements, and internationalization. He doesn’t walk you through creating a parser or an actor system like he does in Scala for the Impatient, but he does give you the necessary information to create a maintainable application in Java. The fact that you’ll learn how to create and process annotations as well as to perform runtime compilation of classes opens a world of possibilities (these sections obviously only touch the surface).

The book also covers Nashorn, a JavaScript REPL that provides access to Java types. I have node.js experience, so this really interests me. I’ll need to investigate the performance implications of running Java code from within this JavaScript environment, but this also opens a lot to an applications developer. For example, if you want to play around with a type in Java’s core library, you can fire up a REPL and instantiate the type rather than going through the rigamarole of creating a throw away project. As a C# developer, I use LinqPad regularly on Windows and Mono’s `csharp` interactive shell on OSX.

Again, I love how concisely the content is delivered. The code that accompanies the book is well structured, allowing the reader to quickly jump between text and the full implementations of the code in the book.

Another thing I enjoyed about this book is how information with short examples are presented in the chapter’s text and exercises are presented at chapter end to give a more hands-on experience. If you skip over the exercises, you’ll still get all of the important material of the chapter.

I would recommend this book to any non-beginner who wants to learn about Java 8.

Rating: ★★★★★ (5 stars)

Review: From Mathematics to Generic Programming

 

(This is a repost of my Amazon review) I’ve been out of college for a while. I did well in math classes in high school and college, but I’ve been recently feeling rusty. I wanted to read this book to combine something I love (generic programming) with something I feel is missing in my daily life (mathematics). I wasn’t at all disappointed.

The book covers a lot of interesting historical stories of advancements, discoveries, and progressions in mathematics. It starts with the cravings of the Greeks to learn and how the study of the world around them incorporated arithmetic, geometry, astrology and other teachings. The book presents many different abstractions via axioms, theories, and proofs. These are then seamlessly related to generic programming.

Although the programming pieces of the book don’t stress this enough, the examples are a guidance toward functional programming concepts. Stepanov covers monoids, groups, semigroups, rings, etc. I was surprised by the amount of ground covered in this book. He even discusses how mathematics can be applied to social networks to do something like find friends of friends of friends (graphs).

The code examples in the book are written in C++. This may be intimidating for some developers. Don’t worry, the code isn’t overly advanced. If you’ve worked with another language that has generics, traits, mixins, or macros, you should be fine. These are the level of abstractions you’ll encounter in this book. There’s an appendix to introduce the C++ concepts, if needed.

There are plenty of exercises in the book. These are actually the only the only negative thing I have to say about the book. There are no solutions, no hints, and no companion code for the book’s exercises. Maybe when the book has been around for a while, you may be able to find a github repo where someone has worked through the tasks. I was sad to see nothing like this existed.

I would highly recommend this book to anyone with an interest in mathematics and an interest in generic programming. I felt like the book was a little heavier on mathematics than generic programming. However, I also feel like most developers I’ve met don’t feel comfortable with the application of mathematics concepts.

Flattr this!

Software Abstractions take Skill.

I recently read Adaptive Code via C# and posted a review on Amazon:

This book is a new favorite of mine. I’ve always prided myself on writing clean and concise code. I’ve always been fond of SOLID principles. I wanted to read this book to keep my understanding of SOLID principles fresh. It also covers design patterns, although be aware that it’s not an in-depth design patterns book.

The book is broken into three sections. The first section is an introduction to Scrum and SOLID. Before I had even finished the first section, I was already recommending this book to colleagues. This leading content isn’t necessarily targeted toward developers. I think many managers or team leaders could benefit from reading the basics of Scrum and understanding the terminology for SOLID programming.

I already had a pretty solid (sorry for that) understanding of SOLID principles, so I felt like the second section was more of a refresher. In that vein, I think it’d be hard for me to definitively say how easily digestible this section will be for beginners. I think it will greatly help intermediate or expert engineers to gain a new understanding of software architecture. The book’s audience is meant to be intermediate and expert engineers, but I think beginners could get the content. It’s so well written and clearly explained that I think anyone who might struggle a little with the concepts presented in the book could easily substitute any gaps in understanding with Wikipedia or blogs. Though, I honestly felt like there were no gaps. This section may be boring for non-developers, although I know project managers, program managers, and directors that would find this section interesting. The biggest thing to keep in mind is that SOLID principles are not rules; they’re guidelines.

I thought the last section was excellent. It is split into three chapters in which you’re presented with somewhat realistic dialog (‘fortnight’) that follows a small team through the first two sprints for a chat application. I’ve read a few books on Agile and Scrum methodologies and this section was probably the most fun to read on the topic. It could just be that it’s written as a script with code examples, but it was refreshing and easy to follow.

This book does a great job at explaining technical debt. While reading the book, I realized nobody at my current job has ever said the term ‘technical debt’. I asked around and found that it was a new term to most. The concept of technical debt is one thing I know I had problems understanding as a beginner. As developers become more mature, they begin to understand that the field is usually roughly equal parts business and technology. It’s really important to understand these ‘trade-offs’ and the last section demonstrates pretty well how technical debt occurs.

If you’re on the fence about purchasing this book, you should buy it. It’s a quick read and an understanding of the subject matter will improve your software. I’ve never regretted purchasing a Microsoft Press book.

I gave a short presentation at work recently about SOLID principles, so I was stoked to have a chance to read this book. One of the biggest takeaways I hope anyone has from this book is the ability to abstract software in useful ways.

I recently solved an issue using techniques such as those presented in this book. Specifically, this solution included the Open/Closed Principle, Dependency Injection, and Single Responsibility Principle as well as the Decorator pattern. The issue was simple, one I’m sure many people have encountered in their time with C#; a dataset’s DataRow does not inherent from IDataRecord in the same way something like SqlDataReader does.

Suppose you have a domain model of some kind that you need ‘mapped’ from your database into a single object.

Here’s a demonstration of the problem. I use a csv of cars from Wikipedia and instead of mapping to a domain object, I write out to the console.

First, an example using a DataReader:

using (var connection = new OdbcConnection(connectionString))
{
    connection.Open();
    using (var cmd = connection.CreateCommand())
    {
        cmd.CommandText = "select * from Cars.csv";

        using (var reader = cmd.ExecuteReader())
        while (reader.Read())
        {
            OverloadedDumpRow(reader);
        }
    }
}

Now, an example using a DataRow:

using (var connection = new OdbcConnection(connectionString))
{
    connection.Open();

    var adapter = new OdbcDataAdapter("SELECT * FROM Cars.csv", connection);

    DataSet ds = new DataSet("Temp");
    adapter.Fill(ds);

    foreach (DataRow row in ds.Tables[0].Rows)
    {
        OverloadedDumpRow(row);
    }
}

Aside from the implementation of data retrieval, OverloadedDumpRow should look exactly the same for both examples:

Console.WriteLine("A {0} {1} {2}", 
    row["Year"], row["Make"], row["Model"]);

The problem is that, since these two implementations don’t share a common base type of any sort (DataRow derives from nothing). This isn’t really an issue in a small example like this, but if you have a complex domain and you want to return data from your database and parse that data consistently. Think about what you’d have to do for each and every domain model just to parse resultsets from IDataRecord and DataRow. How do you determine whether or not you’ll even *need* both implementations? To be DRY, you’d need to pull your data from the following methods into variables or directly into your target domain object:

static void OverloadedDumpRow(IDataRecord row)
{
    Console.WriteLine("A {0} {1} {2}",
                    row["Year"], row["Make"], row["Model"]);
}

static void OverloadedDumpRow(DataRow row)
{
    Console.WriteLine("A {0} {1} {2}",
                    row["Year"], row["Make"], row["Model"]);
}

Obviously, this isn’t reusable. What we’d need is an interface. Something like this:

public interface IStringIndexed
{
  object this[string key] { get; }
}

Then, we could implement the redundant methods above in a single method:

static void DumpRow(IStringIndexed record)
{
  Console.WriteLine("A {0} {1} {2}",
    record["Year"], record["Make"], record["Model"]);
}

To get from IDataRecord and DataRow to this target interface, you’ll need an adapter. An adapter decorates a target type and exposes some new interface for that type. This can be a little confusing in our case because IDataRecord and DataRow have the same functionality (returning an object by string index), but they don’t have a consistent interface allowing us to write abstractions on top of these two types.

Our simple interface follows the single responsibility principle (implementations can only get an object by key) as well as the open/closed principle (you can now write extension methods against IStringIndexed).

Writing an adapter to use the interface from above is ridiculously easy. Here’s one of them:

internal class DataRowStringIndexedWrapper : IStringIndexed
{
    private readonly DataRow _row;

    public DataRowStringIndexedWrapper(DataRow row)
    {
        _row = row;
    }

    #region IStringIndexed Members

    object IStringIndexed.this[string key]
    {
        get { return _row[key]; }
    }

    #endregion
}

You would wrap an IDataRecord in exactly the same way.

Here are the two updated examples (notice both of these dump the record to console using the same method):

using (var connection = new OdbcConnection(connectionString))
{
    connection.Open();
    using (var cmd = connection.CreateCommand())
    {
        cmd.CommandText = "select * from Cars.csv";

        using (var reader = cmd.ExecuteReader())
        while (reader.Read())
        {
            DumpRow(new DataRecordStringIndexedWrapper(reader));
        }
    }
}

using (var connection = new OdbcConnection(connectionString))
{
    connection.Open();

    var adapter = new OdbcDataAdapter("SELECT * FROM Cars.csv", connection);

    DataSet ds = new DataSet("Temp");
    adapter.Fill(ds);

    foreach (DataRow row in ds.Tables[0].Rows)
    {
        DumpRow(new DataRowStringIndexedWrapper(row));
    }
}

This is the power of following SOLID principles and studying design patterns. This example isn’t taken from the book, but you’ll learn these skills and more in the book.

Code

A console application of this example is available on github.

You can purchase Adaptive Code via C# from informIT or Amazon.

Flattr this!

Functional Thinking is… functional

Submitted at: O’Reilly
Pros:
Concise, Easy to understand, Accurate, Helpful examples
Best Uses:
Intermediate, Expert, Novice, Student
Describe Yourself:
Developer

I’ve reviewed Neal Ford’s “Functional Thinking” video series as part of O’Reilly’s bloggers program and I must say it is one of the best videos I’ve seen.

I’m familiar with functional programming techniques from other languages, but I wish I had originally learned some of the concepts from this video. For example, when Neal gives an example of currying versus partial application, I felt like any developer I know would fully understand the difference between the two (not an easy feat).

Neal covers quite a bit of ground in this video, and he does it in a way that is easy to follow and clearly understand. One of the things I liked best about this video series is how examples are given in a format of first demonstrating code in an object-oriented Java snippet followed by a transitional snippet that is somewhat more functional, then a final fully functional example in one or more functional languages.

That said, I also think this video series could have done without all of the Clojure examples. It was nice to see Groovy, Scala, and some functional Java examples. I feel like the content matter would have been a little more effective to someone unfamiliar with functional programming without the common shock of trying to discern a Lisp-style language.

I especially enjoyed Neal’s discussion about the paradigm shift from object-oriented programming to more functional programming. He is able to support this with concrete examples of functional concepts like map/fold, functional data structures, preferring composition over inheritance, and a lot more that I think any developer of any experience level would benefit from watching.

I’d recommend this video series to everyone interested in functional programming.

Flattr this!

My review of Python Cookbook, 3rd Edition by O’Reilly Digital Media

Product: Python Cookbook, 3rd Edition by O’Reilly Digital Media
Submitted at: O’Reilly

Fantastic Cookbook
by JimSchubert from Seattle WA on 7/27/2013

Pros:
Helpful examples, Well-written, Concise, Easy to understand, Accurate

Best Uses:
Intermediate, Student, Expert, Novice

Describe Yourself:
Developer

I read Python Cookbook as part of the O’Reilly Bloggers program. I would highly recommend Python Cookbook to developers with any level of expertise, provided they understand the basic syntax and usage of Python 3.

I don’t use Python regularly. I’ve stayed away from Python for a while because of the parallel development of the 2.x and 3.x versions of Python. One of the things I loved about this book is that the authors clearly state that the intention of the book is to cover Python 3 only. In fact, many of the recipes won’t work in Python 2.x. The book’s contents have made me rethink avoiding Python.

I consider myself somewhat familiar with Python basics, which is required if you want to gain the most from this book. While the book does start of with some simple recipes (like list comprehensions, string manipulations, math operations), it eventually delves more into advanced topics like metaprogramming, socket programming, and the intricacies of working with threads.

It may not cover extremely advanced topics in Python, but the book comes close. The last chapter discusses interacting with C libraries which you may already have experience with if you’ve read Gray Hat Python (also available from O’Reilly). I consider language interop a pretty advanced topic.

In all, I was very pleased with the content and delivery of this book. I generally bookmark one or two pages in a book, but with this book I ended with 12 bookmarked pages. It definitely left me excited about developing applications with Python 3.

One caveat to readers: some of these recipes are for demonstration purposes only and should not be used in production code. For example, recipe 10.11 shows how you’d load modules from a remote machine using import hooks. Just because you *can* do this, doesn’t mean you should.

Flattr this!

Computer Science Programming Basics In Ruby

Computer Science Programming Basics In Ruby
Originally submitted at O’Reilly

Product: Computer Science Programming Basics in Ruby by oreilly
Submitted at: O’Reilly

Great intro to basics!

by JimSchubert from Seattle WA on 6/7/2013

Pros: Accurate, Well-written, Helpful examples, Easy to understand, Concise
Best Uses: Student, Novice
Describe Yourself: Developer

I read this book as part of the O’Reilly blogger program. I have been a professional software engineer since 2008, and I thought that I wouldn’t gain much from this book from a technical perspective and just provide some creative feedback for future readers. I also regularly enjoy teaching others about technology and different aspects of development. I was very impressed with the authors’ presentation of material.

If you have a degree in computer science, this book is most likely not for you. The actual material discusses things like what an array is and how to use one. It also provides examples of how to use branching conditional structures, objects, files, etc; like the title says, these are the basics.

What impressed me the most was the use of diagrams throughout the book. As engineers we regularly try to cut corners by going light on documentation, which is a practice that plagues the field and turns our science into more of an art. What is even more difficult than writing documentation or learning materials for other engineers? Writing for non-engineers. This book does an excellent job of explaining concepts that most authors take for granted. For example, I think you would have difficulty finding an introductory level book that doesn’t explain arrays with a picture of adjacent boxes to represent indexes; as engineers we assume that new engineers may have issues with data structures, but we regularly take control flow for granted. I think we assume that control flow can be really explained by requesting it to directions, but this simplification may not work for everyone. This book presents control flow by providing an application example, then displaying the logic of the example in a flowchart. I love that. I think this aspect alone would easily reduce some of the intimidation a new student to the computer science field may have.

I would recommend this book to students or anyone considering a career move into software or web development. I would also personally be interested on reading more by this team of authors on advanced topics.

Flattr this!

My Review of Hilary Mason: Advanced Machine Learning


More “Intro to Machine Learning part 2”

By Jim Schubert from Richmond, VA on 9/22/2012

 

4out of 5

Pros: Helpful examples, Easy to understand

Cons: Too basic, Not comprehensive enough

Best Uses: Novice, Student

Describe Yourself: Developer

I watched this video as part of O’Reilly Media’s blogger program. I haven’t worked with machine learning topics in the past, and I was interested to learn a bit from this video. It turns out that I use many of the machine learning concepts in the linux terminal almost daily, but on much smaller data (personal computer logs). I’ve even parsed Apache logs in almost the same way as presented in this video’s “Learning from your data” segment.

At first, I was little confused why this video is called “Advanced Machine Learning” because I didn’t feel like any of the topics were all too advanced. Each segment seems to only skim the surface of a very general topic. In fact, it seems to me that this video is more of a continuation of Ms. Mason’s other Machine Learning video on O’Reilly– “An Introduction to Machine Learning with Web Data.” It may be more appropriately named “An introduction to data analysis”, and that’s not a bad thing! Don’t be turned away by a misleading title. Fair warning: I’ve rated the video based on the content with my proposed title.

If you’re looking for an in-depth discussion of machine learning algorithms, this isn’t the video for you. If you’re looking for an introduction in getting things done with data, you should check out this video. Although the amount of information is pretty light, it is still a good way to get your start conceptually. If you look at the scripts and sample data provided in the code repository, you’ll be off to a good start to learn more about your data.

For instance, Hillary makes it a point to break things down into a few simple steps:

1) What is your data?
2) What do you want to learn from your data?
3) How to extract that information.

Again, I wouldn’t recommend this video if you’re software engineer with a desire to learn in-depth machine learning algorithms. I do recommend this video if you’re interested in understanding some fundamentals of machine learning and how they’re applied in some advanced production scenarios (especially at bit.ly).

I also recommend checking out the code examples and learning the basics of the python modules used in the scripts. They will help you analyze your data in a meaningful way.

(legalese)

Flattr this!