Pages

First Impressions: Go (GoLang) 30 April, 2013


Go is a language that mixes old and new concepts. They use automatic memory management, but also bring back pointers and unsigned primitives. Other differences include forcing defensive style. It is a statically typed language, which helps find errors at compile time rather than waiting for a runtime error/test to catch the problem. Something else that I really like is the basic web site readiness. Go comes built with web technologies built in.

I think it's a decent language, but for me to spend more time using GO, it needs:
1 - a unique name (try to google 'go' + something)
2 - to be built out more (ex: compiler optimizations, improved web site readiness)
3 - better data integration (it feels like the only good support is for AppEngine's Datastore)

The use of GO seems to be restricted to a few startups, or to tools of better known or longer lived companies. Here's a list of some features I wanted to highlight:


Tools

The tools are still ramping up. Getting automatic building and completion on OSX seems like it was more of a pain than it should have been. The windows setup was pretty simple. It gives you an idea of what is available, but isn't quite as smooth as your standard Eclipse or VS auto-complete.


Speed

Another thing that needs some love is the compiler optimizations. I ran a couple of benchmarks. I know these are specific cases, but  for a compiled binary, it should have out preformed Java. Instead Java was at least twice as fast. The two tests I ran were SHA2 generation, and Fibonacci generation.

Built In Web Framework

There is no need for an additional or external web container. No Tomcat. No Rails. It runs it's own server and it's built in.
package main
import (
  "net/http"
)
func main() {
  http.HandleFunc("/", someHandlerFunction)
  http.ListenAndServe(":8080", nil)
}

HTML Templating

Built into the language is the ability to markup HTML with GO data:
.go file:
x, y := template.ParseFiles("some.html")
x.Execute(httpResponse, dataModel)
.html file:
<a href="someLink">{{.LinkTitle}}</a>

Multiple Return Values

func getPair() (int,int) {
  return 1,2
}

Signed & Unsigned Types

a int8 = 127b uint8 = 255

Forced Style

{}s required for one line if/for blocks. Not doing this creates a compile time error. Also, else statements must be on the same line as it's braces.
Right:
if i==0 {
  //Something
} else {
  //Something else

Wrong (no braces):
if i==0
  i = -1

Wrong (closing if/starting else braces are on different lines):
if i==0 {
}
else {
}

Unused Code

Unused code (variables/imports/etc.) will create compile time errors instead of warnings.

Initializing Statements for if Blocks

if i:=math.Max(a,b); i==5 {
  //Do something, possibly using i
} else {
  //Use i here too 
}  

Easy Small Object Construction & Assignment

Java:
class Pair {
  int a;
  int b;
  public Pair(int a, int b) {
    this.a = a;
    this.b = b;
  }
}
new Pair(1, 2);
V.S.
GO:
type Pair struct {  a int  b int}Pair{1,2}


Pointers (No Pointer Arithmetic)

func mod(i *int) {
    *i++
}
func main() {
    i:=4
    mod(&i)
    fmt.Println(i)
}

Variable Struct Construction Args

type fourPropertyStruct struct {
    a,b,c,d int
}
func main() {
    fmt.Println(fourPropertyStruct{b:4,d:7})
}


Simpler Syntax for Arrays

someArray[firstElement:lastElement-1] will return the appropriate subset of someArray[]. Missing indexes imply beginning or end ([:3] or [3:] for example)


One Form of For

Instead of a multi step for and a simple iterator based for, one form is used:
var list = []int{1, 2, 4, 8, 16}
func main() {
    for i, v := range list {
        fmt.Printf("index: %d, value: %d\n", i, v)
    }
}
To keep a single For form, _ is used when you don't need either the index or value
for _, value := range pow {
    fmt.Printf("%d\n", value)
}

Object Creation

new creates New Objects
make creates New Arrays & Maps
a:=new(SomeStruct)
b:=make([]int, 5)
Maps are declared: map[keyType]valType
maps can return a key, boolean pair describing what the value is/if the key existed

Simultaneous Assignment

x,y = y,x+y
Temp variables are no longer needed!


No Break Statement Needed in Switch Statements

switch ret {
  case 1: //Do something
  case 2: //Do something else
  default:
}

No Classes. Just Structs with Methods Appended

interface types can have method signatures defined in them. a type implements an interface when it has those methods, not by tagging it as that interface
type Greeter interface {
    Greet() string
}

Errors Implemented by Having an Error()(string) Method

You don't tag a struct or object with an interface. If an object has the methods defined in an interface, it is automatically-polymorphically-compatible.

Easy Threading

go someMethod, will launch that method on a separate thread. When you combine this with channels (a report back mechanism), concurrency becomes simple compared to many other languages:
func getInfoFromThread(x chan string) {
    x <- "hi"

}
func main() {
    x := make(chan string)
    go getInfoFromThread(x)
    z := <-x br="">    fmt.Println(z)
}

Transistors and Computer Science 22 March, 2013

It feels like there are a multitude of developers who talk about Arduino, Raspberry pi, and computer hardware in general. This being said, I haven't observed many that add this type of knowledge to their arsenal. Over the last year, I caught myself doing the same thing, so I finally took the plunge.

Understanding topics like Ohm's law and current are necessary to get into any detail. If you're a hobbyist, Maker Shed has a great intro. But for a developer looking for the executive summary, the transistor is a good place to start. Not only is the transistor something your dev box is based on, but it has the fascinating application of being able to represent boolean logic in hardware. This lays the foundation for all those truth tables you did in your Computer Architecture/Systems classes.

Here's an example.
Inputs: A, B
Output: C

Here's a truth table for C = f(A, B):
ABC
000
010
100
111

A boolean expression that calculates A and B based on this truth table would be:
A AND B, also commonly written as A∧B or A && B.
If both A and B are 0, or either A or B are 0, C equals 0.
C is only 1 if both A and B are 1.

Here's where transistors come into play. Basic Bipolar Junction Transistors take two inputs, and have a single output. They are perfect for creating AND, OR, NOT, XOR, NAND, and NOR operations. Transistors may need to be chained together while acting as a series of cascading switches to get such benefits, but they can do it.

Once we chain enough of these logic gates together, we can do more complicated computations.


Here's a transistor schematic symbol:
Here's a schematic for an AND gate using two transistors:

Simple, yet interesting.

From Strategy to Marketing 24 May, 2011

At a high level, marketing can be broken down into four steps:
  • Understand needs
  • Plan for meeting those needs
  • Communicate & execute the plan
  • Build relationships
The first and last items in the above list are largely marketing oriented. The middle two are strategy oriented. Strategy and marketing are often taught separately, but are very intertwined.

Marketing is all about capturing value from targeted customers by creating profitable relationships with them and building value for them. This requires a great deal of strategy.

During the screening and concept phases of product development, a need is targeted. This need is compared to current solutions using both marketing concepts and value propositions.

Targeting and Segmentation
Markets can be segmented in many ways. Segment variability and available resources determine a which segments are targeted (chosen as the buyers or consumers). The most common segments are based on:
  • Geographic
  • Demographic
  • Age
  • Lifestyle
  • Gender
  • Income
  • Psycographic
  • Behavioral
  • Occasion
  • Benefit

Effective segmentation means that a segment and resulting reactions must be:
  • Measurable
  • Accessible
  • Substantial
  • Differentiable
  • Actionable

One way to identify holes in the market, or segments that are not being served is to use positioning maps. An example is shown below:



Marketing Concepts
Concepts in marketing (your overall strategy for selling) include:
  • Availability and affordability
  • High quality and high performance
  • If large scale marketing and selling efforts take place
  • Knowing the needs and wants of the consumer
  • Long term interests of consumers in business and society

Value Propositions
A value proposition (all the value that you are offering) points you in the direction of your positioning strategy. A positioning strategy is generally one of the following:
  • More for more
  • More for the same
  • More for less
  • The same for less
  • Less for much less

To communicate this to the customer, you create a positioning statement. This statement takes the form of:
"To our is that "

The marketing mix supports the positioning strategy and statement.

Corporate Governance 07 April, 2011

While management is about directing activities, governance is about setting the conditions within which activities can be directed. Formally defined, corporate governance is about management and the board of directors enforcing policy that:
  • Balances the interests of shareholders
  • Forces responsibility, accountability, and transparency
  • Challenges management to achieve high performance
Agency Theory
Agency theory is one way of looking at the problem of controlling the performance and ethics that a business’s influence carries. In agency theory, there are two actors. One actor is a principal, which is thought of as a stakeholder (someone who is affected by an entity). The other actor is an agent, or someone managing the entity. It is often the case that the principal and the agent do not have the same goals. For example, although the principal may have a monetary stake in the entity and the agent is an employee of the entity, the principal and agent may not share the same work ethic for company success or the same notion of what appropriate risk is.

Given these differences in how the principal and agent think about an entity, it may be difficult for a principal to monitor the actions of the agent. When active monitoring does not take place, it is easy for the gap between a principal’s and an agent’s desires to grow wider and conflict. Corporate governance can help close this gap.

Who is Involved?
Although everyone should act responsibly, the board of directors has the explicit responsibility for overseeing corporate governance. The board is usually broken up into several committees who each have one or two main objectives. The responsibilities of the board of directors and its committees include:
  • Nominating other board members
  • Auditing and determining who performs the audits
  • Setting the tone for ethical behavior and high performance
  • Approving budgets
  • Ensuring availability of financial resources
  • Setting salaries and compensation for executives
  • Watches out for a “if it is legal, it is okay” attitude
  • Questions executive decisions
  • Allows the outside to see success
  • Looks out for shareholder equity
  • Balances stakeholder interests
Stakeholder Analysis
Being aware of all stakeholders that are affected by the company and balancing their needs can cover much of what corporate responsibility is meant to do. The following list outlines basic stakeholder analysis steps:
  • Identify all stakeholders and their relationship to the company
  • All stakeholder needs must be identified (time, quality, cost)
  • An organization must understand how well stakeholder needs are being met
  • Gaps in providing for needs must then be weighed and necessary changes made
Independence
The executives of a company are responsible for following guidelines and rules, but it is the board of directors that should have the last say in questionable matters. Given all the decision making and analytical power that the board possesses, an important caveat in structuring a board of directors is the degree to which they are independent. Independence in a board of directors will determine how easy it is for a company to become unethical or underperform.

The degree to which a board of directors is independent directly affects how equitable it is with shareholders as well as how it balances stakeholder needs. When a board is independent, it can act without bias. When a board is not independent, conflicts of interest arise. To help ensure the independence of board members, they must:
  • Not have any conflicts of interest
  • Not be afraid to speak out
  • Be trained to ask the right questions
Making sure that an annual meeting calendar with topics exists, and making a distinction about what decisions the board should make can help the board operate effectively.

Companies must pay the price to help ensure that conflicts of interest do not exist, that boards are independent, decisions are transparent, and that auditing is done correctly. If they do not, more regulations will be put in place and fewer overall benefits will be garnered by stakeholders.

Deciding in Light of Uncertainty and Risk 05 April, 2011

Decision making can be difficult because there are often many options to chose from, and varying levels of risk are built in to these options. Many times, when people talk of managing risk, they simply mean transferring the risk elsewhere. Decision and risk are necessary issues that must be dealt with, simply because business is a competitive environment. Conservatism can work for a period of time, but it opens the door for others to leapfrog a business that is unwilling to take some risks or make decisions involving uncertainty.

Risk and uncertainty often are the result of incomplete information, ambiguous information, or time constraints. Sometimes, they are a result of people interpreting the same information differently. A representative sample may be necessary from which to base a decision.

Another reason that this subject warrants attention is because common solutions for dealing with risk and uncertainty have become flawed. History is not an indicator of black swan events. Although using historical data to analyze current situations can be useful, it should probably be used as a last resort in many scenarios. The following set of generic and specific frameworks will help identify what a correct decision should be, regardless of the uncertainty level.

Decision Making Steps
  • Recognize the need for a decision
  • Generate alternatives
  • Assess alternatives
  • Choose among alternatives
  • Implement the chosen alternative
  • Learn from feedback

You may be able to narrow alternatives by removing those that are not:
  • Legal
  • Ethical
  • Economical
  • Practical

Risk Matrix

A risk matrix simply interpolates and visualizes what risk may be associated with familiarity of products/technology, as well as what risk may be associated
with familiarity of markets.


Reality Check
Simply asking the following questions can provide a person with a reality/sanity check and as an initial feasibility test. An entire Harvard Business Review article was written on this:
  • Is it real?
  • Can we win?
  • Is it worth doing?

Cynefin Framework
A decision is categorized into one of four levels of order/organization, and then dealt with accordingly:
  • Simple - Clear cause and effects -> Use best practices
  • Complicated - Multiple right answers exist -> Use expertise
  • Complex - No visibly right answer -> Look for patterns
  • Chaos - No right answer, no pattern -> Establish order

Uncertainty Framework
Three academics (Courtney, Kirkland, and Viguerie) established a model for identifying levels of uncertainty and dealing with them.
  • Level 1 - Basic uncertainty -> Learn the required information
  • Level 2 - A few possible outcomes exist -> Use a decision tree
  • Level 3 - No discrete number of outcomes -> Use scenario planning
  • Level 4 - Even variables are discrete or unknown -> Use analogies to simplify

Decision Styles
Subordinates are all on a spectrum of needed supervision. When others cannot or will not decide, you decide for them. Otherwise, responsive, intellectual, and participative decision styles should be used.

Decision Trees
If a few requirements are met in a given scenario, it is possible and useful to use decision trees to narrow down and grasp options. The following steps outline how to create and use a decision tree:

Prerequisite - You must know all the alternatives, be able to assign probabilities to them, and have clear objectives.
  1. State your decision
  2. Draw branches for any intermediate results that could occur
  3. Draw branches any decisions that should be made at that stage
  4. Repeat steps 1 & 2 until no more intermediate results or decision points exist
  5. End each final branch with a outcome result ($ for example)
  6. Multiply probabilities and outcome values where it makes sense
  7. Based on all probabilities and final objectives, choose the best outcome

Example Decision Tree

Avoiding Decision Making Pitfalls
  • Don't form an immovable hypothesis from the piece first information you get
  • Don't justify decisions simply from historical data
  • Don't use the status quo as a benchmark for success
  • Get an outside point of view
  • Phrase the problem differently to see other sides
  • Be mindful of over emphasis by individual sources
  • Watch out for assumption padding on multiple levels
One of the most important things that can be done to improve decision making abilities is to receive quick and clear feedback after a decision has been made and results are available.

Leadership vs Management

Leadership vs Management

The words management and leadership both describe ways of dealing with people, but they underscore two very different ideals. At a high level, management deals with complexity by breaking up work. Leadership deals with change by applying a vision to everyone’s work.

A higher level of leadership would normally be found in the executive ranks of organizations. A higher level of management is usually found in the middle ranks of an organization. Finding the best mix of management and leadership for a person is extremely important. One reason for this is that the amount of supervision needed theoretically changes as you look higher towards C-suite positions. When less supervision is needed, there exists in subordinates attributes needed to make decisions. They need to be led more than they need to be managed.

Peter Drucker said “There is nothing more wasteful than becoming highly efficient at doing the wrong thing”. I would add that “There is nothing more frustrating than knowing you are on the right path, but getting nowhere”. Management is doing a thing right. Leadership is doing the right thing.

Although managing complexity can be hard, changing can be harder. John Kotter outlines an eight step change process that can help:
  • Create urgency
  • Form a group of advocates
  • Get the vision right
  • Communicate to get buy in
  • Empower action
  • Create short term wins
  • Don’t give up
  • Make change stick

Here is a comparison of leadership and management goals:


Can anyone be a leader?

Kouzes and Posner say that a leader must be able to:
  • Find your voice (your words must be consistent with your actions)
  • Affirm your values (what you care about – determined by how you spend your time)
  • Express yourself in your own way (others follow authenticity)
  • Challenge the process (experiment and grow)
  • Enable others to act
  • Encourage optimism

Formally, there are several academic frameworks for understanding leadership

Trait approach
This approach goes in and out of style every few years. It says that there are specific traits that define whether or not a person is a leader. Research shows that most of these traits can be learned. These traits drive decision making and generally include:
  • Drive
  • Extraversion
  • Integrity
  • Self-confidence
  • Knowledge of the business
  • The ability to read others

Behavioral approach
This approach is simply to focus on both project goals as well as team relationships. Finding the right balance of these two items determines the effectiveness of the leader. This approach can be seen in many aspects of the situational approach.

Situational approach
This approach to leadership says that universal leadership traits and behaviors don’t exist and you must look at the situation before deciding what to do.

Three popular situational models include the Vroom model, Fiedler analysis, and the Hersey/Blanchard theory.

1 - The Vroom model looks at situational attributes such as decision significance and where subjet matter experts are, assigning each one a status of high or low. A funnel method is then used to narrow down how the decision should be made (on a spectrum of autocratic to democratic). If more than one option seems to fit, use the one that will take the least amount of time.

2 - Fiedler analysis asks three questions and uses a funnel model similar to that of Vroom’s to determine if a leader’s decision should favor project goals or personal relationship maintenance. The three questions include the following:
Is the leader to other relationship good?
Is the task understood?
Does the leader have power?

3 - The Hersey/Blanchard theory looks at the maturity of individuals involved and decides whether to focus on project goals or personal relationship maintenance. It simply states that if a person or group has a low or high maturity, a focus should be placed on project goals. If, however, the person or group is of moderate maturity, a decision should focus on personal relationship maintenance.

With knowledge workers, helping everyone to exemplify a shared leadership is critical. It is often difficult to do everything by oneself. After all is said and done, I think one of the easiest ways to act is based on a statement I once heard “Help others fall into the pit of success”. Although oversimplified, this very well may sum up the way managers and leaders should act.

What most people call the 'org chart' 30 March, 2011

Organizational design describes how an organization is configured. It helps assign tasks and roles to people. It also allows people to integrate ideas and communicate. A few main components of organizational design are:
  • Reporting relationships
  • Reward systems
  • Rules and procedures
  • Communication methods
  • Job specialization
  • Decision making methods
  • Learning
  • Distribution of authority
One way to organize and setup these components is to follow the “Structure should follow strategy” mantra. Look at what the strategy is, and design the previous components accordingly. When many people think of organizational design, they think of the structure component (the “org chart”). This may be due to the difficulty in thinking through many of the organizational design components. Instead of customizing the level of each component to a strategy, many people use a canned or popular default organizational structure. Default structures help determine how organizational components are designed.

Before describing popular organizational structures, it should be noted that all organizational structures can fall within a spectrum. One end of this spectrum is labeled ‘Mechanistic’, and the other end is labeled ‘Organic’. Mechanistic organizations are considered to be closed to their environment because they cannot adapt or deal with complexity. Organic organizations on the other hand, are considered to be open to their environments because they can adapt and deal with complexity.

Typically, mechanistic structures have the following characteristics:
  • Many levels of management
  • Centralized decision making
  • Many processes and procedures
Mechanistic structures are the most common because the first enterprises were patterned after the Army which had a very strict chain of command.

Organic structures usually have these characteristics:
  • Few levels of management
  • Decentralized decision making
  • Few formal processes and procedures
Here is where each of the following default structures lie on the mechanistic-organic spectrum.

Simple:
This is generally used by small businesses or startups. Although they can be quick to respond, adaptations come in small iterations. They cannot handle complexity and usually bottleneck when coordinating with ‘the boss’.

Functional (Unitary-Form):

This form organizes people based on their skills. It can deal with more complexity than simple organizations because of the specialization groups that employees are in. Each department however, has a hard time seeing the big picture which involves the other departments and their concerns. Processes are usually required to facilitate or force coordination between departments. This is generally the most common. This structure promotes centralization.

Conglomerate (Holding-Form):
A conglomerate is a set of unrelated businesses and based on departmentalization. Each of these businesses could be further categorized.

Divisional (Multidivisional-Form):

Instead of creating departments based on skill, departments are created based on geographical regions, customer groups, or product groups. Customer needs can be better met with this type of structure. Divisional structures are scalable and do not force employees to specialize. Administrative costs rise because each department could be a miniature functional company. Divisional structures can adapt and deal with complexity better than functional structures because a divide and conquer approach is present. These organizations start sharing resources.

Matrix:

A matrix structure tries to get the best of both worlds by superimposing a functional structure on top of a divisional structure. High levels of communication and coordination are present, but this comes at a higher cost. Less time is spent supervising, but decisions may take longer because consensus from a diverse group will be harder to achieve.There are also usually two bosses which can cause confusion. This structure takes full advantage of its human resources.

Project/Team:

Like matrix structures, team organizations are hybrid structures, but with only one boss per person. They adapt well, and can handle complexity well. They are very costly to operate. There is often forced collaboration because teams are made up of multiple skill sets. People can easily move from project to project when they are needed, and this transient behavior helps transfer information throughout the company.

Network:

The network organization is one which is almost exclusively made up of partnerships and outsourcing. These partnerships and outsourcing contracts can easily be renewed, replaced, or removed. Sometimes called a virtual corporation, it can be accommodating but can also be a communications nightmare. Many online companies take this form.

The following factors can help determine how mechanistic or organic an organization should be:
  • Stability of the industry
  • The pace of industry innovation
  • Number of products
  • Number of competitors
  • Number of external partners
  • Number of employees
  • Number of clients
  • Internationalization
  • Company culture

If a company wants to change its structure to fit its strategy, the company culture will probably determine whether the effort will succeed or fail. Often the level to which an organization can be organic will be determined by the self-motivation of its people and their ability to understand each other.