IDE – Visual Studio Code

Tags

Some people ask me which IDEs I use to develop. Usually I used to use an IDE for each language: Eclipse for Java, PyCharm for Python, and so on… I tried to see a generic “IDE” (like a code editor with plugins) as Sublime and Atom. I always read stories that said they are good but heavy.

I tested Sublime, even liked it, but I thought that wouldn’t worth to buy or keep using. I downloaded Atom and the size already scared me: on that time was almost 130 MB or something close to that. I didn’t even install Atom when I heard a friend recommeding me Visual Studio Code. I got curious and I downloaded.

I had a surprise right away: at the time, 40 MB to download. By installing, I already liked the interface, the ease and the native support for Git. I used and enjoyed it, it did not take up much memory and I got carried away. I started to use other languages that I usually program and I was downloading plugins. I accidentally press a Hotkey I used in Eclipse and suddenly open a terminal inside the VS Code. That’s it. It was all I needed.

Continue reading

Advertisements

DevOps

Tags

, , , , , ,

What it is?

DevOps is an integration culture between Development and Operations, aiming that both participate together on the entire software lifecycle (Software Development Life Cycle – SDLC). Some of the main focuses of DevOps: better-quality software, collaboration between Dev and Ops and continuous improvement.

Directly Associated Practices

  • Cloud Computing (AWS, Azure, Google Cloud)
  • Infrastructure as a Code (Chef, Puppet, Ansible, SaltStack)
  • Automated Tests
  • Builds and Continuous Integration (Jenkins, Bamboo, CircleCI)
  • Continuous Delivery

Indirectly Associated Practices

Some practices that end up also being associated with DevOps:

  • Containerization (Docker, RKT)
  • Continuous Deployment

What DevOps is NOT?

  • A tool or just the practices.
  • Just automation.
  • Job Title.
  • Just about Dev and Ops.

Why to adopt DevOps?

  • Continuous and quick Feedback
  • Better quality
  • More reliable releases
  • Shorter TTM (Time-To-Market)
  • Better collaboration between teams
  • Continuous Learning
  • Continuous Improvement

More Knowledge

Free Course about DevOps: https://www.udacity.com/course/intro-to-devops–ud611
Podcast (BR): https://blog.lambda3.com.br/2016/10/podcast-12-devops/
Podcast (EN): https://www.arresteddevops.com/what-is-devops/
Reading: http://www.agileweboperations.com/what-devops-is-not
Reading: http://gutocarvalho.net/octopress/2013/03/16/o-que-e-um-devops-afinal/
Book: http://shop.oreilly.com/product/0636920039846.do

Programmer Utilities – Java Tools 01

Tags

,

Spring Loaded

Main Function: Refresh Java code without restarting server.

Similar: JRebel.

URL: https://github.com/spring-projects/spring-loaded

  • To use Spring Loaded, you have to download the jar and add the following parameters on JVM:
-Djavaagent:ABSOLUTE_PATH/springloaded-1.2.5.RELEASE.jar -noverify
  • On the servers below, the parameters ALSO must be included:
    • JBOSS
-Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.logmanager,org.springsource
-Djava.util.logging.manager=org.jboss.logmanager.LogManager 
-Xbootclasspath/p:${JBOSS_HOME}/modules/org/jboss/logmanager/main/jboss-logmanager-1.2.0.GA.jar 
-Xbootclasspath/p:${JBOSS_HOME}/modules/org/jboss/logmanager/log4j/main/jboss-logmanager-log4j-1.0.0.GA.jar 
-Xbootclasspath/p:${JBOSS_HOME}/modules/org/apache/log4j/main/log4j-1.2.16.jar
  • Wildfly
-Djboss.modules.system.pkgs=org.jboss.byteman,org.springsource

After that, you only need to start the server in Debug Mode and any change on Java Code that is not on method definition or new method/class, you won’t need to restart. It’s recommended to disable the server’s Hot Deploy (Never publish automatically).

PODAM

Main Function: Fill a class (and its dependencies) with random data.

URL: http://devopsfolks.github.io/podam/

Main Functionalities: In addition to being able to fill a class, you can define strategies to generate your data, it supports Bean Validation, generating data for example: Numbers between 3 and 5 (@Min and @Max), and more. Continue reading

Tiers vs Layers

Tags

, ,

Tiers and Layers, in portuguese, are translated to the same word: “camadas”, so, unfortunately there’s no way to understand what they really means, because are two different things and very important. Regardless of language translation, I intend to explain the difference between them on this post.

Tiers

  • Physical separations between parts of the system.
  • It envolves system components that runs or could easily run on separated machines.
  • Tiers Example: Web Server, Database, Distributed Cache, Application Server, etc.

Layers

  • Logical separations between parts of the system.
  • Layers Example: MVC, DDD, etc.
  • Focus on organizing your code.

Layers help decrease coupling and improve separation of responsibilities for better maintenance, evolution and organization of the system.

2 TIERS x 3 TIERS x N-TIERS

– 2 TIERS

2-tiers

Example: Clients accessing a database with business logic in stored procedures.

Advantages: 

  • Security
  • Performance

Disadvantages: 

  • Database dependency
  • Difficulty of integration
  • Low separation of responsibilities
  • Low maintainability
  • Point of failure
  • Difficulty keeping all clients up to date

– 3 TIERS

3_tiers

Example: The remote client, the Web Server and the database.

P.S.: In this case, it loses the meaning of business logic to stay in Stored Procedures. Business logic would now be run in the middle tier (business tier).

Advantages:

  • Ease of updating
  • Ease of integration
  • Separation of responsabilities
  • Security
  • Confiability
  • Easy to keep all clients up to date
  • Better maintainability

Disadvantages:

  • Points of failure
  • Less performance

– N-TIERS

3-Tiers variation. Usually 3-tiers with additional tiers as replication in clusters, load balancers and other tiers. It is also common to say that 3-Tiers are N-Tiers where N is equal to 3.

Attention to adding new tiers:

  • It might impact performance
  • Significant improvement in scalability
  • Improvement in disponibility
  • It might impact complexity
  • It can make it difficult to manage and maintain the entire infrastructure

That’s it folks, I hope you liked it.

References: Introdução À Arquitetura e Design de Software, https://www.casadocodigo.com.br/products/livro-arquitetura-java

Programmer Utilities – Podcasts 01

Tags

,

Talk Python To Me

  • As the name says, a podcast about python and related technologies.

URL: https://talkpython.fm/

5 Minutes of Javascript

  • Podcast about Javascript and its news.

URL: https://fivejs.codeschool.com/episodes

JsJabber

  • Podcast about Javascript and good practices of Javascript and other news, such as related programming languages.

URL: https://devchat.tv/js-jabber

Javascript Air

  • Podcast about Javascript and good practices of Javascript and its news.

URL: http://javascriptair.podbean.com/

Appendix: Extras

  • In addition to my favorites above, here it’s a list of other podcasts for you to decide which ones you like the most (Portuguese and English).

URL: http://ogilvieira.com.br/awesome-podcasts-br/#/

Beyond The Basics – Servlets, JSP and HTML

Tags

, ,

Servlets and JSPs were important for long time, but some concepts are very important and curious and may not gain the proper attention. How a JSP page turns into an HTML page? How can we work directly with the HTML instead of JSP (like the Thymeleaf)?

Remembering…

  • JSP

Java Server Pages, that are template engines. On it, it’s possible to write Java code either directly (scriptlets) and with JSTL / taglibs, and you can get parameters / objects passed through a Servlet.

  • Servlets

Java classes that are responsible for dealing with requests from Web clients, such as the browsers.

  • Web Container (Servlet Container)

It is a component of a web server that interacts with Java Servlets. It is the container that delivers the servlet the request and the HTTP response, and calls servlet methods (such as doPost or doGet).

How JSP turns into HTML with filled data?

When a JSP is requested, the Web Server uses a JSP compiler and converts the JSP into a Servlet that implements the interface javax.servlet.jsp.JspPage.

O arquivo JSP é compilado somente quando a página é requisitada pela primeira vez ou quando o arquivo JSP é alterado, ou seja, o Servlet gerado a partir do JSP é reutilizado, fazendo as próximas chamadas serem mais rápidas.

The JSP file is compiled only when the page is first requested or when the JSP file is changed, i.e., the Servlet generated from the JSP is reused, making the next calls faster.

But how so? The Web Server that transforms the JSP? 

That’s right. The Web Server transforms the JSP into a Servlet.

But what about my Servlet? And what’s that getRequestDispatcher? Continue reading

Programmer Utilities – Links 02

Tags

, ,

JSON to Java Object (POJO)

  • As the name says, it converts JSON to POJO, but also has the funcionality to pass the URL of a JSON.

URL: http://json2java.azurewebsites.net/

JSON/XML to Java Object (POJO)

  • Ao contrário do link acima, esse link não converte só JSON, mas também XML. Não aceita uma URL para um JSON. Unlike the above link, this link does not convert JSON only, but also XML. Doesn’t accepts a URL to a JSON.

URL: http://pojo.sodhanalibrary.com/

JSON to C# Object

  • As the name says, it converts JSON to C# object, but also has the funcionality to pass the URL of a JSON.

URL: http://json2csharp.com/

GIST

  • Gist is a code sharing tool. No need to create an account to share (both public and private), however, without an account is impossible to edit the file.

URL: https://gist.github.com/ Continue reading

What I’ve Been Reading – 01

Tags

, , ,

Hi guys, what’s up? I’ll share with you some things that I’ve been reading lately and I think relevant and worthy to take a look:

Liquibase

  • Liquibase is a database version control tool. Supports changesets, branching and merging and also has traceability. It supports the following file formats: XML, JSON, YAML and SQL. Here is an example taken from the official site:

--liquibase formatted sql

--changeset nvoxland:1
create table person (
id int not null primary key,
firstname varchar(80),
lastname varchar(80) not null,
state varchar(2)
);

--changeset nvoxland:2
alter table person add column username varchar(8)

--changeset nvoxland:3
create table state AS SELECT DISTINCT state AS id FROM person WHERE state IS NOT NULL;
alter table state modify id char(2) NOT NULL;
alter table state add primary key(id);
alter table person add constraint fk_person_state foreign key (state) references state(id);

  • State of the Study: I intend to use, first to test and use the features. If I like, I want to use whenever I can.
  • My Opinion About the Subject: Anything that makes easier database maintenance is valid. Before this, I only used Flyway, but I will test Liquibase.

My Reference Link (BR): https://dicasdolampada.wordpress.com/2012/03/19/evoluindo-o-banco-de-dados-com-o-liquibase/

My Reference Link (EN): https://blog.codecentric.de/en/2015/01/managing-database-migrations-using-liquibase/

Ionic vs React Native

  • Ionic and React Native are two frameworks that promise to develop hybrid mobile applications using JavaScript (Ionic using Angular base, and the React Native using React and its concepts). As I know little of both, I am evaluating pros and cons to know what I should study.

Continue reading

Tips – Performance 01

Tags

, , ,

On Tips Performance series, I’ll give tips of little or almost little things that can be done to improve application performance.

Optimize the FOR loop

Reason: Every time FOR ends an iteration, it validates the condition to know whether to continue. In this condition, it calls a method of the list, thus, the list size will be calculated for each iteration.

Explanation: By placing the value of the list size in a variable, access is much faster because it is not necessary to calculate in all iterations, because it uses the variable that already contains the reference in memory.

Before:

for (int i = 0; i <= list.size(); i++) { ... }

After:

for (int i = 0, j = list.size(); i <= j; i++) { ... }

Programming on the Right Scopes

Reason: Many objects in broad scopes are unused most of the time. Much of the programming languages currently have a garbage collection, cleaning objects that are no longer being used / referenced. Continue reading

HTTP Protocol (Part 2)

Tags

,

On the previous post (HTTP Protocol (Part 1)) we talked a little bit about HTTP basic structure. On this post, we’re gonna talk a little bit more about HTTP structure and go deep on the knowledge.

Status Codes

These are some of the Status Codes most used / known:

  • 200 – OK
    • Default successful response. It may contains response body.
  • 204 – No Content
    • Successful response in which there will never be response body. Note: even if you return response body, once with this status code response, the response body will be ignored and will be as if it had not.
  • 304 – Not Modified
    • It is used when conditional GET or HEAD requests are received and would have resulted in 200 status response, if not for the fact that the condition was false. Typically used when the client wants to see a response only if it has been changed compared to a previous request.
    • The server that generates a 304 response MUST generate any of the headers that would result 200 for the same request: Cache-Control, Content-Location, Date, ETag, Vary and Expires.
  • 400 – Bad Request
    • It means that the request could not be understood by the server due to malformed syntax.
  • 401 – Unauthorized
    • It means that for the request to proceed is required user authentication.
  • 403 – Forbidden
    • It means that the request was understood but the user is not allowed to complete the request.
  • 404 – Not Found
    • Default status when a URI is not found.
  • 500 – Internal Server Error
    • Generic error code, used when an unexpected condition is found and no specific message is suitable.

Headers

  • The headers in HTTP are used to traffic all types of meta information about the requests.
  • Several of these headers are standardized; however, they are easily extensible to accommodate any special particulars which an application may require on this direction.

These are the most used / known Headers:

  • Host – It shows which DNS was used to reach this server
  • User-Agent – It provides information on the means used to access this address
  • Accept – It performs negotiation with the server about the accepted content
  • Accept-Language – It negotiates with the server which language to be used in response
  • Accept-Encoding – It negotiates with the server which encoding to be used in response
  • Connection – Set the type of connection to the server (persistent or not)
  • Content-Type – It defines the MIME Type of the content

Continue reading