Thursday 26 March 2015

6 traits successful entrepreneurs share

CNN Article

 They're persistent

- Launching a start-up is a marathon, not a sprint
-You'll inevitable come against failure on a daily basis.
-Some ideas work, more often they don't. you try, fail and try again. 

 

They're adaptive

- The start-up world can be a jungle.
- The most successful entrepreneurs have a keen ability to adapt to their habitat
-  Can change the inception of an idea to the final product if unforeseen problems arise (ie. the market changes)
-Willing to try another approach when something isn't working
-In start up world its called pivoting.

 

They're risk takers

- Entrepreneurs are, above all risk takers.
- They are willing to part ways with a job that offers a plush salary and benefit to pursue their idea or business, with no guarantee
- We hear
grandiose success stories, but we don't always hear about the long, tumultuous journeys that led them there

 
They're imaginative doers
- Entrepreneurs see the world differently.
- Where other people see problems, they see opportunities.
- But its one thing to have a great idea -- its a whole other thing to see that idea through.
- Successful entrepreneurs don't just dream, they're willing to go out and create solutions.

They're confident

- Trust your crazy ideas.
- Entrepreneurs face doubt, not only from others but also from themselves. It's those entrepreneurs who are confident enough to believe in their ideas, and stick with them, that change the world.

They're trustworthy

People don't invest in companies, they invest in people." Investors are constantly being pitched by entrepreneurs eager for capital. Before they can persuade someone to sign a check and infuse a startup's lean bank account, entrepreneurs must first convince the investor that they can be trusted

 

Thursday 19 March 2015

6.0 Data Types

6.1 Introduction 
  • A Data type defines a collection of data values and a set of predefined operations on those values.
  • An important factor of determining the ease with which they can perform this task is how well the data types are available in the language being used match the objects in the real world.
  • The two most common (non-scalar) data types are arrays and records. although the popularity of associate arrays has increased significantly.

  • It is convenient, both logically and concretely, to think of variables as descriptors.
  • A descriptor is the collection of attributes of a variable.
  • If the attributes are all static, descriptors are required only at compile time.
  • For dynamic attributes however they are used at run-time
  • In all cases, descriptors are used for type checking and to build the code for the allocation and de-allocation operations
 6.2 Primitive Data Types

These are data types that are not defined in terms of other types.

6.2.1 Numeric Types

6.2.1.1 Integer
The most common primitive numeric data type is integer.

Many programming languages support different sizes of integers: byte, short, int and long.
Some languages like C++ and C#, include unsigned integer types.
Unsigned types are usually used for binary data.

A signed integer value is represented in a computer by a string of bits with one of the bits (typically the left most)  representing the sign.

unsigned int  00000001 = 1
                      11111111 =  255

Signed int     00000000 =  0
                      00000001 =  1
                      01111111  =  127
                      10000000 = -128
                      11111111  =  -1

6.2.1.2 Floating Points 

Floating point data type model real numbers, but the representations are only approximations of most real values.

Most languages include two floating point types, often called float and double.
Float - 4 bytes
The double type is provided for situations where larger fractional parts are need. double the size of a float with 8 bytes.


6.2.1.4 Decimal
Decimal data types store a fixed number of decimal digits with the decimal point at a fixed position in the value.
- Date type for business data processing
-Have an advantage of being able to precisely store decimal values, at least those within a restricted range, which cannot be done with floating points.
- its takes at least four bit to code a decimal digit.

6.2.2 Boolean Types

Boolean types are perhaps the simplest of all types.
- Their range of values has two elements - true and false
- Any non-zero value is true
- Zero is false
- A Boolean value could be represent by a single bit, but because a single bit of memory cannot be accessed efficiently on many machines, they are often stored in the smallest efficiently addressable cell of memory, typically a byte.

6.2.3 Character Types
Character data are store in computers as numeric coding.
-ASCII (American Standard code for information interchange) is the traditional character set.
- ASCII uses the value 0 to 127 to code 128 different characters.
-Because of globalization of business and the need for computers to communicate with computers around the world, the ASCII character set is becoming inadequate.

- Unicode has been developed as an alternative.
- 16 bit character set
-Includes characters from most of the worlds natural languages. ie, Thai digit, Cyrillic alphabet
- the first 128 characters are identical to ascii
- Used in C#



6.3 Character String Types
A character string type is one in which the values consist of sequences of characters.

The common string operations are assignment, catenation, sub-string reference, comparison and pattern matching.



6.4 User-definer ordinal types
- An ordinal type is one in which the range of possible values can be easily associated with the set of positive integers.

6.4.1 Enumeration Type
An enumeration type is one in which all of the possible values, which are name constants are provided, or enumerated in the definition.

- Away of defining and grouping collections of name constants. (enumeration constants)
- Sub range is a sub group in an enumeration type ie. Ratings  8,9,10 = high


6.5 Array Types
An array is a homogeneous aggregate of data elements in which an individual element is identified by its position in the aggregate, relative to the first element.

6.5.4 Heterogeneous Arrays - are arrays in which elements need not be the same type.


6.5.6 Array Operations - assignment, catenation, comparison for equality and inequality and slices.

6.5.7 Rectangular Array
- A rectangular array is a multidimensional array in which all of the rows have the same number of elements, all of the columns have the same number of elements

Jagged Array 
- A jagged array is one in which the lengths of the rows need not be the same.
 - i.e one row with 7 elements ,another row with 6, another row with 4 

6.5.8 Slices
- A slice of an array is some substructure of that array.

6.9.6 Pointer
A pointer type is one in which the variable have a range of values that consist of memory address and a special value nil.
-The value nil is not a valid address and is used to indicate that pointer cannot currently be used to reference a memory cell


Pointer have two distinct purposes
1. Pointers provide some of the power of indirect addressing which is heavily used in assembly language programming.
2. Pointers provide a way to manage dynamic storage, A pointer can be used to access a location in the area where storage is dynamically allocated, which is usually called the heap.

Pointer Operations -  assigning and de-referencing


Dangling pointer - A dangling pointer / reference, is a pointer that contains the address of a heap dynamic variable that has been de-allocated.


6.9.7 Reference Type
A reference type variable is similar to a pointer, with one important and fundamental difference.
 A pointer refers to an address in memory, while a reference refers to an object or value in memory.

Wednesday 18 March 2015

Richard Branson Business Book Notes

1.0 Five Secrets To Starting A Business

  1.  If you don't enjoy it, don't do it 
    Starting a business takes huge amounts of hard work so you better enjoy it. 
  2. Be innovative - create something different
    • You've got to do something radically different to make your mark today, it is not easy to start a company and to survive and thrive in the the modern world.
    • Look at Microsoft, Google, Apple and Facebook. the way they've shaken up the world we live in by doing things that had never been done before and then continually innovating.
    • If you enter a already crowded segment, you had better be ready to offer customer service that blows the competition away.

  3. Pride of association works wonders.
    • Businesses are nothing more then than a group of people.
    • People are by far and away your biggest assets.
    • In probably the majority of your businesses your people are your product.
  4. Lead by listening
    • To be a good leader you have to be a great listener.
    • No point of imposing your ideas with no debate and a degree on consensus.
    • No one has a monopoly on good ideas or good advice.
    • Never openly criticize people. Never lose your temper.
    • Always be quick to applaud a job well done, people flourish on praise.
    • People don't need to be told when they've done something wrong, because usually they  know it.
  5. Be Visible
    • A good leader doesn't get stuck behind a desk.
    • Constantly be out and about, meeting people.
    • Its easy in small companies and  harder in large companies, so appoint company heads with the same philosophy. This way you can run large group of company in the same way a small business owner runs a family business. Keeping  proactive, responsive, and friendly.

    p.s If you don't survive, just remember that the majority of new businesses don't make it.
         Some of the best lessons come from failure.|Just pick yourself up, dust yourself off and start
          again.

2.0 People Power - The real engine of any business

Finding them, managing them, inspiring them and then holding on to them is one of the most important challenges a business leader faces, and your success or lack thereof plays a vital role in the long term success and growth of your business.

- A company is a collection of people.
- People are the front-line of your business.
- When a company offers pretty much the same as its rivals. The thing that sets it apart is its people and their attitude towards customers. If they're always smiling, cheerful and pleased to help. customers will continue to want to deal with your company.
- A good leader must know the team, its strengths and weaknesses; socializing and listening to the team face to face is key.
-One of the most common reasons people leave a job is because they are not listened too. it is rarely about money, more often about frustration.
- Leaders must keep the employees trust

Wednesday 4 March 2015

5.0 - QA

1.   What are the design issues for names?
=    The design issues for names are “Are the names case sensitive?” or “Are words for reserved words or keywords?”

2.   What is the potential danger of case-sensitive names?
=    readability (names that look alike, but are different).

3.   In what way are reserved words better than keywords?
 A reserved word is a special word that cannot be used as a user-defined name.
 A keyword is a word that is special only in certain contexts.

4.   What is an alias?
=    When more than one variable can be used to access the same memory location, the variables are called aliases.

5.   Which category of C++ reference variables is always aliases?
=    Union types. Union is a type whose variables may store different type values at different times during program execution.

6.   What is the l-values of a variables? What is the r-values?
=    The l­-values of a variable is its address. The r-values of a variable is its value.

7.   Define binding and binding time.
=    A binding is an association, such as between an attribute and an entity, or between an operation and a symbol. Binding time is the time at which binding takes place.

8.   After language design and implementation [what are the four times bindings can take place in a program?]
  • Language design time —  bind operator symbols to operations
  • Language implementation time– bind floating point type to a representation
  • Compile time — bind a variable to a type in C or Java
  • Load time — bind a C or C++ static variable to a memory cell)
  • Runtime — bind a non-static local variable to a memory cell

9.   Define static binding and dynamic binding.
=    Static binding first occurs before run time and remains unchanged throughout program execution. dynamic binding first occurs during execution and can change during execution of the program.

10. What are the advantages and disadvantages of implicit declarations?
=    The advantage is write-ability.

11. What are the advantages and disadvantages of dynamic type binding?
=    The advantage is flexibility (generic program units).

12. Define static, stack-dynamic, explicit heap-dynamic, and implicit heap-dynamic variables. What are their advantages and disadvantages?
=    Static: bound to memory cells before execution begins and remains bound to the same memory cell throughout the execution.
Stack-dynamic: storage bindings are created for variables when their declaration statements are elaborated.
Explicit heap-dynamic: allocated and deallocated by explicit directives, specified by the programmer, which take effect during execution.
Implicit heap-dynamic variables: Allocation and deallocation caused by assignment statements.

13. Define lifetime, scope, static scope, and dynamic scope.
=    Lifetime: A time during which the variable is bound to a specific memory location. The lifetime begins when it is bound to a specific cell and ends when it is unbound from that cell.
      Scope: The range of statements in which the variable is visible. A variable is visible in a statement if it can be referenced in that statement.
      Static scope: is based on program text and to connect a name reference to a variable , you (or the compiler) must find the declaration.
      Dynamic scope: Based on calling sequences of program units, not their textual layout (temporal versus spatial). References to variables are connected to declarations by searching back through the chain of subprogram calls that forced execution to this point.

14. How is a reference to a non-local variable in a static-scoped program connected to its definition?
=    A reference to a non-local variable in a static-scoped language with nested subprograms requires a two step access process:
1. Find the correct activation record instance
2. Determine the correct offset within that activation record instance

15. What is the general problem with static scoping?
=    Usually too much access. Scope structure destroyed as program evolves.

16. What is the referencing environment of a statement?
=    Set of all names visible to the statement.

17. What is a static ancestor of a subprogram? What is a dynamic ancestor of a subprogram?
=    The static ancestors of a subprogram sub() are all the procedures in the program within which the procedure sub() is defined, i.e., the definition of the procedure sub() is nested. The definition of a procedure may be directly nested within only one procedure, called its static parent procedure. However, this static parent procedure may itself be nested within another procedure, and so on up to the main() program. All these procedures are considered to be static ancestors of the procedure sub(). Simply put, the static ancestors are those that strictly contain the subprogram in question.
The dynamic ancestors of a subprogram sub() are all the procedures called before sub() during the execution of a program, that have not yet finished executing. These are the procedures that are waiting for procedure sub() to finish executing before they can terminate. Simply put, dynamic ancestors are those that are called to reach the subprogram in question.

18. What is a block?
=    The storage a variable is allocated when the section is entered and deallocated when the section is exited.

19. What is the purpose of the let constructs in functional languages?
=    “let” introduces a new variable scope, and allows you to bind variables to values for that scope. It is often read as “let x be [value] in …”

22. What are the advantages and disadvantages of dynamic scoping?
=    Advantage: convenience.
Disadvantage: cant type-check at compile time. Poor readability (can’t determine type of a variable statically).

23. What are the advantages of named constants?
=    The advantages are readability and modifiability.

3.0 - QA

1. Define syntax and semantics!
= Syntax is the form of expressions, statements, and program units. Semantics is the description of those expressions, statements, and program units.


2. Who are language descriptions for?
Language descriptions are for other language designers, implementers, and programmers (users of the language).

3. Define a left-recursive grammar rule.
= When a grammar rule has its LHS also appearing at the beginning of its RHS, the rule is said to be left-recursive. Left-recursive specifies left associativity. Unfortunately, left recursion disallows the use of some important syntax analysis algorithms. When such algorithms are to be used, the grammar must be modified to remove the left-recursion. This in turn, disallows the grammar from precisely specifying that certain operators are left associative. Fortunately, left associativity can be enforced by the compiler, even though the grammar does not dictate it.

7. What three extensions are common to most EBNFs?
= The first extension denotes an optional part of a RHS, which is delimited by brackets. For example:
<if_stmt> -> if ( <expr> ) stmt [ else <stmt> ]

The second extension is the use of braces in an RHS to indicate that the enclosed part can be repeated indefinitely or left out altogether. For example: <ident_list> -> ident {, <ident> }


The third extension deals with multiple choice options. For example: <term> -> <term> ( *|/|% ) <factor>


8. Distinguish between static and dynamic semantics.

= Static semantics is more on the legal forms of programs (syntax rather semantics) and is only indirectly related to the meaning of the programs during execution. Static semantics is named because the analysis required to check these specifications can be done at compile time. In many cases, the semantic rules of language state its type constraints.

Dynamic semantics is describing the meaning of the programs. Programmers need to know precisely what statements of a language do. Compile writers determine the semantics of a language for which they are writing compilers from English descriptions 


10. What is the difference between a synthesized and an inherited attribute? = The synthesized attributes are the result of the attribute evaluation rules and may also use the values of the inherited attributes. The inherited attributes are passed down from parent nodes. In some approaches, synthesized attributes are used to pass semantic information up the parse tree, while inherited attributes help pass semantic information down it.
For instance, when constructing a language translation tool, such as a compiler, it may be used to assign semantic values to syntax constructions. Also, it is possible to validate semantic checks associated with a grammar, representing the rules of a language not explicitly imparted by the syntax. 


12. What is the primary use of attribute grammars?
= An attribute grammar is a device used to describe more of the structure of a programming language than is possible with a context-free grammar. An attribute grammar is an extension to a context-free grammar. The primary purpose of an attribute grammar is it allows certain language rules to be described, such as type of compatibility. An attribute grammar is a formal way to define attributes for the productions of a formal grammar, associating these attributes to values. The evaluation occurs in the nodes of the abstract syntax tree, when the language is processed by some parser or compiler. 

15. Describe the two levels of uses of operational semantics!
= There are different levels of uses of operational semantics. At the highest level, the interest is in the final result of the execution of a complete program. This is called natural operational semantics. At the lowest level, operational semantics can be used to determine the precise meaning of a program through an examination of the complete sequence of state changes that occur when the program is executed, This use is called structural operational semantics.

16. In denotational semantics, what are the syntactic and semantic domains?
= The mapping functions of a denotational semantics programming language specification, like all functions in mathematics, have a domain and a range.
the syntactic domain is called the domain because it is syntactic structures that are mapped. The domain is the collection of values that are legitimate parameters to the function; the range is the collections of objects to which the parameters are mapped.
the semantic domain is called the range. 

19. What two things must be defined for each language entity in order to construct a denotational description of the language?
= objects and functions

20. Which part of an inference rule is the antecedent?
= The top part of an inference rule is called the antecedent.

21. When a grammar rule said to be left recursive?
= When a grammar rule has its LHS also appearing at the beginning of its RHS, the rule is said to be left-recursive. This left recursion specifies left associativity.
22. Give an example of an ambiguous grammar.
= <program> →<stmts>
<stmts> → <stmt> | <stmt> ; <stmts>
<stmt> → <var> = <expr>
<var> → a | b | c | d
<expr> → <term> + <term> | <term> – <term>
<term> → <var> | const

23. On what branch of mathematics is axiomatic semantics based?
= mathematics logic

25. What is the problem with using a software pure interpreter for operational semantics?
= The detailed characteristics of the particular computer would make actions difficult to understand. Such a semantic definition would be machine-dependent.

26. Explain what the preconditions and postconditions of a given statement mean in axiomatic semantics.
= An assertion before a statement (a precondition) states the relationships and constraints among variables that are true at that point in execution. An assertion following a statement is a postcondition

27. What is loop invariant? Explain with an example.
= The corresponding step in the axiomatic semantics of a while loop is finding an assertion called a loop invariant, which is crucial to finding the weakest precondition. The loop invariant must satisfy a number of requirements to be useful. First, the weakest precondition for the while loop must guarantee the truth of the loop invariant. In turn, the loop invariant must guarantee the truth of the postcondition upon loop termination. These constraints move us from the inference rule to the axiomatic description. During execution of the loop-controlling Boolean expression and the loop body statements. Hence, the name invariant.

28. What is the use of the wp function? Why it is called a predicate transformer?
= A weakest precondition is the least restrictive precondition that will guarantee the postcondition. It is often called a predicate transformer because it takes a predicate, or assertion as a parameter and returns another predicate.