Translate

Sunday, November 20, 2016

Common Java Code Review Comments

I was assigned to work on a mobile project where the team does not practice code review.  Everyone in the team (16 developers) can merge the codes that they want.  No unit tests or integration tests were written to verify if their changes were correct.  Good thing they have a Quality Assurance (QA) team but only to test the mobile app and collect the list of bugs.
To make things worse, the project will be released to Production in two weeks time.

I asked at least 4 team members on how can I contribute to the release.  Each one is pointing to one after another.  They don't know what I can work on.  I even get the impression that they think I am slow.  It will take me some time to get to speed.  I may look young (and pretty) but I tell nobody that I have been working professionally as a Software Developer for almost 2 decades!  Oh well, people in the IT field can be sexist sometimes.

So being in this new team, my co-worker who also came from my previous project imposed more strict code review process.  I came up with a cheat list so that I can have comments in each pull request submitted by developers.
  1. Update Javadoc
    • If method has been renamed, make sure that the documentation has been updated.  If there is no Javadoc, ask the developer to add one.
    • When method parameters have changed, make sure to update the Javadoc too
    • Return object was changed
    • The logic has been changed
    • Missing Javadoc
  2. Set the correct access modifier.
  3. Do not save unencrypted passwords in the repository
  4. No unit tests
  5. Incomplete unit test - Unit test is testing only happy path scenarios.
  6. Too verbose logging
  7. Too deep if statements
  8. Eating exceptions. Not catching exceptions
  9. Returning null
  10. Not checking for null
  11. Duplicate codes. Copy-pasted codes which can be reused.
  12. Spaces vs tabs
  13. Too generic error messages
  14. Class names are not descriptive enough.  I even encountered class names such as Add, Remove and Rename.  Those are action words and those classes are the objects that are supposed to be added, removed or renamed in the application.
  15. Wrong spellings, incorrect grammar - I may not be fluent in English but I am a GrammarNazi when it comes to coding.  Working with developers of different cultures and educational background can be challenging.
  16. Description of the pull request
  17. Returning a very huge object.  This is same as logging the very huge object.
  18. Incorrect logging level
  19. Assuming that the project uses Spring Framework, change if (list != null && list.size() ) CollectionUtils.isNotEmpty(...).  Use StringUtils.isBlank(...)
  20. Unhandled or incorrectly handled exceptions
I hope this list can serve as guidelines to Java programmers who want to participate in their team code reviews.

Thursday, September 15, 2016

Firefox RestClient Send button is not working

It has been months since I last accessed a REST web service that uses OAuth.  I have to do some testing on my work and now I have to use the RESTClient add-on in my Firefox browser.  I have saved the web service settings in that RESTClient.

Upon clicking the Send button, nothing happens.  This normally works but for some reason it does not work as expected.  I Googled to find out what could have gone wrong and ultimately find a solution to fix this so I can proceed with my testing.


  • In the Firefox address bar, type "about:config"
  • Search "restclient" on the text box.
  • It will display results for the RESTClient extension

  • For each RESTClient result returned, right click and press "reset"
  • Restart Firefox.  This will remove any cached data for the Firefox extension and the Send button should start working again!

Thursday, May 12, 2016

Running a Cucumber Feature File in Eclipse

I was tasked to improve an automation test that the offshore QA team has written for our web application.
I specifically have to update this Cucumber feature file.

Feature: Verify Search functionality

   Scenario: As a default User, I should be able to see search in Account page
      Given I do a default login
      When I view "Account" tab in Home Page
      Then I verify search ui functionalities

To a more granular test that when a default user do a search and the web application's dependent web service is down, then an error message will be displayed.

  • I am a Java developer but I have no background on QA testing nor Behavioral Driven Development (BDD), Cucumber, Selenium and all these tools that the offshore team has been using in their automation tests.
  • The QA Team has very little onboarding documentation so working on a Cucumber Feature file could be tricky.
  • We have an onshore QA Manager but he has got loads on his plate at the moment.
  • I was told not to run random tests off the project because it could cause issues in the Production environment.

To accomplish my almost impossible task, here are the steps I did.
  1. Import the project from Github into an Eclipse workspace.
  2. Install Cucumber Plug-in in Eclipse At this point, when I open the Feature file, I can see the file icon changed and the file text is color-coded.
  3. I try to run the feature file by right-clicking on the file.  Run As -> Cucumber Feature.  I got an error as below:
  4. This is because the Cucumber Eclipse plugin does not have Cucumber JVM and other JAR files needed to execute feature file.  Right-click on the project.  Select Properties -> Java Build Path -> Libraries.  Add External JARS. Then select the files that you must have previously downloaded from Maven Repository:
    • cucumber-core-1.2.4.jar
    • cucumber-java-1.2.4.jar
    • cucumber-junit-1.2.4.jar
    • cucumber-jvm-deps-1.0.5.jar
    • cucumber-reporting-2.2.0.jar
    • gherkin-2.12.2.jar
    • junit-4.12.jar
    • mockito-all-2.0.2-beta.jar
    • selenium-java-2.41.0.jar
  5. I tried doing again step #3 but failed.  At this point, I found a blog post that made it work.  I created a Run Configuration.  From the menu, select Run -> Run Configuratons.. -> Cucumber Feature -> New.  Select the project you are in.  In the Arguments, enter 
  6. --glue AcceptanceTestCases src/Search.feature --format pretty
    VM arguments:
    -ea
  7. Execute this configuration and the Feature file should run smoothly.

Tuesday, May 10, 2016

Alternative to Mozilla Firefox's RESTClient

Alternative to Mozilla Firefox's RESTClient

Writing and running REST and SOAP web services has been in my daily routine at work.  My favorite plugin to execute REST calls is Firefox's RESTClient plugin.

But last week, there was an outage in our network that we had to install new certificates in our machines.  I overwrote the cacert file as advised by our DevOps so we can run our apps in our localhosts.

However, this new cert has somehow changed my Firefox settings.  As I was running Firefox RESTClient, none of the Headers were being populated when I choose any of my saved requests.

I knew something was wrong.  I exported all requests into a JSON file.  I uninstalled the plugin.  Then failed to reinstall it back again as I keep on getting "Your connection is not secure"



So I'm stuck and cannot work on my web services testing.  It's either I walk over to the DevOps team and have them checked if this was caused by the cert recently installed OR find an alternative REST Client so I can proceed with my web services testing.

I went ahead with the latter.  Below are browser plugins that I find equally or better options to Firefox's REST Client.


  1. I considered Chrome's RESTClient first. However adding authorization headers was not straightforward.





  2. Then I tried another popular Chrome plugin, PostMan.

    As soon as I hit the Authorization tab, it asks me for the Type. Basic Auth, OAuth 1.0 and OAuth 2.0 are the types I need most of the time.
  3. Another REST Client I installed was cREST Client.  But I find it too simple.  So I abandoned the idea of using it.
To wrap up, the best easy-to-use REST Client browser plugin for me is PostMan.  Although I found something wrong with it.  When I choose Basic Auth, it can only accept a Username + Password combination.
A web service that I was about to test only has a Basic Auth key.  If I have to run that web service, then I would have to move to the RESTClient.


Monday, May 9, 2016

Installing Cucumber plug-in in Eclipse from Repository

There are two ways to install Cucumber plug-in to your Eclipse.  One way is by using the Marketplace which I blogged here.
Another way is by using the Repository which is detailed below:
  1. Open Eclipse.  From the menu, select Help -> Install New Software.  Click on Add... button.
  2. In the Add Repository window.  Enter http://cucumber.github.com/cucumber-eclipse/update-site in Location field.  Enter Cucumber as the name.  Then click OK.


  3. The window below will be displayed.  Tick the check box to expand the features included in the plugin.  Click Next button.


  4. Accept the Terms of Agreement.


  5.  After a successful installation, Eclipse will ask you to restart.



  6. Once restarted, when you open a Feature file, additional commands are added in the context-menu.


How to extract Zookeeper TAR.GZ file in Windows using 7-Zip

How to extract a Zookeeper TAR.GZ file in Windows

I was about to install Zookeeper in my local machine when I found out that the installer is in GZ format.  Being a Windows user, I have to find my way on extracting the files without using Linux/Unix commands.  I have 7-zip handy.  You may also choose WinRar, GZip or other free extractor tool available.

Here are the steps I did to extract the Zookeeper installation files:

  1. Download the latest stable installer.  As of this writing, http://www-eu.apache.org/dist/zookeeper/zookeeper-3.3.6/zookeeper-3.3.6.tar.gz is the most stable one.

  2. Right-click on the file downloaded on your file system.  Select 7-Zip.  Then Open Archive.  The 7-Zip window will be opened as below.





  3. Click the Extract button.  Then provide a Copy to folder.  This will extract the TAR file in the folder provided.

  4. Double-click on the TAR file.  This will display the contents of the TAR file as shown below.

  5. Select again the zookeeper-3.3.6 directory.  This time, click the Copy button in the 7-zip buttons panel.  You will be asked to enter a valid Copy to folder.  Click OK when done.

  6. Viola!  All files will be extracted to the folder.

Monday, April 25, 2016

Hello World Github Repository


The Hello World project is a time-honored tradition in computer programming. It is a simple exercise that gets you started when learning something new. Let’s get started with GitHub!
You’ll learn how to:
  • Create and use a repository
  • Start and manage a new branch
  • Make changes to a file and push them to GitHub as commits
  • Open and merge a pull request

What is GitHub?

GitHub is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere.
This tutorial teaches you GitHub essentials like repositoriesbranchescommits, and Pull Requests. You’ll create your own Hello World repository and learn GitHub’s Pull Request workflow, a popular way to create and review code.

No coding necessary

To complete this tutorial, you need a GitHub.com account and Internet access. You don’t need to know how to code, use the command line, or install Git (the version control software GitHub is built on).
Tip: Open this guide in a separate browser window (or tab) so you can see it while you complete the steps in the tutorial.

Step 1. Create a Repository

repository is usually used to organize a single project. Repositories can contain folders and files, images, videos, spreadsheets, and data sets – anything your project needs. We recommend including a README, or a file with information about your project. GitHub makes it easy to add one at the same time you create your new repository. It also offers other common options such as a license file.
Your hello-world repository can be a place where you store ideas, resources, or even share and discuss things with others.

To create a new repository

  1. In the upper right corner, next to your avatar or identicon, click  and then select New repository.
  2. Name your repository hello-world.
  3. Write a short description.
  4. Select Initialize this repository with a README.
new-repo-form
Click Create repository:tada:

Step 2. Create a Branch

Branching is the way to work on different versions of a repository at one time.
By default your repository has one branch named master which is considered to be the definitive branch. We use branches to experiment and make edits before committing them to master.
When you create a branch off the master branch, you’re making a copy, or snapshot, of master as it was at that point in time. If someone else made changes to the master branch while you were working on your branch, you could pull in those updates.
This diagram shows:
  • The master branch
  • A new branch called feature (because we’re doing ‘feature work’ on this branch)
  • The journey that feature takes before it’s merged into master
a branch
Have you ever saved different versions of a file? Something like:
  • story.txt
  • story-joe-edit.txt
  • story-joe-edit-reviewed.txt
Branches accomplish similar goals in GitHub repositories.
Here at GitHub, our developers, writers, and designers use branches for keeping bug fixes and feature work separate from our master (production) branch. When a change is ready, they merge their branch into master.

To create a new branch

  1. Go to your new repository hello-world.
  2. Click the drop down at the top of the file list that says branch: master.
  3. Type a branch name, readme-edits, into the new branch text box.
  4. Select the blue Create branch box or hit “Enter” on your keyboard.
branch gif
Now you have two branches, master and readme-edits. They look exactly the same, but not for long! Next we’ll add our changes to the new branch.

Step 3. Make and commit changes

Bravo! Now, you’re on the code view for your readme-edits branch, which is a copy of master. Let’s make some edits.
On GitHub, saved changes are called commits. Each commit has an associatedcommit message, which is a description explaining why a particular change was made. Commit messages capture the history of your changes, so other contributors can understand what you’ve done and why.

Make and commit changes

  1. Click the README.md file.
  2. Click the  pencil icon in the upper right corner of the file view to edit.
  3. In the editor, write a bit about yourself.
  4. Write a commit message that describes your changes.
  5. Click Commit changes button.
commit
These changes will be made to just the README file on your readme-editsbranch, so now this branch contains content that’s different from master.

Step 4. Open a Pull Request

Nice edits! Now that you have changes in a branch off of master, you can open a pull request.
Pull Requests are the heart of collaboration on GitHub. When you open a pull request, you’re proposing your changes and requesting that someone review and pull in your contribution and merge them into their branch. Pull requests showdiffs, or differences, of the content from both branches. The changes, additions, and subtractions are shown in green and red.
As soon as you make a commit, you can open a pull request and start a discussion, even before the code is finished.
By using GitHub’s @mention system in your pull request message, you can ask for feedback from specific people or teams, whether they’re down the hall or 10 time zones away.
You can even open pull requests in your own repository and merge them yourself. It’s a great way to learn the GitHub Flow before working on larger projects.

Open a Pull Request for changes to the README

Click on the image for a larger version
StepScreenshot
Click the  Pull Request tab, then from the Pull Request page, click the green New pull request button.pr-tab
Select the branch you made,readme-edits, to compare with master (the original).branch
Look over your changes in the diffs on the Compare page, make sure they’re what you want to submit.diff
When you’re satisfied that these are the changes you want to submit, click the big green Create Pull Requestbutton.create-pull
Give your pull request a title and write a brief description of your changes.pr-form
When you’re done with your message, click Create pull request!

Tip: You can use emoji and drag and drop images and gifs onto comments and Pull Requests.

Step 5. Merge your Pull Request

In this final step, it’s time to bring your changes together – merging yourreadme-edits branch into the master branch.
  1. Click the green Merge pull request button to merge the changes intomaster.
  2. Click Confirm merge.
  3. Go ahead and delete the branch, since its changes have been incorporated, with the Delete branch button in the purple box.
mergedelete

Celebrate!

By completing this tutorial, you’ve learned to create a project and make a pull request on GitHub! :tada: :octocat: :zap:
Here’s what you accomplished in this tutorial:
  • Created an open source repository
  • Started and managed a new branch
  • Changed a file and committed those changes to GitHub
  • Opened and merged a Pull Request
Take a look at your GitHub profile and you’ll see your new contribution squares!
If you want to learn more about the power of Pull Requests, we recommend reading the GitHub Flow Guide. You might also visit GitHub Explore and get involved in an Open Source project :octocat:

Tip: Check out our other Guides and YouTube Channel for more GitHub how-tos.
Last updated April 7, 2016

33 Ways to Monetize your Website

Source: http://websitesetup.org/33-ways-to-monetize-website/


Updated 3rd of January, 2015 by Robert Mening.
It’s not a myth that you can make money with your website. A lot of websites on the Internet are made for one simple reason – to generate income. In most cases, it’s not just a hobby.
Whether you are trying to get rich or just looking for some funds to cover the hosting/domain expenses, here are some of the ways to do so.
Keep in mind that some of the strategies are more or less passive while some other techniques require a lot of on-going work. Make sure you pick something that suits well with your website.

10 most popular ways to monetize your website


1) Affiliate Marketing

Affiliate marketing is a very popular way to make money through your website/blog. In short, you sell (or recommend) someone else’s product(s) on your website. When your website visitor clicks on your affiliate link and buys the product – you’ll receive commission.
The commission is usually 30% – 70% of the product or service price. So if you promote an e-book that costs $100, you’ll get $50 for referring the buyer (just an example).
Where can I find products to promote?

2) Pay Per Click Advertising

Google has made a program called Google Adsense for publishers (bloggers, website owners) and advertisers (business owners, marketers, product owners).
This system is quite simple. You place a code on your website that will start displaying relevant ads to your website. For example, if your site is about pets (dogs & cats), Google Adsense will start showing your visitors ads for cat food, dog training and so on.
When someone clicks on the ad, you will receive money for this click. It’s usually $0,5 to $5 per click, but when your site has enough traffic – you can make hundreds if not thousands of dollars per month. Keep yourself known with their TOS, though.
How to apply for for Google Adsense?
  • Apply for AdSense – Before applying, keep yourself updated with their TOS, though. Google is very strict with their rules so it’s pretty hard to get approved.

3) Selling Ad Space

As the name says, all you need to do is sell the ad space. You set up a price, let’s say: “Banner at the sidebar will cost $xxx per month”. You will get paid upfront and the price depends on your traffic. If your site gets ton loads of traffic from different sources, the banner ad price can go up as $5000 per month. However, if your site doesn’t have much traffic, don’t expect much.
Where can I let others know that my website is selling ad space?

4) Sell your own digital product (ebook for example)

Selling your own product is awesome because there are no middle mans, no one is going to take the “cut” – it’s only YOU and the CLIENT. You can sell directly through your website and you’ll get paid directly. While it looks like a simply way to make money, it’s actually not.
It takes a lot of time to create a good product that you can actually sell through your site. So make sure it’s well-made and polished before you throw it out on your webpage. In addition, a perfectly optimized landing page for the product is essential to higher your conversion rates.
Additional resources

5) Donation / Becoming a sponsor

Setting up donation buttons or simply asking additional funds from your readers is another way to monetize your website. It’s easy to set up, but you have to be aware that it’s not so easy to make money with it. Unless you find a sponsor(s) who pays a lot! However, before you throw up your donation buttons and widgets, make sure that your visitors will see why you need those donations (hosting expenses, new product creation, researching costs etc…).
For example web.archive.org makes a lot of money from donations, but then again – they probably have millions of visitors per month.
How to set up donation buttons?

6) Accept sponsored posts & articles

Once your site is getting good amount of visitors monthly, you can offer sponsored posts and articles. There are a lot of advertisers who would be interested in writing sponsored posts for your website.
Another option is make money through reviewing something. Here’s an example: You have a website about Apple products -> marketer from Apple sees your site and contacts you.-> He/she offers you a free iPhone 5 if you make a comprehensive review and post it on your site for followers to read. This is an extreme case, but I’m sure you get the point…
Win=Win situation? Yep. However, make sure don’t accept anything completely irrelevant to your site/blog. If your site is about cats and you post a review of American Express credit card, then your visitors might have a trust issue (case study).
For further reading:

7) Generate “Leads” for other companies

Generating leads means you help other organisations or companies to make money. It can be a simple e-mail submit or telephone number, a lead is a lead.
Scenario: Let’s say you have a website about teaching and learning math. You can easily set up links to different schools and universities that offer people to learn math. When YOUR visitor submits their e-mail or a phone number to university for application – you’ll get paid.
It’s very similar to affiliate marketing, but your visitor doesn’t necessarily have to buy something. A short contact information is more than enough. The sales people will take care of the rest.
Where can I find such offers?

8) Build an “Email List”

Building a “list” means that you gather your visitors emails. 90% of the websites that get some sort of traffic use that technique – and it’s working pretty well.
You’ll not get rich overnight, but it’s definitely something long-term (and profitable). However, make sure you first create relationships with your followers by simply offering great information and/or help for FREE. Spamming different offers through emails is never a good idea.
How exactly does it work?

9) Set up an online store

You don’t always have to create a website about something. You can just create a “tool” for your business – an online store.
Bricks and Mortar businesses are becoming more and more popular since the rise of the “Internet era”. If you have enough dedication to make it work, try it out. Be aware of the competition, though. There are thousands of e-commerce website on the Internet, but only few of them make a lot of money. Plan out your strategy, keep your design up-do-date and use the latest marketing techniques.
How do I create a successful online store/shop?

10) Sell your site to someone else

I usually don’t suggest people to do that, but site flipping/selling is becoming a very lucrative business model. If you are into short-term projects and more into “quick buck” you can implement it as well.
… but you also have to know that your site has to either get a lot of traffic or generate money through different monetization methods.
The site value is usually based on the income. If your website is making $500 per/month through selling ad space, you can sell the site for $5,000 – $10,000 (12x – 22x monthly income).
Another option is to sell ready-made sites, they are much cheaper, but there’s still some money to be made.
Where can I sell my site?
OK, by now you have learned the ten most popular ways to earn money your website. But that’s not all you can do.
Below here I pointed out another 23 ways to make money with your website. Keep in mind that some of them are slightly connected with the ones above yet they are little “out of the box”.


Another 23 ways to monetize your website


11) Sell text-link ads – There’s still a slight demand for text-links ads, but you need to keep in mind that Google doesn’t tolerate it that much…
12) Set up “infolinks”– It’s quite easy to set them up, but the downside is that it’s not converting too well and the payouts per clicks are quite small. It’s a great alternative for Adsense, though.
13) Use monetization widgets – Very similar to Google Adsense, worth trying out as an alternative.
14) Set up RSS feed ads
15) Give away premium content for extra $$$ – If you are producing mind-blowing, awesome and near ideal content that helps your visitors – you can feel free ask money for that. I’m completely fine with paying for the premium content. However, at first your main goal should be growing audience and visitors; not asking them money right away.
16) Start a private forum or coaching class(es) – If you are good at something, why don’t you start advising others? It’s a great way to earn recurring income from your students.
17) Create a job board – You can set up a job board on website. You can earn money by accepting different job offers from various companies/individuals.
18) Offer consulting – You know something that other’s don’t? Offer consulting GIGs and get paid for your knowledge. You can offer consulting via email, forum and Skype.
19) Add “hire me” page on your website – If you enjoy freelancing, you can leverage your opportunities through your web page. Make sure you list down all your skills and previous tasks – this will improve your chances of getting hired.
20) Sell or rent internal pages – This isn’t very popular way to make money, but if you find someone who is interested in renting your pages – give it a go!
21) Display pop-ups advertisements – Extremely annoying, but another easy way to makesome money.
23) Display audio ads – This is something new and it’s getting more and more popular in 2015. I haven’t tried it personally, but I have read some articles about it and it definitely looks promising.
24) Sell an e-book – Many people sell e-books through their site. Some examples: If you have a website about recipes and cooking, you can easily create and sell your own recipe book. The same applies in every other niche.
25) Create a conference around your website
26) Set up a teaching program
27) Host paid webinars
28) Create a membership site
29) Offer coupons (with affiliate links) – People are eagerly looking for discount & promo codes. If you can offer a valid one, you are able to cut some money as well.
31) Offer writing gigs – If you are native & fluent – I can’t see any reason why you shouldn’t offer writing GIGs. If you are good enough, you can easily ask $20 – $30 per 500 word articles. Just let others know that you are offering this kind of service.
32) Create a paid directory/business page
33) Just copy what others are doing – My personal favourite.
P.S: If you know any other ways to monetize websites, let me know. I’ll add it in the list and credit you by putting your name behind it.