This week I had the chance to go into more depth on the material design principles and I must say that the design itself is awesome. So, I got started building the user interface of our event app.
After looking at a lot of apps. I decided to make a recycler view list of cardviews. Cool right? Looks awesome too. I did this by put an imageview, relative layout and a linear layout in a linear layout. In the second linear layout I added the textviews for the position, organization. Finally the description textview was added in the relative layout. This is how I designed the card layout. Now for the recycler view of cardviews, I added cardview layout to the recycler view adapter to make the list of cardviews.
I also wrote unit tests for the database this week as suggested by Mohit. At first, they were failing and since I didn’t have any experience writing tests for databases, I wasn’t able to debug them. So, I took help from mohit who ended up identifying the problems which was arising due to the singleton in the database. Apparently, You can’t use singletons in a test because we don’t control the creation of the singleton object, as it is performed inside a static method. There is no way to mock the object in order to test the behavior of our method in isolation. So for now mohit has used dependency injection to make the tests work but I am working on a way to remove the injection.
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 🙂
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.
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 instances of the class) are rarely needed.
An example of a class variable that could be useful is in a case where we wanted a unique “serial number” to be assigned to each instance of the class as it is created. The variable containing the next available (or last used) serial number would appropriately be a class variable, and each time a new instance (object) is created the serial number would be recorded as an instance variable value in the object and the serial number in the class variable would be incremented. Thus, each object can be serially numbered as it is created (without using one of those nasty global variables!).
After executing the code above, class TicTacToe will exist. However, it will have no methods other than those that are inherited from class Object. To make it useful, we must add the methods that are needed for our implementation.
Adding methods to classes :
The subClasses interact by passing messages through objects only.
The notation TicTacToe>>#initialize means that we have a method named initialize in the subclass TicTacToe.
In the initialize: method above , we have a container which is the instance of the class Morph (Morphic is the name given to Pharo’s graphical interface. ). We define the various attributes of the container such as layoutPolicy: and color:. model is another instance of the class TicTacToeModel which we will be creating further in this example.
self refers to the receiver of the message. It is usually used within a method to send additional messages to the receiver. self is frequently used when it is desired to pass the sender object (self), as a message argument, to a receiver who requires knowledege of the sender or who will in some way manipulate the sender.
In short, self refers to the object itself that defines the method.
The method addRows (the name is self explanatory) is used to add rows in the Tic Tac Toe grid. It declares temporary (local) variables rowMorph , aCell and rowCol which can’t be used beyond this method.
1 to:3 do:[ :row |
rowMorph := Morph new layoutPolicy: RowLayout new.
1 to: 3 do: [ :col |
aCell := TicTacToeCell new.
aCell setModel: (model) row: row col: col.
rowMorph addMorph: aCell.
].
The above code snippet works as a nested loop that runs thrice for each three rows to create a 3X3 grid as per requirement.
This method adds controls to the game. The local variables are : rowMorph , newGameButton and exitGameButton.
rowMorph defines an instance of the class Morph which would be the placeholder for the two control buttons located at the top. The two control buttons are defined as New using the variable new GameButton which on click would restart the game , and Exit using the exitGameButton which on click would close the game. The buttons are created using a method createCtrlLabelled which we define next.
rowMorph addMorph: newGameButton adds the button to the Morph instance created earlier.
TicTacToe>>#createCtrlLabelled: aString onClickExecutes: aBlock method makes a simple button using Morph adds label and control to it.
The open method defines as to how the game/TicTacToe class would open. Here we have defined it to open in a dialog box.
It closes the game and calls for Garbage Collection (Garbage Collection (GC) is a form of automatic memory management. It finds data objects in a program that cannot be accessed in the future and reclaims the resources used by those objects.)
Here a subclass TicTacToeCell is defind in the SimpleButtonMorph class with parentModel , rowNum and colNum as the instance variables. This class defines the button for each cell of the grid.
This initialize method initialises the button size as 80X80 and gives it the color: yellow. An ‘onClick’ control is given to the button which then calls the onClickExecutionBlock method present in the same class.
The setModel: row: col: takes three arguments ticTacToeModel , aRow and aCol. The parentModel is assigned ticTacToeModel , roNum becomes the value of aRow and similiarly colNum has the value aCol.
This method defines what should happen when each cell in the grid is clicked. At every click , the label of the cell is changed to X or O depending upon whose turn it is , the row numbers and coloumn numbers are updated in the parentModel and win condition is checked by calling the checkWinCondition method of the class TicTacToeModel defined next.
A subclass TicTacToeModel is defined in the Matrix class with filledCellCount , currentFill and winner as the instance variables.
This initialize methods defines that initially no cell in the grid is filled and there is no winner as of now.
The updateRowAt: Col: method takes two arguments r and c used to update the currentFill and filledCellCount variables.
The method checkWinCondition is self explanatory. It is used to check if we have a winner or not at every move.
.
Now , we have made the game. To open the game , simply execute the following in the playground/workspace.
The messages : ‘Yes’ , ‘Player x is the winner’ will be displayed in the Transcript.
PS – This was just the basic implementation. I plan to improvise it further with graphics and other functionality/features.
Do like the post if it was helpful.
For any queries/suggestions please comment below.
I am enjoying this a lot. It has been a wonderful experience till now working with all my team members and my mentors. I mean I am learning something new everyday. Like I have learned squashing git commits using rebasing and pushing, which I am using a lot now. I am also following a code review policy suggested by mohit where I push to a new branch on my fork and then create a PR, after which mohit reviews my code and then merges it. This is a very nice practice and I think that every open source developer should follow such practices to get the best quality code out there.
Moving on, this week I was mainly working on implementing the UI for the app. For this I studied layouts of various apps and came out with what I though was best. So I though I should implement the Tracks Fragment First where I add all the tracks I have updated inserted into the database in a recycler view. I take up a very basic layout for now just showing the track name and description.
I also added the sponsor fragment where I have used Picasso by Square Inc. to download the Logo images and displayed them in a recycler View. Here also I researched various options to download the Sponsor Logo images and I come up with one clear winner : Picasso. We can resize image, load from URL’s,drawables etc. all in just one line of code.
I also added the speaker fragment in which I used a bit complex layout as I had to get the speaker image, name, designation and description all in one recycle view ViewHolder. So after some hiccups I managed to get it right. I used Picasso here as well for the speaker Image. Although I still have to add further details to this fragment and the others. I’ll do so in this week. I am planning on adding some material design with some clickables for different holders. I have also started to work on a list of cardviews as well.
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 building various mock-ups for a user friendly graphical interface for the application, the rudimentary features which would be present in the first release were finalized.
The chief features would include :
Search for word(s)
Browse files in the current image
Help or Tutorial
About section
Feedback or Suggestion Aid
Explore the code ( Cardinally Open Source 😉 )
LATEST MOCK UP OF GUI FOR sQuick
At this moment, the most viable options available (apart from the use of GTSpotter,Rubric or Bloc suggested by developers on the forum and #pharo IRC) include:
The use of Spec to build the UI which provides a comparatively easier option to implement Button Click Actions, User Input Search String Retrieval etc. But the graphical interface designed by placing the widgets is not a very fancy one and dependent on the current theme of the image.
The Morphic GUI gives the application a very pretty look in comparison, however the user input search string retrieval method is not a straight-forward one and is under construction.
After considering various pros and cons, the suitable alternative is considered to be the one made with Morph as it gives a refreshing look to the application.
UPCOMING:
Completion of GUI development
Commencement of Index build
Stay tuned for more… Post any queries , will be happy to help 🙂
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
Smalltalkis 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.
Pharois 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.
Specis 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 well as their customization.
I hope now you have got the classifications of Smalltalk , Pharo , Spec all cleared up which remains a basic doubt in every beginners mind.
INSTALLATION GUIDE
Visit the official Pharo website’s download tab to get the desired version of Pharo for the corresponding OS.
For a step by step tutorial describing various ways to install Pharo in your system visit the ‘Installing Pharo in many flavors’ blog written in a very systematic manner by Guille Polito.
Follow the steps as given in Spec Documentation to install Spec in a Pharo Image.
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.
In the inceptive coding period of this project development the tasks achieved are as:
Designing the basic graphical user interface using Morphs in Pharo 4.0. The morphs elements utilized to make the interface elements included: – TextMorph for labels etc.
– PluggableTextMorph to display the contents of the file
– ImageMorph for background, header GIFs etc.
– TextMorphForEditView to enter the search string.
– SimpleButtonMorphs for creating buttons whose click will perform the desired action.
– MenuMorph , MenuItemMorph to make the list of files available as ‘Browse’ menu.
– DropListMorph to make a drop down list menu for the selection of languages.
Loading the files in the current Pharo image and making methods/classes that would directly access those files from the image and display their names as a menu list
Making a Metacello Configuration of the project for easy project loading in Pharo.
For further ease, the project configuration was directly added to the Meta Repo of Pharo 4.0 at SmalltalkHub.com and now the project can be directly loaded through Configuration Browser in Pharo 4.0
World > Tools > Configuration Browser > sQuick(jigyasa)
Removing the cache of the instance of the MainInterface so as to allow the users to open up many search/content windows simultaneously
Making of a content window that would display the file name and the file content when the file name is clicked from the ‘Browse Files‘ menu
Designing mock-ups for the UI for an enhanced user interface which include the latest search engine feel
UPCOMING:
Augmenting the UI for a pleasant user experience
Initiate working on the search tool / indexer build.
Stay tuned for more… Post any queries , will be happy to help 🙂
We often get the question, how can I join the community. There is no official membership form to fill out in order to participate in the Open Tech Community. You simply start to contribute to our projects on GitHub and you are already a member. So, let’s work together to develop to develop social software for everyone!
The FOSSASIA team welcomes contributors and supporters to Free and Open Source Software. Become a developer, a documentation writer, packaging maintainer, tester, user supporter, blogger or organize events and meetups about our projects.
Women in IT discussion in the community
Here are some ideas how we can collaborate
Download our Open Source applications, install them and use them
The first step of joining a project is always to download the software and try it out. The best motivation to support a project is, if the project is useful for yourself. Check out our many projects on github.com/fossasia and our project social media Open Source search engine on github.com/loklak.
Show your support and ★star FOSSASIA projects
Help to motivate existing contributors and show your support of FOSSASIA projects on GitHub. Star projects and fork them. Doing something that people like and that helps people is a great motivation for many.
Learn about best practices
We have formulated best practices for contributing to Open Source to help new contributors to get started. Please read them carefully. Understanding our best practices will help you to collaborate with the community and ensure your code gets merged more quickly.
Subscribe to news
Subscribe to the FOSSASIA Newsletter to stay up to date on new software releases, events and coding programs here on the main page.
Read the blogs and support users on the mailing list
Show us you interest in FOSSASIA’s Open Technology and keep up to date on new developments by following us on Twitter and retweeting important updates: twitter.com/fossasia
Join and support the FOSSASIA network at community events
Set up a booth or a table about FOSSASIA at Open Source community events! There are many events of the open source community all over the world. The core team of FOSSASIA is simply not able to attend all events. You can support the cause by making the project visible. Register as a member of the FOSSASIA community at events, set up an info point and showcase Free and Open Source projects. Check out for example FOSSASIA event calendar calendar.fossasia.org or our meetup group in Singapore: meetup.com/FOSSASIA-Singapore-Open-Technology-Meetup
Translate our projects and their documentation
Do you speak more than one language? Most Open Tech projects are 100% volunteer translated, which means you can be part of a translation team translating software and documentation thousands of people will use. Start now and check out our GitHub repository.
FOSSASIA 2015 in Singapore has been a fantastic success. Thanks to everyone who helped to make this event possible! We would also like to thank all sponsors, venue partners and our main supporters Red Hat and Google. FOSSASIA 2016 will take place from March 18-20 in Singapore. Below are some numbers and facts of 2015 now, some info about ‘What’s Next in 2015’ and our FOSSASIA GSoC program with 5,500 USD stipends for students (Deadline 27 March. Apply now).
FOSSASIA’15 NUMBERS & FACTS
We had 128 speakers from 27 countries and 900+ attendees. 37 volunteers supported the event.
There were 142 scheduled sessions and lightning talks, and 58 breakout and unconference sessions.
Dozens of talks are already available as videos. Thousands of photos have been uploaded to social networks. 1500+ tweets with the FOSSASIA hashtag were posted during the event.
Other keynotes included Lennart Poettering with systemd; Bunnie Huang gave insights to Open Hardware Development; Colin Charles about the future of MariaDB, and Gen Kanai talked about developer engagement at Mozilla.
“Build your own minimum viable Internet” was a hot topic at the event set by Harish Pillay as well as the Internet of Things and enabling local production with digitization of machines like knitting machines.
A first trend analysis of FOSSASIA shows that Python continues to receive increasing attention of developers and DevOps topics attracting a lot of interest.
WHAT’S NEXT IN 2015
Due to the large interest in DevOps at FOSSASIA we are teaming up with Red Hat to bring you some free Open Stack webinars including a 3-webinar series to learn how PaaS partnered with DevOps can improve application time to market. Please follow this link for the free webinar.
And: DevOps can also join a free webinar to learn about the Keystone identity service, which is part of the OpenStack Platform.
FOSSASIA is a mentor org for Google Summer of Code 2015. We are looking for students who would like to develop for Open Source projects and receive a stipend of 5,500 USD. We are particularly looking for mobile app developers and software developers for Open Hardware and the Internet of Things. Please check out our ideas list here: http://labs.fossasia.org/ideas and sign up before March 27 on Google Melange.
Students from all around the world aged 13-17 years old worked with mentors of FOSSASIA on improving open source software during the 7 weeks the contest is run. They coded programs, designed artworks, tested software and more than anything else had fun.
174 students managed to complete at least one task with FOSSASIA and 43 out of them claimed a cool t-shirt from Google by completing 3 or more tasks.
Out of the 10 students who completed most number of tasks finalists and grand prize winners were picked collectively by FOSSASIA’s 24 mentors. Namanyay Goel and Samarjeet Singh won the grand prize, which is an all expense paid trip to Google HQ in Mountain View, California. Alvis Wong, Amr Ramadan and Tymon Radzik emerged as finalists. Congratulations finalists! Safe travels grand prize winners! We are thankful for your precious contributions and will be delighted see you continue to contribute even after the program.
Open source projects ExpEYES, sup, TiddlySpace, p5.js among few others, benefitted from FOSSASIA students’ work. More than 150 open source/ open tech projects and communities around asia were connected to FOSSASIA with the help of students. Students also worked together to build a nice website portraying students and mentors.
We would like to thank all participated students for the amazing interest they showed in our tasks. Its great to see some of them still hang around to help us. 24 mentors of FOSSASIA worked hard and stood up to the challenge of finding time to work with and help out students while having other obligations. Thank you mentors! Lastly we are grateful to Stephanie Taylor and Co. at the Google OSPO, for organizing the wonderful contest.
You must be logged in to post a comment.