Home » Programming
Category Archives: Programming
As all developers know, Murphys Laws is a powerful guide to keep in mind and help us (in one way or the other) to prevent big catastrophes. Maybe I’m exaggerating a bit, but you all get the point.
Until a few years back i didn’t use code repositories, more exactly control version system. I didn’t use it, didn’t need it and most of all I didn’t knew of their existence (Ye, shame on me). But when I went to college, I felt the need to backup all my work, after all the teachers didn’t care about the “I hard drive died” or “my computer went kaboom” excuses.
So i started my investigation about code repositories. I found out about CVS, but it was starting to be discontinued and I couldn’t find any free CVS repositories. Next I found SVN, seems promessing, Google has SVN repositories free and with some configuration you can turn them to private, add users, etc. Felt great and I used them for a few years. Although it has many vantages, there was not much system explorer integration and I used them both in Linux and Windows, or even great integration with Eclipse and Netbeans. Maybe is was a big idiot, but times to times i had some trouble and didn’t had my code at the latest state. I assume, my low experience and lack of method provided my biggest headaches.
After a few years, it came to my attention the existence of another flavour: the GIT. One distributed VCS with great functionalities and make me wonder how is the feeling of working with it. Well is great, i don’t want anything else (by now :P).[Some comparison about them both: https://git.wiki.kernel.org/index.php/GitSvnComparison] By searching for git hosting, i found out about github (which is free and the repositories are public) and bitbucket (also free and the repositories are both public and private). There are many others out there:
This is great but … … … they are hosted in the Internet. In some contexts it is not desired that we have the repositories in Internet, but we need, no, we want one repository to control version of our work but, unfortunately, there is no repository “in house”. In this “tutorial” (http://git-scm.com/book/en/v1/Git-on-the-Server) explains how to setup a git server, but in my humble opinion is a bit complex for a simple, one project repository, so I searched a little more.
I looked at GIT documentation (yes, it’s true. Sometimes I read the manual :P) and noticed about the “git init –bare” command, that provide a local repository, which is great. So if you have a shared (and mapped) network drive, an external drive you can initiate a repository and them you can work as usual, by cloning, commiting and push actions.
I also found this article by Jimmy Theis (http://jetheis.com/blog/2013/02/17/using-dropbox-as-a-private-github/) which explains how to use your dropbox account to backup your repositories. Although I didn’t tried with others storage hosting, i believe that should work with Onedrive service also.
Some considerations, learned by the hard way:
- While working, commit each functionality that you are working. One at the time. If something was buggy, it’s is easier to “undo” one commit rather then “undo” multiple functionalities in one commit.
- Commit often, push once. Since you don’t need to be connected to “commit”, you can “commit” as often you need to accomplish your goal. At the end, just “push”.
- Although you don’t need any application beside GIT to the work, sometime is a pain doing the work in command line. I suggest the usage of a GIT client. I use Atlassian SourceTree (http://www.sourcetreeapp.com), it is great and work both in Windows and Mac. It helps you to keep track about your repositories and can sync with github and bitbucket.
- If you like and want to use the command line, don’t forget to add files before committing. They are not added by default.
- GitIgnore is your friend. Use it and abuse it. This functionality help you to keep out of track unneeded files. Very helpful in Visual Studio projects.
- Don’t forget, just don’t, to add to GitIgnore any file that you have containing usernames, passwords, connection strings, etc. One in the Web, you can’t control who sees it, an by a security measure you have to change all services credentials. A huge pain in the head. 😛
Just a few insights to those who are a bit distracted 🙂
Keep it tuned.
Some time ago i posted about a event that I participated
Here is the video:
A not so long ago i had a course of Business Intelligence and for the course project i had to build a data-mart with the dimensions and fact tables. I admit that i don’t like the Excel, although it has many advantages I …. hate him :-).
Because I was a little stressed, I didn’t stop to think how to do the work and start creating a sheet to the dimensions and the fact tables and an extra sheet to the “inner join of all dimensions and fact table”. A real pain in the … hand.
Recently I had to do another “project” using only the Excel and it was a requirement that i only made a single call to the database and do all the work in the Excel. After starting the job, i remember thinking “This is extremely stupid” so I stopped to think and with some help a Mr. Google I got a meanful breaktrought.
This is a recipe to use Excel as it was a relational database and hope it will help you and also prevent you from doing the same mistakes.
- Open Excel and create a data table.
- Insert manually
- Get it from the database
- Save the Excel in a easy to remember location
- Create a “Data Connection”.
- Data Tab -> “From Other Sources” -> “From Microsoft Query”
- “Databases” -> “Excel Files”
- Find the saved excel file
- Add all columns you need
- Don’t provide any filter or order
- Click “Save Query” and save it in the save folder than the excel file
- Click “Finish”
- Choose the cell location for the result.
Now we should have the data in the sheet.
If we copy the excel to other location we will have some missing files errors, so to prevent we will change some configurations.
- Go to “Data” tab again and click “Connections”
- Double-Click in the active connection
- Click “Definition” tab
- in the connection string change the absolute path for the excel for an relative.
- ex: “DBQ=c:\temp\excel.xls” -> “DBQ=.\excel.xls”
- If you need to change the query just change it in the “Command text”.
- Verify that there is no reference to the absolute path of the excel book.
If you need some “where” clauses that depend cell value, just edit the query and in the query clause put “?”. ex: “…. where id=? ….”. When you refresh the data it will ask which cell should be read to assume the value. Niiiiiice. You can also click in the parameter button and can costumize the text should appear and the cell location.
Hope it help.
In the last month i start building one of my ideas for mobile applications. Since the moment i had the idea, i had a bunch of problems. My mind flood with all kind of question, issues, problems from a variety of stages of development:
“How i do this?” , “Make it asynchronous or synchronous”, and this and that and whatever.
So I stopped. I found a way to do things, from a organised way and i wrote it down. Once written i created a slideshow presentation so beginners could have a starting point.
You can find the slide in:
Hope you enjoy. Any suggestions, feel free to contact me.
AND IT IS FINISHED!!!
The library is ready.
In this last day, it was made the effort of making some re-factoring, turning the implementation more readable. Some bugs were corrected, and javadoc was made.
In my next stage of the project I will make an java main application that uses the library, something simple so you could see the picture.
See you next time.
After some days of complete laziness I went back to work.
For some weird reason the code was exactly has I left him, :-), so I start the next step of the development was ….
…. UNITY TESTING.
Yes, this beast of development. But I wasn’t afraid. I respected the beast and I went back to work. Fortunately, i only had to do functionality tests to a few classes, and correct some conceptual bugs in them.
For now the “library” serves the committed purpose. For a list of contacts, send each one of them an email with a set of attachments.
Review the code, remove redundant code. Tweaking a little more the code. And last, but not least, export the library with all its dependencies and make an use case to test the library.
I Know i promised some diagram of the project. Don’t worry, it isn’t forgotten, but requires some time to do it right.
I’ll keep it in touch,
Yes, it’s a fact. Yesterday i didn’t do nothing…
But today i worked for both days. I finished developing the classes to send the email with attachments.
The application is not yet finished, still missing the unity test to approve all classes but looks good. Another thing i have to do is re-factor some packages, because some classes deserve to have their own package because they have one specific functionality, this is the case of the Contact.java and ContactList.java.
Another re-factor to be done is at ContactList.java. I’ll annotate the class and methods with JAXB annotations, so it could be easier to save to/read from xml files with a given structure. This is helpful if we like to provide an pre-build xml final, instead of adding the contacts by hand.
Next week, after the successful unity testing, i’ll provide the current simplified UML diagram and one potential application example of the small, limited library.
Until then, you could step by the github repository e checkout the project.
Have a nice weekend! 🙂