searchQuick Apprise: THREE #GoogleSummerOfCode #FOSSASIA

The intended “searchQuick” (sQuick) is an application to enable a user to search a set of books or texts, like an encyclopedia, or some other topical book collection offline built in the open source platform Pharo 4.0. After the GUI was designed with minimal features, the next task was to develop the cardinal search function. Indubitably, a well-run search application/engine requires indexing. Search Application/Engine Indexing basically collects, parses and stores data to facilitate fast and accurate information retrieval. That being, the index for sQuick was built using the Dictionary data structure in Pharo which works like HashTable of other programming languages/platforms. index := Dictionary new. Pharo describes a Dictionary as: "I represent a set of elements that can be viewed from one of the two perspectives: a set of associations, or a container of values that are extremely named where the name can be any object that responds to =. The external name is referred to as the key. I inherit many operations from the Set. " The contents of the text files present in the current Pharo image were split at whitespaces and added to the index along with the corresponding file title. tokens := ' ' split: aDocument contents. The method #indexFiles was used to iterate over all the text files in the current Pharo image to index all the files before the searching begins. Dictionary Entries after File Content Indexing The #queryString method has been temporarily build using #includesSubstring which matches the user input string with all the entries of the index and gives the result in an array form with #tally output as the number of search results. Various test methods are now built to inspect the functioning of the methods designed. Continuous debugging is being done to check out and remove errors, if any ;) UPCOMING: Improve the indexing technique Explore methods to quicken the search functionality Integrate the search routine with the GUI already built Design more test cases to develop a bug-free application Stay tuned for more... Post any queries , will be happy to help :)

Continue ReadingsearchQuick Apprise: THREE #GoogleSummerOfCode #FOSSASIA

TicTacToe Tutorial #FunWithPharo

reposted from jigyasagrover.wordpress.com/tictactoe-tutorial-funwithpharo This tutorial has been included as a chapter in  Fun With Pharo! Tic-tac-toe (or Noughts and crosses, Xs and Os) is a paper-and-pencil game for two players, X and O, who take turns marking the spaces in a 3×3 grid. The player who succeeds in placing three respective marks in a horizontal, vertical, or diagonal row wins the game. Because of the simplicity of Tic-tac-toe, it is often used as a pedagogical tool for teaching the concepts of good sportsmanship and the branch of artificial intelligence that deals with the searching of game trees. It is straightforward to write a computer program to play Tic-tac-toe perfectly, to enumerate the 765 essentially different positions (the state space complexity), or the 26,830 possible games up to rotations and reflections (the game tree complexity) on this space. So , here we make a Pharo version of this well-known game by using Morph. This post provides a step-by-step approach on how to go about building this simple application. A game package will be built having 3 subclasses : TicTacToe TicTacToeCell TicTacToeModel Initially , we have created TicTacToe a subclass of the Object class. The subclasses we will make will be combined in the package game as mentioned in the category: parameter. Object subclass: #TicTacToe instanceVariableNames: 'container model' classVariableNames: '' poolDictionaries: '' category: 'game' A category name is not required in order for the class to work, but you will not be able to access the class to make changes or to look at existing code unless you provide a category name. (The category name used can be a new category name or the name of an existing category.) The poolDictionaries: parameter is seldom used and will not be discussed here, and the category: parameter specifies the category under which this class will be grouped in the system browser. As we know, a class encapsulates data values and methods, and every object contains a set of the data values and can receive any of the methods as a message. The data values in each object are specified by providing a set of names of variables whose values will be an object's internal data values. Each object has its own set of these values, and the set of data values for an object represents the object's state (or value). The variables that contain the data values of an object are called the instance variables for the object, and the instanceVariableNames: parameter is a list of names, separated by blanks, for the instance variables. In the above code snippet , we have declared container and model as two instanceVariables. The classVariableNames: parameter lists the identifiers that are the names of variables shared by the class and all of its objects. That is, there is only one set of these, and they are used by the class and all of its objects. Class variables (so called because they belong to the class, of which there is only one, rather than to the objects that are…

Continue ReadingTicTacToe Tutorial #FunWithPharo

Starting with Smalltalk, Pharo and Spec

It’s been a few weeks since I started with Smalltalk, Pharo and Spec. Under the guidance of Mr. Martin Bähr, Mr. Sean DeNigris and people from the #pharo community (@thierry, @kilon, @maxleske) I have been able to learn Pharo in a systematic way. I have implemented the knowledge gained by building a few simple desktop applications using the resources available online. This post intends to clear all your doubt regarding the basic definitions of Smalltalk, Pharo and Spec. GETTING THE BASICS CLEARED Smalltalk is an object-oriented, dynamically typed, reflective programming language. It was designed and created in part for educational use, more so for constructionist learning. The language was first generally released as Smalltalk-80. A Smalltalk environment is its own little world, designed around a conception of a computer with a minimal operating system and populated with living objects. A Smalltalk implementation is composed of an image (binary code), a major source file and a 'changes' file. The image is called Virtual Image (VI) because is independent form the platform you use for running Smalltalk. Smalltalk systems store the entire program state (including both Class and non-Class objects) in an image file. The image can then be loaded by the Smalltalk virtual machine to restore a Smalltalk-like system to a prior state. As Sean DeNigris wrote to me: “You may not realize it, but you have opened a portal to some of the greatest minds in the history of our industry. You have in your hands, not a programming language, but a live, dynamic, turtles-all-the-way-down environment designed to provide 'support for the creative spirit in everyone'. More practically, Smalltalk is a programming tool that allows productivity unimaginable in most systems. And, if you put in enough time and effort to actually think in it, it will help you program better in any language you use.” ; Smalltalk is more dynamic and powerful than what one can think of. Pharo is an open source implementation of the programming language and environment Smalltalk. Pharo is not Smalltalk. Pharo is Smalltalk-inspired. Pharo offers strong live programming features such as immediate object manipulation, live update, and hot recompilation. Live programming environment is in the heart of the system. Pharo also supports advanced web development with frameworks such as Seaside and more recently Tide. The official Pharo website defines it as: Pharo is a pure object-oriented programming language and a powerful environment, focused on simplicity and immediate feedback (think IDE and OS rolled into one). Pharo relies on a virtual machine that is written almost entirely in Smalltalk itself. Spec is a simple framework for describing User Interface (UI) for Pharo Smalltalk. It takes a model and a layout description, runs it through an interpreter and a UI is produced as a result. All the widget implemented this can then immediately be reused as any other widget. It also allows the separation of concerns between the different parts of the user interface as expressed in the MVP pattern. Spec emphasis the reuse of the widgets as…

Continue ReadingStarting with Smalltalk, Pharo and Spec