gsolano's blog

Not afraid of looking uncool

Sometimes I feel like software development world behave in certain way like fashion mode. I don’t say it because I think it is completely subject of trivial conditions like the influence of a pop star over young teenagers, but in small scale, most popular rock star frameworks tend to monopolize software engineers with recipes, sometimes to the point of thinking that anything distinct from the recipe is out fashion.

Parsing an HTML page

I wanted to share an example code showing how to parse an HTML page using the open library HTML Parser . I used this library in the past for a project where we required to extract all links of a site, and now I’m about to use it again for a project where we need to validate certain HTML coding rules. This library is simple and very straightforward to use.

So let’s assume we need to find all the absolute URL’s referenced in a page. First, we create our parser class:

  1. import java.io.IOException;

Determining redirects when accessing an URL

Here’s a basic example on how to determine when opening a HTTP request, if the URL redirects to another one. The function of this class gets the HTTP response code from the HTTP connection, and if the code is any of the ones associated with redirection: 301/302/303, it obtains the final destination from the "Location" header.

To be, or not to be ...

To be, or not to be ... a manager, that is the question. Remember the first time you coded a Hello World application. If the programming muse touched you at that moment, you felt like you wanted to do this for the rest of your life. Or maybe not, but at least you found some level of vocation that motivated you in some fashion to keep improving in the software development world.

10 Tips to drive your software developer career

Recently, I was reading an interesting article on how to be a better professional as a front-end developer . So I started to reflect on my own set of tips that I would recommend to drive the career as a general software developer. Lot of points can be added to the list but this is just my personal perception at this stage of my career contextualized in a so called “third world” country.

Using Observer Pattern to track progress while loading a page

Have you ever been in a site where there is a heavy process that takes a long time in finishing? If the web page is not user friendly designed, you may end it up with an annoying forever loading page.

If we want to avoid this feeling of slowness in our pages, we should consider adding a progress indicator in the page to show how much is left until process is finished. To accomplish this we can take advantage of the Observer pattern.

A Few File Operations || Building a Synchronizer

Recently in the project I’ve been working in the last couple of months, we had to think in a way to solve the problem of keep updated some local copies of repositories where the originals are located in remote servers. Due to the kind operations we need to run, we couldn’t afford to do them directly in the remote servers. If you are thinking right now, “well duh! Use SVN you dummy” , well, let’s say that our client does not have it and there is no close possibility he will install it for us. We only had access to the share drives where we could read the file systems. That’s all we had.

Tres Amigos of Persistance (DAO - DAOFactory - BO)

Nowadays, even with all the good accumulated knowledge we have in design patterns, software engineers still tend to program classes where business logic is mixed with persistence logic. Even some experienced developers omit this important aspect of software architecture maybe for lack of knowledge, or just for the rush to start programming quickly. I consider the last reason is the most common of all.

Now why should we bother too much about this separation? well, the idea is not to develop a case for what is basic in software architecture:

Log Friendly Exception Handling

Normally for a typical junior, "in a rush", programmer, exception handling is something that is quickly solved by suppressing the exception, or catching it just to simply log the entire stack trace.

I can say that because I used to do it, not to care too much about the correct treatment of exceptions. Sometimes we tend to think that the most considerable approach is to log the exception and throw it up repeating the process in the subsequent classes.

  1. public class A {
  2. 	public void callB() throws {
  3. 		try {
  4. 			new B().doSomething();

Iterating Complex Map Structures

Have you ever encountered yourself with nested data structures mixed with generics syntax? Even worse, have you or have you been creating this confuse statements in your code?

Let me show you an example of what I mean and what I had found in some interactions with colleague's programming code.

In our example application we need to store and show the enrollment data for a university quatrimester. The data is structured in a hierarchical fashion where we have as first node the year, then the quatrimesters, the courses and at the bottom the students enlisted in those courses.

Year

Syndicate content