Labels

algorithms (22) Design Patterns (20) java (19) linux (14) Snippet (13) service mix (6) soa (4)

Pharo programming environment

Smalltalk and modern graphical interfaces were developed together
Let us see all  the main tools in Pharo:

  • The Browser is the central development tool.we can use it to create,define, and organize your classes and methods. Using it you can also navigate through all the library classes.In this all the classes and methods are contained in the image.
  •  The Message Names tool is used to look,all the methods with a particular selectorwith a substring.
  •  The Method Finder tool is also same like msg name tool
  •  The Monticello Browser is the starting point for loading code from, and saving code in, Monticello packages.
  • The Process Browser provides a view on all of the processes (threads) executing in Smalltalk.
  • The Test Runner lets you run and debug SUnit tests,
  • The Transcript is a window on the Transcript output stream, which is useful for writing log messages .
  • The Workspace is a window into which you can type input. It can be used for typing Smalltalk
    expressions and executing them as do it s. 
  • The Debugger has an obvious role, when compared to other programming lang..Smalltalk you can program in the debugger. The debugger is
    not launched from a menu; it is normally entered by running a failing test,
    by typing CMD–. to interrupt a running process, or by inserting a self halt
    expression in code. 

Composition Vs Aggregation

Composition vs Aggregation

 


  1. Composition and Aggregation are almost the same 

  2. composition the contained objects do not exist independently in                                case of the above example the Heart cannot exist without the person.

  3. Aggregation the contained objects can exist independently like 
    Money exists without a person.

Sending messages and Saving, quitting and restarting a Pharo session

  •  Open a workspace. Type in the following text:
                  "BouncingAtomsMorph new openInWorld"

Now action-click. A menu should appear. Select do it (d) .
  • A window containing a large number of bouncing atoms should open inthe top left of the Pharo image.
  • You have just evaluated your first Smalltalk expression! You just sent the message new to the BouncingAtomsMorph class, resulting in a new BouncingAtomsMorph
  • The BouncingAtomsMorph class decided what to do with the new message, that is, it looked up its methods for handling new message and reacted appropriately.
  • Similarly the BouncingAtomsMorph instance looked up its method for
    responding to openInWorld and took appropriate action.


Saving, quitting and restarting a Pharo:
  • Select World . Save as . . . , enter the name “myPharo”, and click on the OKbutton. Now select World . Save and quit .
  • Now if you go to the location where the original image and changesfiles were, you will find two new files called “myPharo.image” and “myPharo.changes” that represent the working state of the Pharo image at the moment before you told Pharo to Save and quit . 
  • If you wish, you can mov these two files anywhere that you like on your disk, but if you do so you may
    (depending on your operating system) need to also move, copy or link to the virtual machine and the sources file





  • When you start Pharo for the first time, the Pharo virtual machine loadsthe image file that you provide. This file contains a snapshot of a largenumber of objects, including a vast amount of pre-existing code and a largenumber of programming tools (all of which are objects). 
  • As you work with Pharo, you will send messages to these objects, you will create new objects,and some of these objects will die and their memory will be reclaimed (i.e.,garbage-collected).
  • When you quit Pharo, you will normally save a snapshot that contains allof your objects. If you save normally, you will overwrite your old image filewith the new snapshot.
  • Alternatively, you may save the image under a newname, as we just did.In addition to the .image file, there is also a .changes file. This file containsa log of all the changes to the source code that you have made using the standard tools.











Apache Service Mix

To install service mix

Download service mic from this location

http://servicemix.apache.org/download.html

extract to a directory and run servicemix.bat

JBI Components

    1. Binding Components (BC) :
      1. To communicate using remote protocols .
      2. To normalize/denormalize messages it receives .
      3. they are additional transport to the container.
    2. Service Engines (SE):
      1. some type of logic inside the JBI environment and only communicates with the NMR. If a SE needs to communicate outside the JBI environment, it must send a message to a BC.
      2. To add another type of business logic to the container
    3. Service Assemblies:
      1. Is a collection of BCs and SEs.

HELLO WORLD Pharo

Now let us do some simple programs in pharo..
first we shall start with hello world program

As soon as pharo open it wil luk lik dis...




Nw type yhe following "Transcript show:'Hello World' " in the work space window.. nw see the result in transcript window.




Basics Of XSL

 

 

     
    <xsl:template> is a set of rules to be applied when a node is matched
    match="/"          is used along with the template tag to specify on which node to apply the template on , if it is “/” it has to be applied on the entire document.
    <xsl:value-of> used to get the value of a tag.
    <xsl:for-each> used to iterate over a list of nodes
    filter the output  
    <xsl:sort>       used to sort the nodes based on a tag
    <xsl:if> used to test the condition on a node
    <xsl:choose>  
    <xsl:when>  
    <xsl:otherwise>  
    <xsl:apply-templates>   

Sample XML

<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
</book>
<book id="bk103">
<author>Corets, Eva</author>
<title>Maeve Ascendant</title>
<genre>Fantasy</genre>
<price>5.95</price>
</book>
</catalog>



XSL To Transform

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:template match="/">
<table border="1">
<tr>
<td>Title</td> <td>genre</td> <td>author</td> <td>price</td>
</tr>
<xsl:for-each select="/catalog/book">
<xsl:sort select="title"/>
<tr>
<td>
<xsl:value-of select="./title"/>
</td>
<td>
<xsl:value-of select="./genre"/>
</td>
<td>
<xsl:value-of select="./author"/>
</td>
<td>
<xsl:if test="price &gt; 10">
<font color="Red"></font>
</xsl:if>
<xsl:value-of select="./price"/>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>



Output


 























Titlegenreauthorprice
Maeve AscendantFantasyCorets, Eva5.95
Midnight RainFantasyRalls, Kim5.95
XML Developer's GuideComputerGambardella, Matthew44.95

How to work in PHARO

  • Pharo is available as a free download from http://pharo-project.org. There are
    three parts that you will need to download, consisting of four files.
                                      Pharo virtual machine.(pharo.exe)
                                      Pharo shared sources(squeakv.sources)
                                      Pharo.image
                                      Pharo.changes
  • After downloading drag n drop pharo.image file on the pharo icon..        

What are Squeak and Pharo?

  • Squeak is a modern, open-source, highly portable, fast, full-featured Smalltalk implementation Based on original Smalltalk-80 code                                      
  •  Pharo is a lean and clean fork of Squeak
                           www.pharo-project.org




                                                                                                   

History of smalltalk


Search 24 Bytes

Loading...