Adam on code.

Thoughts on code and software engineering.

Books on software architecture

I compiled a list of books on software architecture based on the discussion in the group “97 Things Every Software Architect Should Know” on LinkedIn

What are must read books for a software architect?

Essential list of books on software architecture.

 

JJ DID TIE BUCKLE – USMC Leadership, The Character of Christ and Netflix’s Culture Values.

Every United States Marine knows and strives to exemplify the 14 leadership traits. In the Christian life we look at the Fruit of the Spirit and the character of Christ as the goal for ourselves. I read a presentation given at Netflix about the company culture that reminded me how important it is to revisit these definitions from time to time and realign my values. I think we all like to work with people that embody Netflix’s values.

I’m not elevating Netflix to the level of the Marine Corps or the Bible but I think it’s a good example of a company’s values. After all, we do spend a good portion of our lives in a professional environment working and interacting with others. We don’t live insulated lives in particular groups but rather overlaping circles that affect each other. I’m only referencing three areas but in  reality we usually have more circles and people and lives are more complex.

JJ DID TIE BUCKLE

1. Justice: the practice of being fair and consistent.

2. Judgment: the ability to think about things clearly, calmly and in an orderly fashion.

3. Dependability: the ability to be relied upon to perform duties properly, and being trustworthy to complete a job while putting forth the best possible effort in an attempt to achieve the highest standards of performance.

4. Initiative: taking action without orders, meeting new and unexpected situations with action and being resourceful to get something done.

5. Decisiveness: being able to make good decisions without delay while weighing all the facts while acting calmly and quickly arriving at a decision.

6. Integrity: being honest and truthful in what is said and done; putting honesty, sense of duty and sound moral principles above all else.

7. Enthusiasm: a sincere interest in the performance of all challenges.

8. Bearing: carrying oneself with confidence.

9. Unselfishness: avoiding making or being comfortable at the expense of others, being considerate.

10. Courage: the ability to remain calm when recognizing fear. Standing up for what is right and accepting blame when responsible.

11. Knowledge: understanding the job and acquiring knowledge to understand people, along with keeping up with current events.

12. Loyalty: being devoted to country and respecting seniors, peers and subordinates.

13. Endurance: the mental and physical stamina measured by the ability to withstand stress and hardship.

14. Tact: dealing with people in a polite, calm manner to maintain good relations.

http://www.au.af.mil/au/awc/awcgate/usmc/leadership_traits.htm

 

Galatians 5:22-23

New King James Version (NKJV)

22 But the fruit of the Spirit is love, joy, peace, longsuffering, kindness, goodness, faithfulness,23 gentleness, self-control. Against such there is no law.

From Netflix’s slides,

Seven Aspects of our Culture (Italics mine)

  1. Values are what we Value
  2. High Performance
  3. Freedom & Responsibility
  4. Context, not Control
  5. Highly Aligned, Loosely Coupled
  6. Pay Top of Market (How many companies say they want to pay top of market?)
  7. Promotions & Development (How many companies think of promotions and development?)

I had a conversation with someone that mentioned that companies can focus on one of three things. A company can focus on the bottom line, its customers or its employees.

“We Want to Work with People Who Embody These Nine Values”

  1. Judgment
  2. Communication
  3. Impact
  4. Curiosity
  5. Innovation
  6. Courage
  7. Passion
  8. Honesty
  9. Selflessness

Here is a link to the complete presentation. 

http://www.keithrull.com/blog/wp-content/uploads/2013/01/netflix_culture.pdf

Also worth nothing this presentation of HubSpot’s culture. 

http://www.slideshare.net/HubSpot/the-hubspot-culture-code-creating-a-company-we-love

House of Cards: a win for Netflix

This is not necessarily a post about code of software; but since I have two previous posts about Netflix. I thought it’s be fitting to mention that Netflix’s new show House of Cards seem like a clear winner. Netflix created a remake of a show from the 1990′s starring Kevin Spacey, a heavy hitter, and released the entire season worldwide on the same day creating a buzz and possibly a new way to release streaming entertainment.

Languages that compile to JavaScript

I sort of feel for anyone who is getting into programming nowadays. There is programming for Windows, OS X and Linux flavors on the desktop and laptops, all the server and mainframe operating systems, then multiple mobile devices both server, client side and cloud. Once you pick a platform or mix thereof, you have to pick the framework and languages.

JavaScript is ubiquitous nowadays. As of today, it has claimed the 5th spot in popularity of programming languages and has become  indispensable on the web and mobile. There are well over a hundred languages that compile to JavaScript. There is a list of them on github: https://github.com/jashkenas/coffee-script/wiki/List-of-languages-that-compile-to-JS. The two most notable of these languages that compile to JavaScript are CoffeeScript, in its own right, and Dart because of Google.  I imagine developers will feel more inclined toward a particular language if it’s based on a language that they already know but eventually some of these will become deprecated.

Code Reviews

At some point in your software engineering career you have to do some sort of code review. You should review your own code but most often you do a review of someone else’s code. I thought I’d share a few of the things that I consider while reviewing code. I have reviewed code mostly on C#, VB, html, JavaScript and SQL. I can share the process and some of the things that I have in mind during a code review. Some of these considerations have grown out of what I’ve seen that causes errors either immediately or down the road or makes code hard to read and understand to other developers.

There is a saying that sooner or later one has to pay the piper. Writing code that is not only efficient but also readable can save you a lot of time in the long run and I would say that the benefits can be exponential when you’re part of a team.

Some of the things to consider:

- Does the implementation meet the requirements of the business? It may seem basic but this can sometimes be missed if the initial definition was not clear. It’s been said that a well-defined problem is half the solution.

- Use intelligent variable names; same applies to database objects and columns. “Id” means nothing unless it’s only used locally. The subject of variable names can in itself turn in to a heated argument among developers. I tend to prefer Hungarian notation, it lets you know the datatype right up front.At least be consistent with your conventions.

In General, and especially in SQL, avoid using data types as variable or column names. Consider this example: Paste this line into an SQL query analyzer.

SELECT
DATEADD(m, 1, CAST(CAST(Month AS VARCHAR) + '/' + CAST(5 AS VARCHAR) + '/' + CAST(Year AS VARCHAR) AS datetime)) AS Date
FROM
MyTable

You might be a bit confused at first. What is odd here?

Answer: Month and Year are columns in a given table. Column names are not colorized but in this case they are also colorized because they are MS-SQL functions.

SELECT YEAR('2012-05-08T01:01:01.1234567-07:00');

Returns the integer 2012. Note also that MS-SQL is not case-sensitive and, unlike MySQL, the terminating semicolon is optional.
It’s not a good idea to use a function name as a column name. If you encounter this you can at least make it more readable by enclosing the object name, in this case columns, with square brackets as such (note here they are still colorized but they should not be in a query analyser):

DATEADD(m, 1, CAST(CAST([Month] AS VARCHAR) + '/' + CAST(5 AS VARCHAR) + '/' + CAST([Year] AS VARCHAR) AS DATETIME)) AS Date

- Include good comments in the code.

- Have good indentation. This can be achieved while coding or, if need be, reformat text. In Visual Studio is easy with Crtl+K, Crtl+D. Other text-based editors such as vi, Sublime Text, etc; may use plug-ins.

- Avoid repetition of logic or code anywhere. For example, use a common table for search results vs. having different table definitions if the search is from different sources.

- Create functions or classes for repetitive operations.

- Use consistent naming of variables, classes and namespaces.

- I prefer code that is readable over fancy contractions that makes it hard to debug if necessary.

- Avoid hard coding as much as possible. Use configuration files or other editable settings mechanisms as much as possible.

- Delete unused code. This will save you and others time when you do a global search plus will make your code neater. If you want to see obsolete code again for some reason, use source control or save it in a snippets file.

- This may seem very obvious but just in case, use variables for a single purpose only.

- Catch errors and log user-friendly messages. This will save you time if you need to debug errors. You can use Try / Catch structures in most languages. In .NET and similarly managed platforms there are error listeners, if you will, such as HttpApplication.Error that can be used to capture unhandled exceptions.

- Delete unused files of any type. Same applies to databases, deleted any obsolete objects. Less is more when it comes to code or objects.

- Look for any enhancements that will make the code faster or better in any way.

For example, use the StringBuilder class instead of String for repetitive string manipulation.

Use a Listinstead of array whenever possible. Many times an array is maxed out with 20 items even when not expected, for example variations of a given product can max out a hard coded array.

I ran into this back in February on code that required selecting distinct values from an array and found a more optimal way to do it based on language enhancements.

.NET Framework 1.0/1.1

public int[] GetDistinctValues(int[] array)
{
ArrayList list = new ArrayList();
for (int i = 0; i < array.Length; i++)
{
if (list.Contains(array[i]))
continue;
list.Add(array[i]);
}
return (int[])list.ToArray(typeof(int));
}

New way of doing it in .NET Framework 3.5

One line of code

nrs = nrs.Distinct().ToArray();

btw: This is illustrated in detail in this post.

http://weblogs.asp.net/gunnarpeipman/archive/2008/05/15/getting-distinct-values-from-arrays.aspx

Obviously some of these principles are different in on other languages such as C/C++ or Ruby but at least functionality, readability and consistency should be the same across languages.

I usually do some unit testing and performance testing as part of code review. If it’s web front end UI code it may mean using multiple browsers or Fiddler to check raw responses or performance as well as variant behavior on different browsers.

There are many other things that can be done to look for efficiency in processing and avoid memory leaks. I would say that if you follow some of these basic tips you’re off to a good start. I enjoy building code that do powerful and useful things. Software engineering should be enjoyable not frustrating.

CSS

Web technologies are growing faster than we can learn them. Consider CSS, there are dozens of frameworks, 15 alone worth considering. And there are 3 pre-processors to choose from, LESS, Sass and Stylus. This is an exciting time for web technologies and perhaps also a time of growing pains. Some suggest that browsers should start supporting the CSS pre-processors directly but that would just extend the gap of backward compatibility and will probably just add more code to pages.

Netflix’s blind tumbles in the dark.

Well, I had barely published my note, which later became a blog entry when I migrated to here, and Netflix destroyed everything that had made it good. They decided to split their business into streaming and mailing movies and charge more. It made me wonder if their success was just a random tumble in the dark instead of the result of really knowing what customers wanted.

Innovation in business and technology.

Congrats to Groupon on IPO filing. Good to see companies that are actually useful succeed. Unlike the fake deals you see all the time, I’ve seen really good deals on Groupon like $12 movie tickets for $4, %50 discounts on other products and services that save you $100 bucks sometimes.
Groupon 2010 revenue: $713.4 million, 2009 revenue: $30.47 million. Nice chunk of change.
They did so well in 2010, in spite of all the Groupon clones that have sprung up. Some clones like schwaggle are pretty good too though. I saved $80 using Schwaggle. Even Amazon has taken notice and launched amazon local, which to me seems like it’s based on the Groupon model. I’ve had a very good customer experience with Amazon so far. Other than the whole, selling books from pedophiles episode, which of course was a gargantuan faux pas in my opinion, Amazon is a good company also. I think I got a free book form them in 1998 and have been hooked since then.

Another company that have broken the old regime of we-got-you-by-the-nuts business mentality from, for example Blockbuster, Netflix! I like that Netflix put the hurt on those big companies and made them change their business model to benefit the customer.

Innovation is not only in technology as in the case of Apple, although Apple didn’t invent the mp3 (I know they have their version -AAC- but that’s not the point), laptop or the smart phone, they have perfected it and dominated the market. I do wish Apple would bring those 500k jobs to America though. Innovation in business has paid off for these companies. It makes me think of the part on the Social Network where Larry Summers is quoted as saying “Everyone at Harvard is inventing something. Harvard undergraduates believe that inventing a job is better than finding a job. So I suggest again that the two of you come up with a new new project.” Obviously intellectual copyrights should be protected but also you can’t have companies suing each other on every little patent. Patent trolls are the vermin of technological progress, I think.

Back in the day I used to think that Sun Microsystems would be a great company to work for. They made amazing hardware and coupled with Solaris, a solid operating system, truly enterprise standard. I loved my Sparc 20 pizza box with a 21 inch monitor. Simply a superb machine. I’m sure there a lots of those still around doing scientific work. Then Scott McNealy went lawsuit crazy against Microsoft. The beef started when Microsoft released Windows NT, a serious threat to Sun’s hold network market share. Sun saw a demon under every byte of Microsoft. Microsoft did end up with a good portion of the server market with Windows NT, 2000, 2003 and 2008. Microsoft matured and diversified Windows to include 64 bit and different editions dedicated to the web, datacenter and so forth. Unlike most Übergeeks, McNealy did not come from the world of computer science but rather from a business background. McNealy bankrupted Sun. Pundits dubbed Sun, Sue Until Nothing left. Sun ended up licensing Java. Microsoft developed their own implementation of Java, which I think kicked Sun’s butt in terms of performance. Many reincarnations later I still think Java is slow, but that’s just my opinion of course. By then Microsoft invented C# and .NET, a killer combination. I think Visual Studio is a very good IDE that also helped to popularize c# and .NET. Even Gosling said C# was a clone of Java. I always thought of C# as Microsoft way of luring Java developers. It did work in part. There’s a whole debate between the main .NET languages camps of VB.NET and C#. C# developers claim that c# is a superior language. I develop daily equally in both languages since that’s what my work place uses to develop primarily, and It’s always been my opinion that C#, again, was to lure some Java programmers as well as a competing with Java. Many of the benefits that C# inherited from Java were implemented in the CLR (common language runtime) where all .NET languages run. And guess what, any flavor of .NET language code compiles to pretty much the same to be executed in the CLR. Aside from the new versions .NET 1, 1.1, … 4.0 there is only one .NET core, just pick your flavor of language to write code. Yes, initially C# and VB were slightly different where C# had generics and was purportedly better at handling low level tasks. Before C# 4.0, C# didn’t allow optional parameters which was touted as a feature that proved c#’s superiority. Well, C# 4.0 now includes optional parameters and a host of other changes to both VB and C# that brought them even closer. Again, there’s a heated debate about which language is better. I think it’s just a matter of preference or what’s used where you work. I’m not intending to discuss the matter at length but just to give my two cents.

Software Engineers are humans and sometimes opinionated. I mean there are those that say if you don’t know Schema then you’re not a good programmer. Some swear by c++ and then there are purists like Linus Torvalds that slams c++ and says c is the perfect language. I don’t see myself tied to any technology and I think that all tools are best fitted for specific purposes. For example try a real business example like creating thousands of pages from a list (or table) with 200k or rows were you need to sort and search on two columns. You have to repeat the process several times everyday. Java, VB, C#, are all bloated and can take about 30 minutes to process all records, eons in computing time. All these languages have limits since the sit on top of another runtime machine (JVM and CLR) along with their entourage of libraries which then sits on the OS (operating system) This is a task where C++ and C demonstrate the real raw power of lower level languages to process data and I/O performance. I would say Microsoft’s managed VC++ sits in between Java-VB-C# and C++, C. In this example Linus would be right C’s performance is scorching fast. Even the DB call is faster in C code. That’s what I like about mathematics and computer science, you can settle disputes conclusively. I mean, if you want to take it a step further you can write your code in assembly but then you have to target a specific family of CPU. Again, I think there are different languages for different purposes. There’s no tool for all jobs when it comes to languages. With the exception of assembly, all of these languages are third generation languages some are more similar to each other than others and some shine a different tasks. Why all these languages? Innovation, someone thought of a way to solve a technological or business challenge.

I’d say Microsoft innovated too. Other than developers using LAMP (Linux, Apache, MySQL and PHP) very few people use Linux. When Microsoft was the 800 lb gorilla (Apple seems to have taken that place in some aspects, also Google starting to join the Evil Empire) there was this whole movement about anything but Microsoft, because Microsoft was taking over the world, Microsoft was special interest and unconstitutional. Before Microsoft it was Standard Oil, The Bell System… how far do you want to go? Linux is free! Plus it came is many flavors! How come there aren’t more people using it? I’d say Windows is easier to use, more software available and even those hard core Linux users boot up their boot leg copy of MS Windows. I never understood how Internet Explorer stifled innovation, but then again, what do I know? It’s seems simple. Make something superior and people will want to use it and buy it. In an ecosystem of free software and free services people will use what they consider superior. How can you argue people’s choice of free alternatives.  Eventually Chrome and Firefox have caught up and beat IE fair and square. A real monopoly is Apple’s lock on the iPod and iPhone to only sync with iTunes. That’s a whole different can of worms.

Google’s entire empire built on innovation has always seemed amazing to me. All the big early players like Microsoft, Yahoo, Netscape, Altavista, really dropped the ball on this one and Microsoft primarily. I always imagine a meeting somewhere in the cavernous bowels of the Microsoft beast in which some employee might have said, “you know what. I think we could do more with all that free data on the internet”, an unruly digression from the norm which had to be quickly crushed with a quick remark such as “what you can’t find something online? Dumb idea, We already do all that anyone would ever need to search the internet” I hope you get the point. Then Sergey and Larry must have said to themselves. You know what? We think there is a lot, I mean a lot that can be done with all that data on the internet. The rest is history. And of course, hindsight is 20/20 but on the other hand it’s the same story over and over again. The mouse at Xerox, MS’s DOS, and other examples. I’m not saying I wish Microsoft had succeeded over Google, Google is a great company, I’m saying Microsoft dropped the ball. A funny thing I saw one time I was at the doctor’s for a physical. The nurse opened the web browser which defaulted to Bing, typed “google” and proceeded to google.

History could have been different for Sun. Sun stopped making CPU’s and hardware altogether. Back in 1999 when I was following this I wondered why Sun didn’t dig in and just beat the competition fair and square by continuing to make better hardware and OS at a competitive price. Yes, the thing about Sun, like Apple, Sun wasn’t cheap. As a consumer I prefer a better product, but also a more affordable one. The law of supply and demand is even stricter in the business world. Things move fast in Silicon Valley. The funny thing is the big players are IBM, HP and Dell with 78% market share. Yes, HP and Dell sell hardware which in turn uses Windows or any OS they choose. It wasn’t even a symmetric battle to start with. Dell just stayed out of the heat and friended everyone, outflanking more established companies. You can see all sorts of parallels between business and the Marine Corps Doctrinal Publication MCDP-1, Warfighting. Nowadays you throw in cloud technologies and it makes for an even changing landscape.

Companies that are stagnant are in danger of being crushed. It’s just the law of the wild wild web. You need to focus on what you can do to innovate in business, technology, etc. Other that suing scoopon, come on! Scoopon, really?, Groupon hasn’t gone all McNealy on all the clones. Anyway, I was thinking how Groupon is doing well and it grew into a longer post. I probably opened too many cans of worms and I may have to revisit this later.

Follow

Get every new post delivered to your Inbox.

Join 365 other followers