Tuesday, March 9, 2010

Ironing Board Cover 140 X 40

Vipera IDE now on svn

This article begins with a series of posts that is a topic very timely and useful. The vastness of the sea in which we are about to sail would need many, many pages of this book I decided to break up into several parts to the discussion.

The use of state machines seems to me important in the planning system, especially when it comes to services.
What happens when we meet the state machine Go? But let

"dall'incomincio" here is an example of a simple state machine (and a bit 'useless) but does understand what are these mysteries.
<-routineQuit // blocks until quit is written to



This concept is very useful when programming object. As we saw in the previous article, the language has Go items. We create our object then around to the internal state which for convenience will contain only the index of the state in which we live.

type InternalState
myState struct {int;}

If we take that as a model in the picture above the internal state InternalState must be initialized, then go in the state 1 and then before finishing second in the state.

then compose in this way the function that will initialize our state machine:


func (state InternalState *) Init (inputValue int) { state.myState = inputValue;}



We will then need two functions for each state, a performing entry and exit:
  func (* been InternalState) Stato1_Entry () {

}
func (* been InternalState) Stato1_Exit () {

}

func (* been InternalState) Stato2_Entry () {
}  
func (* been InternalState) Stato2_Exit () {

}


 In the next post we will see how to combine all the components instead just created to pass the object's state from the initial to the final passing through intermediate states.  
I also hope to have put some flea in his ear to examine a very interesting topic.


Monday, March 1, 2010

Trailler Mario Salieri



Before starting to talk about the subject of this post let me make a small celebration for the 200th post on this blog. Lately I've slowed down the frequency of updates, but I hope to have increased the quality.

I think one feature that did turn up their nose to many is the lack
the keyword in the language class
Go
At first this illustrious absence might suggest the absence of the concept of object instead is very present and very helpful. But let

in order:


1) Definition of new types

Go allows you to define new types with the keyword type.

File type struct {
fileName [] bytes, / / \u200b\u200bName of the file
sizeInByte int, / / \u200b\u200bSize of the file
path [] bytes, / / \u200b\u200bLocation of the file on hd

In Thus we have associated with the file structure of a new type that from now on will have the attributes described herein.
2) Definizione di nuovi metodi

Creare nuovi metodi che eseguano del codice è molto semplice.

func PrintAll() {
fmt.Printf("All");
}
    


3) Associare i metodi ai tipi

A questo punto perchè non provare ad associare il metodo PrintAll al tipo File in modo che stampi tutti gli attributi di File quando viene invocato?
Si deve quindi dire al metodo PrintAll che eseguerà operazioni solo sul tipo File.


func (f * File) PrintAll()
{ fmt.Printf(&quot;Filename: %s\n&quot;,f.fileName); fmt.Printf(&quot;Size: % D \\ n ", f.sizeInByte)
fmt.Printf (" Path:% s \\ n ", f.path);}
  


4) instantiate a new File
This will can then instantiate a new file object and invoke its method.

filePtr: = new (File) / / * File filePtr.fileName = "Useless.txt"
filePtr.sizeInByte = "1024";
filePtr.path = "$ HOME";
 / / Call method  filePtr.PrintAll File (); 



---------------------------------- --------------------

The argument is obviously much larger in this post but I wanted to give an introduction to using only the objects within Go to the most skeptical.
Soon we will also talk about interfaces but leave before we get all the prejudices that come from other languages \u200b\u200bas Go addresses these issues from another point of view.