Eclipse – Formatter e Save Action
Depois de ter falado sobre Code Templates para comentários no código, vou neste post falar sobre a formatação e como otimizar isso para lhe ajudar e não atrapalhar.
Muitos desenvolvedores tem problemas com o famoso Ctrl+Shift+F, que promete formatar seu código e muitas vezes acaba é deixando ele mais confuso.
Bem, o nosso padrão de código(se é que posso chamar assim) é muito diferente(ou um pouco depende) dos códigos dos gringos, ou seja, o Eclipse formata no padrão deles pode dizer assim ;).
Para resolver esse “problema” o desenvolvedor tem que fazer uma configuração simples, mas um pouco chata(considerada por alguns) mas no pior caso será feita apenas uma única vez ;).
Vá em Windows –> Preferences –> Java –> Code Style –> Formatter.
Vamos agora criar um novo profiler, clique em New e digite um nome para o seu novo profile.
Pronto, agora vamos personalizar, clique em editar.
Vou tentar falar um pouco sobre cada aba de opção.
Indentation
Nesta aba você vai selecionar a indentação em si e o tamanho dela, normalmente o tamanho da tab é 4.
Braces
Nesta aba você vai personalizar a posição das chaves(“{” , “}”).
White Space
Está é interessante, pois você poderá personalizar até os espaços em branco entre cada variável, método e assinaturas de todo tipo de objeto, desde strings até arrays e várias outras.
Blank Lines
Nesta aba você irá definir as quebras de linhas(linhas em branco) entres métodos, variáveis, pacotes e etc. Aqui você irá definir por exemplo que o espaço de linha entre a declaração de um package para um import seja de 2 linhas por exemplo.
New Lines
Nesta aba você define como um método vazio deverá ficar, se você deseja inserir uma nova linha neste método, definir também como um array declarado deverá ser exibido e identado, assim como uma annotation.
Control Statements
Esse é bem interessante mesmo, pois aqui você irá definir como seus else, IF, catch, while etc devem ser identados.
Line Wrapping
Neste você define o tamanho Maximo da coluna que uma linha pode comportar, como deve ser a identação de uma assinatura de um método, métodos declarados, enum, variáveis declaradas e etc.
Comments
Isso é referente a identação do Java Doc, blocos de comentários normais(//, /**/), qual o formato das tags HTML, espaço entre os textos do comentário e se desejar remover qualquer linha em branco que esteja no comentário.
Todas essa opções podem já serem visualizadas no código de exemplo ao lado de cada uma, facilitando assim a personalização.
Então supondo que você já criou e personalizou seu profile vamos agora tentar otimizar isso.
Para se utilizar do profile basta você executar o atalho dentro do código, que é o Ctrl + Shitf + F, pronto ele aplica a sua configuração personalizada.
Mas supondo que você criou um profile e quer sempre executar ele, fica meio chato você ficar sempre digitando o Ctrl+Shit+F correto ? Que tal otimizar isso ?
Save Actions
Vá em Windows –> Preferences –> Java –> Editor –> Save Actions.
Para ativar(caso não esteja) basta selecionar a opção “Perform the selected actions on save”.
Agora podemos adicionar uma formatação automática, selecione o Format source code e clique em Formatter.
Verifique se o seu profile está selecionado como profile ativo(Active Profile), clique em Ok e pronto, na próxima vez que você salvar(Ctrl + S) qualquer arquivo .java(classe) ele irá aplicar a(s) sua(s) configuração(ões) automaticamente.
Para definir como padrão para todos os integrantes da equipe, basta seguir os passos abaixo.
Vá em Windows –> Preferences –> Java –> Code Style –> Formatter –> Edit –> Export –> Salve seu profile.
Agora cada desenvolvedor irá poder importar toda a configuração de formatação de código, ou você mesmo poderá levar para onde quiser a sua formatação.
Simples não ?
Ações adicionais do Save Action
Se você quiser personalizar ainda mais a sua formatação é possível ainda inserir algumas formatações adicionais. Na tela de Save Actions temos o Configure onde você poderá definir mais configurações que serão executadas ao salvar qualquer classe Java.
Vou tentar explicar um pouco cada uma delas:
Code Style
Responsável em adicionar ou criar blocos fechados({, }) no bloco de IF/while/for/do.Definir se você quer parênteses em condições por exemplo:
(((i > 0) && (i < 10)) || (i == 50)) ou sem (i > 0 && i < 10 || i == 50).
Se quer adicionar o modificador final em todas os parâmetros onde seja necessário, e quais tipos de parâmetros(private, parameter, local variables).
Member Accesses
Usar o “this” em todos as variáveis e métodos locais ou somente onde for necessário. Como devem ser declarados os métodos e variáveis etc.
Unnecessary Code
Como o nome mesmo já diz, remove trechos de códigos desnecessários, como imports de classes que não existem dentre outras configurações.
Missing Code
Adiciona automaticamente as tags “@Override” e “@Deprecated” nos métodos.
Code Organizing
Organiza a ordem do métodos.
Bem essa são as formas simples de como otimizar o código, seja pela formatação dele ou até por simples comentários, mas essa é a intenção, não perder tempo com coisas simples e repetitivas ;).
Abraços e espero ter contribuído com este artigo para agilizar o processo de desenvolvimento.
darknet drug store deep dark web
Go to IRS.gov/Notices to come across further infortmation and facts about responding to an IRS notice or
letter.
Here is my homepage; 유로밀리언
darkmarket 2023 tor darknet
darkmarket link tor market links
darkmarket 2023 dark market onion
free dark web dark web market list
drug markets onion darknet markets
I love wһat you guys ɑre usually up too. This kind of
clever work and exposure! Keep up the wonderful works guys І’ve adԁed you guys to bl᧐grolⅼ. http://wiki.bluevps.com/index.php?title=User:BrigitteSolar82
darkmarket 2023 dark websites
Very descriptive blog, I liked that bit. Will there be a
part 2?
Great article! We will be linking to this particularly great post on our website.
Keep up the good writing.
I am sure this paragraph has touched all the internet visitors, its really really good article on building up new website.
Great artіcle! We will be ⅼinking to this great
pot on ouur website. Keeep up the great writing. https://ncsurobotics.org/wiki/index.php/Dua_Insan_Tersangka_Pemeran_Togel_Topjitu_Link_Alternatif_top_Jitu_Di_Ringkus_Polsek_Bunga_Mayang
darknet drug market dark internet
darkmarkets tor market links
free dark web deep web drug url
Very nice post. I just stumbled upon your blog and wanted to say that
I’ve really enjoyed surfing around your blog posts. After all I’ll
be subscribing to your rss feed and I hope you write again soon!
What’s up, this weekend is good for me, because this occasion i am reading this impressive
informative paragraph here at my home.
Its like you read my mind! You appear to know so much about this, like you wrote the book in it or something.
I think that you can do with a few pics to drive
the message home a bit, but other than that, this is wonderful
blog. A fantastic read. I will definitely be back.
I am regular reader, how are you everybody? This article posted at this
web site is genuinely pleasant.
I was recommended thiѕ website by my cousin. I’m not sure wһether tһis post is wrіtten bby һim аѕ no ᧐ne else
know suych detailed ɑbout my problem. Үoᥙ’re amazing!
Thankѕ!
Here iѕ my homеpage: セックスウェブカメラ
tetracycline canada online
I always emailed this webpage post page to all my contacts, for the reason that if like to read it next my contacts will too.
tor market url dark markets 2023
If you want to obtain much from this paragraph then you have to apply these strategies to your won webpage.
After study a few of the blog posts on your website now, and I truly like your way of blogging. I bookmarked it to my bookmark website list and will be checking back soon. Pls check out my web site as well and let me know what you think.
Earn 500% to 2000% on every coin selection
We analyze the crypto market to find the best coin for
our subscribers to earn money in a short time.
According to a study by the University of Tulsa, the overall success rate for target cycle pumps is
around 50%. However, the success rate can be much higher for
pumps involving obscure coins with low market capitalization.
For example, the study found that the pumps on Telegram increased
the price by more than 18% in just five minutes.
Join our Crypto Profit Group Telegram Channel, you
won’t regret it.
https://t.me/s/cryptospumpanddumpprofit
Medication prescribing information. What side effects?
levitra cost
All trends of medicines. Read now.
We’re a gaggle of volunteers and opening a new scheme
in our community. Your web site provided us with valuable information to work on. You’ve done an impressive
job and our entire neighborhood will likely be grateful to you.
Hi tһere everyone, it’s my first pay a quіck visit aat this web site, aand
piece of writing is realⅼy fгսitfսl designed for me, кeep
up posting these articⅼes.
Also visіt my ѕite … mafia toto
Доставка цветов – это услуга, которая позволяет заказать букеты
или композиции из цветов и доставить их получателю в нужное место и время.
Доставка цветов может осуществляться как внутри одного города,
так и между разными городами или даже странами.
Чтобы заказать доставку цветов, нужно выбрать желаемый букет или композицию на сайте или в магазине, указать адрес и время доставки, а
также сообщить контактные данные получателя.
Многие компании предлагают дополнительные
услуги, например, подпись открытки или добавление
конфет или игрушек к букету.
Доставка цветов может быть организована
в рамках любого события: от Дня Рождения до свадьбы или похорон.
Кроме того, цветы могут быть подарены просто так, чтобы порадовать близкого человека или выразить благодарность.
букет из 101 синего ириса
deep web drug markets dark web links
Write more, thats all I have to say. Literally, it
seems as though you relied on the video to make your point.
You definitely know what youre talking about, why waste your intelligence on just posting videos
to your weblog when you could be giving us something informative to read?
darknet market list dark web drug marketplace
darknet sites deep web drug store
Hello to every body, it’s my first visit of this website; this website consists of
awesome and truly excellent data in favor of visitors.
Since 2014, players have wagered more than $four.five billion in Bitcoin, and crypto gamblers bet
Review my website – 파워볼게임
blackweb official website dark web market links
Piece of writing writing is also a fun, if you be acquainted with then you can write or else it is complex to
write.
Hi there, its good piece of writing on the topic of media print,
we all understand media is a enormous source of facts.
Verу soon this web рage will bbe famous among all blogging people, due to it’s pleaѕant articles
Alsօ visit my web site; mafia toto
Aѕking questions are actuaⅼly pleasant thing iif you
arе not ᥙnderstanding anything entirely, however this paragraph provіdes pleasant understaanding even.
Feel freе to surf to my web рage … kostoto
dark web markets darkmarket 2023
darkmarket url dark market url
If some one wants to be updated with most up-to-date technologies
afterward he must be visit this web page and be up to date all the time.
darknet drug store free dark web
Greetings! I’ve been following your site for a while now and finally got the courage to go
ahead and give you a shout out from Huffman Texas!
Just wanted to say keep up the excellent job!
dark market darknet websites
Paragraph writing is also a excitement, if you be acquainted
with then you can write or else it is complicated to write.
Also visit my web-site: Marital Aids
drug markets dark web tor markets