Starting a new project: TheQuestion

Hey all!methodology_diagram

Long time has passed since my last post. Maybe that’s because I have been very busy with school, work and a new project I will present now.

You will follow some moves that me and my team will make, from creating this new product up to deploying it and showing this to the world.

Nowadays I’m coursing in college a discipline about creating a startup using the Lean method, which has been very used last years and was detailed in the Eric Ries’ book, The Lean Startup.

Some strategies we’ll took are lean strategies, that will help us validating our hypotheses and take decisions that will cost less money and time.

For you that have an entrepreneur head, this article may be interesting. We will detail our journey to create a new product, test and validate it with customers, elaborate strategies and search the success at all.

Introducing TheQuestion

The project is called (by now) TheQuestion, which is a quizz game played by many people at the same time. The person pays to enter a tourney and then answer some questions and, if it has a good performance she will receive some money.

Our bigger hypothesis is that people would play quizz games for gaining some money. TheQuestion has a game mode to play without money too, just for fun. But we won’t focus on that in this blog.

We base our game in the PokerStars way of gaming. There are lots of kinds of tournaments, with different prices, capacities and themes. The person register in a tournament and when it reaches the capacity, the tournament starts!

Where do we are

By now, we already have implemented big part of the product. It’s a web application and the game dynamics are all implemented, resting just some bugs to (find and) fix.

Some adjacent functions are ready too, such as user preferences, passwords, privacy and history of games played. This adjacent stuff is not very important for our next step, because before of making big efforts we have to create something small with value, validate it and then improve it. We have to avoid expenses according to the Lean Method.

Next step

As a principle of the Lean Method, we will test it with some people. “GET OUT OF THE BUILDING”, they say. We will put some people to play the game, which is almost done and working the necessary. We will provide some “money” (maybe chocolates or candies, just to symbolize money) for the players, then we will see a dispute climate between them.

This kind of test is really helpful, because it gives us feedback about our product and, more important: it help us to validate if our hypothesis that people would play quizzes for money is correct and if we should persist or pivot in this idea/product.

I will write the results of this test and what decision we’ll take.

See ya!

Advertisements

About JSP #1

Today we’ll talk about JSP, which is nothing more than language like PHP.

With JSP you can put server code into your web page, you can build a web page and everything else you can do with PHP.

Now we’ll see some directives that help us to code in JSP.

The include directive

As the name says, you use this directive to include some file to your current page. It’s very useful if you have replicated code (another jsp page) which must be in lots of pages.

Example:

<%@ include file="../include.jsp" %>

The page directive

The page directive has many utilities, so we’ll cover the most important ways of using, like using the import way. If you want to use in jsp some class you implemented in your project, you have to use import in you jsp file (it’s like the import in Java).

Example:

You want to use the class Person in your jsp. So you do:

<%@page import="com.project.Person"%>
<!-- Now you can use your class Person -->
<%
    Person person = new Person();
    person.setName(“Jacob”);
%>

The page directive can also defines some properties of your page, like the encoding type and content type. Like the default that comes in Eclipse:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

It’s very easy to use, so don’t be afraid to use that.

For more information, see this link .

Next topic we’ll see how to merge HTML and JSP, showing values computed in JSP directly in HTML. See yah!

Small things: For Each in different languages

In web programming, a lot of times you will have to handle lists or other types of collections, passing through the collection and doing whatever you want to do with the collection’s elements. There are some ways to do that, so I will tell one way I use a lot and it’s very simple to use, besides being an elegant way of programming.

I use the forEach iteration.

Let’s see an example in Java:

Supposing we have a very simple class called Person.java

public class Person {

    private String name;

    private Integer age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }
}

And we will iterate over a list of Persons (personList):

// supposing we have a list of Persons (List<Person>)
if(personList != null) {
    for(Person person : personList) {
        System.out.println("Name: " + person.getName());
        System.out.println("Age: " + person.getAge());
    }
}

It’s always a good practice checking if the list is not null, to avoid java.lang.NullPointerException.

Let’s see an example in jsp:

In jsp, let’s suppose that we will receive a list of Persons, just like the above example. The list is called personList (List<Person>).

In jsp, to iterate over a list loop we can use a core tag lib called forEach.

<c:forEach var="person" items="${personList}">
    <c:out value="${person.name}"/><br/>
    <c:out value="${person.age}"/><br/>
<c:forEach>

In the above code we show all Persons. We use the core tag lib out to print the data from each object in the list. The personList and its’ objects ate caught via JSP Expression Language.

Let’s see some examples in Javascript:

In javascript we can iterate over an array, using a Javascript’s own commands. This link is a StackOverflow question/answer which covers that.

Another way to do this is using jQuery, which has a command to iterate over arrays. See this link to learn more about jQuery .each().

That’s all folks!

I hope I helped somebody using forEach way to iterate over lists/collections. Any doubt, I’m ready to solve your problem! Thanks!

Starting with Maven!

This tutorial will teach you important things about Maven, a powerful program to help you to organize your project and handle your project’s dependencies.

Maven – What is

Basically Maven is a very useful program for medium/large projects written in Java that helps you in basically 2 things that are more interesting to us:

  • Project organization

  • Dependencies manipulation

We’ll talk about each of the above things soon.

Maven is practically required for big applications and big enterprises have to use that because it optimizes certain project processes.

Fortunately, today Maven comes already integrated with Eclipse, so you don’t even need to install it! Only use and be happy! =)

Project Organization

When you open Eclipse, you can create a lot of kinds of projects without using Maven. You can create a Java project, to create applications that run as Desktop programs. You can also create a Web project, which interests to us.

Web project

The Web project supports codes written in Java, HTML, CSS, Javascript… This project runs in a server, such as Tomcat and the interface appears in the browser. Ok. You can also save things in the database. Ok.

What happens is that Web project Eclipse offers to you is in fact very rudimentary. Ancient web applications written in Java were like that (called Java EE with Java Servlets). This project format left the its organization a mess. Its what we want to avoid, since we want to create a project that will be easy to understand in the future, even for your business’s new employees.

Therefore, we will create a Maven Web project, which will come with everything separated in your correct place, everything organized in its structure. We’ll see that soon.

Dependencies manipulation

Dependencies

A dependency is nothing more than a .jar file, which is like a Java project compressed and you can use in your own project, like a library. Let’s see an example:

Last month you created a project that raffled random numbers (any project…). Today you want to create another project, but you want to use the later platform that you implemented (about random numbers raffle) in your new code. You don’t need to put all the files from old to the new project, you can simply compress your old code in a .jar and add it to your new project. Your project will be able to instantiate your the old classes and call its methods.

And that is very important. Dependencies are nothing more than libraries. For example, to execute operations in an image, we can use some library that make images processing and for that we need to add its .jar in our project. The same thing happens with Hibernate for example, which helps handling database stuff: we need to put the Hibernate’s .jars in our project to can use that.

Where does Maven enter in this history?

Maven helps you to handle these dependencies.

These dependencies are often global and lots of people use them, like Hibernate, Spring, MySql… And those dependencies have differences about version. Downloading these dependencies often is well painful, since finding the .jars up to finding the .jars with compatible versions.

With Maven, you only need to add some lines of XML code in your pom.xml and it finds the library for you and leave it ready to use in your project.

PS.: Maven finds dependencies which are registered in its repository. So, the big enterprises put its dependencies in Maven repository. A lower library, not too known, probably won’t be in Maven repository. In that case you can’t use Maven to import that library. It has to be done manually, adding the .jar files.

Next

Next we will learn how to create a Maven Web project in the Eclipse!

Creating a website: what to learn, what to do?

In this post I’ll will tell you people how you can start creating your website. This post is specially for people who don’t know even how to start, what to study, etc. I ensure you if I had read this kind of text before learning about creating websites, I would learn more easily, for sure. So, the steps detailed below will help you to be a webmaster, who knows… =)

Let’s start!

Creating a website (specially modern websites) require you to know significant amounts of knowledge, in several areas, such as the Graphic part, responsible to show the content you want. There are important areas I’ll comment here, and some stuff you need to learn …

HTTP Protocol notion
For the start, it’s necessary to know how websites usually behave, mainly the Client/Server and Request/Response models, where HTTP is based. A brief notion of how it works is very important and very simple. In summary, basically there is an interaction between the client (user accessing the website) and the server (space where the website is placed) and all communication between those parts is done making a request (from client to server) and receiving the respective response. For example, if you type www.google.com in your browser, you’ll make a request to Google server, which will answer with Google webpage. (Actually there are lots of other things behind this process, but it is the most important now…)

Here there are good links that can help you to understand the HTTP protocol and the Client/Server model.

Client/Server model:  http://compnetworking.about.com/od/basicnetworkingfaqs/a/client-server.htm
HTTP protocol:
http://geekexplains.blogspot.com.br/2008/06/whats-http-explain-http-request-and.html

Graphic Part (view)
In this part we are concerned to show the information to the users. It’s the most basic thing in web development. Here you build your interface, set fonts and colors, create menus, show images, etc. To do that you need to use some programming languages that will help you doing this kind of job. Basically, you can use HTML, CSS and Javascript, which are detailed below:

  • HTML: markup language, based on tags (if you press your mouse right button, and select the “View Page Source” option, probably you will see this kind of organization. It defines your document, your webpage.
  • CSS: it’s used to apply styles to your HTML. Using pure HTML makes your webpage very limited, so you have to combine both to ensure a good user-friendly interface, with beautiful resources, which is going to attract more users to website.
  • Javascript: this language is capable to do lots of things. With this you can turn your page more dynamic, and add some good effects, such as fade-in and fade-out or a slide menu. You can use the pure Javascript or use some library that has ready functions you can use, such as JQuery and ExtJs. I suggest you to first learn Javascript and after learn some library, such as JQuery (powerful and free). The Javascript language itself is quite wide and a bit confused. But it’s’ very important and useful.

Start creating HTML with CSS documents, trying to make a beautiful webpage. Then, try some little Javascript scripts embedded in your page, to learn how it really works.
You can find good tutorials all over web, but I recommend this website (http://www.w3schools.com/), which is a refference for those languages cited above.
Nowadays, there are more technologies available that can help you making good interfaces, such as HTML5. But starting with the basics, you will be able to learn the newest technologies more easily.

Server:
To run your website you need a server to place it. There are many servers available on the internet and it depends on the language you’ll use to develop your website. For example, in this part you can use PHP, Java, C#, Python, and other languages to make the server side. For each of those languages there are many servers you can choose, such as Apache for PHP, Tomcat (which is a Apache foundation project) and Jetty for Java, etc.
I don’t indicate a specific language to learn, because each language has good points and off course the bad points. Make a search for which language to use and you have to choose the one you have more affinity.
The server is responsible to handle the requests from users and send the response to them. The server gets the request, execute some logic (a login for example) and answers to user.
In this part you can use some framework that help to manage the requests and responses. For example, in Java you can use the Spring framework. The most famous pattern which helps handling the requests and the responses is the MVC pattern (explained in future post).
In the links below I give an example using Java (Servlets and JSP), which is the most basic technology to implement the client and server side. It’s just a way of implementation. You can use any other language that supports this feature.
About MVC pattern: http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller
Here is a tutorial of Java Servlets and JSP: http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/

Database:
To save the data, such as a user register, you have to use a Database, which is a platform that helps you to manager this kind of job. To work with databases, you’ll have to learn how relational databases work and learn a language to use a database. This language is named SQL (Structured Query Language), where you can insert, update, search data through your database.
To create a database and use ways to manage it you have to use a Relational Database Management System (RDBMS), such as MySQL, or PostgreSQL. There are many RDBMS so you can use anyone, because they are very similar to use. The RDBMS, in short, is a software that you install in your PC that enables you to manage the data you want.
In this website (http://www.w3schools.com/) you have a SQL tutorial which is quite helpful.
Here (http://docs.oracle.com/javase/tutorial/jdbc/overview/database.html) there is a good tutorial about Relational Databases and SQL.
Here we have a tutorial about how to install and use MySQL on Linux. (http://www.yolinux.com/TUTORIALS/LinuxTutorialMySQL.html)

Concluding…

Making a website requires many kinds of knowledge. Those mentioned above are only a couple of things I consider important and essential to start in this kind area. One thing that is true is that the more you learn about something above Web, more you will have doubts and will search and learn about. The study never stops, so be prepared to learn a lot of things and practice, because with more practice more knowledge you’ll have!
I hope this post could help you! This is my first post and I hope my english isn’t too bad.
Thanks people! See you later!

Hello everybody!

Hi people! codingThis is my first post!
In this blog I’ll try to share some experiences I had learning to program, especially programming for websites and mobile development.
I’m just newbie in blogs, so my apologies for some eventually wrong thing I will post or everything else!

Enjoy!  =)