teleren/devto huggingface dataset:
Effective Java: Optimize Judiciously
Tags: java, effective, optimization, architecture
Published: 2021-07-01 14:42:39

---
title: Effective Java: Optimize Judiciously
published: true
description: A dive into chapter 66 of Effective Java
tags: java, effective, optimization, architecture
series: Effective Java Review
canonical_url: https://blog.scaledcode.com/blog/effective-java/optimize_judiciously/
---

There are a number of sayings that have grown in popularity in the technical industry:

> We _should_ forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil
- Donald E. Knuth

> We follow two rules in the matter of optimization:
Rule 1: Don't do it.
Rule 2: (for experts only) Don't do it yet--that is, not until you have a perfectly clear and unoptimized solution
- M. A. Jackson

It's pretty clear that there are major concerns with optimizing applications early. A root of a lot of these concerns is that when trying to optimize we can often do more harm than good. This harm can be lower maintainability, unreadable code, or even worse performance. In the grand scene of things the benefit we have is that when we write well architected code we often end up with more performant code. Even when we don't start off with more performant code, the well architected code can allow the actual helpful optimization to be written. 

Even though well architected code often does lead to more performant code there are some decisions we can make that can paint ourselves in a corner. These decisions would be largely where we make decisions that affect the performance of the API itself. Examples of this would be returning mutable collections or values from a method requiring copies to be made, using inheritance which ties your implementation to it's parent's class, or returning too much unnecessary data when a more scoped call could be used. Your API becomes your contract, a bad contract design can cause issues for the foreseeable future. It's best to get these decisions correct from the outset. 

After making a solid design and designing your API correctly you may still find that the performance of your code is not to your liking. How do you know what to optimize though? If you just try to guess at what is slow you are likely to make a wrong guess. This is where tools such as profilers are invaluable. Profilers can highlight the code paths that are problematic and also help you understand if your code changes are actually making a difference. Another tool that can help determine if code changes are making positive benefits to your code is to use the Java Microbenchmark Harness (JMH). This tool provides a framework to write benchmarking tests that help you gain visibility into the performance of specific code paths. 

The Java virtual machine (JVM) has been extremely optimized over decades of time. This allows it to take lots of different code and come up with an optimized executable code. Often it is in the best interest to just trust the virtual machine off the bat and only optimize once we know concrete items to focus on and fix.
Hack Reactor Struggles
Published: 2021-07-01 14:39:32

Reporting to you live Week 3, Day 3.

I'm sitting in a morning lecture on Redux now, refraining from banging my head on the desk because: A - that would hurt and B - I'm on camera.

I would love to be able to sit through a lecture and absorb the information presented. But that's not how my brain works. I think HR should recognize that lecture-based learning just isn't for everyone.

Here are some alternatives that would work better for me:

* Allow us to watch a re-play of this video on fast-forward. That tends to keep me more engaged.
* Present the material in slides or some other text-based form.

This is agonizing for me, because it feels like I'm wasting time. I'm not learning. Instead, I'm falling behind my classmates who are able to keep up in this format.

I'm going to have to eat into my assignment time to get a handle on the lecture content, giving me less time for the assignment.

Ok, the lecture just shifted into demo-mode. This is more my speed. Seeing how things work, seeing how the parts interact. 

---

Lecture-based learning really isn't for me. I struggled with it through high school and college (and before) and I struggle with it now. We're all different, and that's something that's perhaps different about me. I'm ok with that.

The frustrating part isn't the feeling of not absorbing the information. It's knowing that there are ways that do work for me. Give me the slides, give me something to read, to study. My brain can work with that.

If you don't experience what I'm describing, it could be hard to relate or understand, so here's a situation that I think is somewhat more common. You know how it can be hard to understand what you're reading when you read out loud (to a group, for instance)? How your own voice might get in the way, or you're thinking about your enunciation, or something else is preventing you from deeply connecting with the words that are coming out of your mouth? That's how it feels for me - to hear the words, to know them, and then be unable to connect them.

I don't mean to describe it as some sort of aphasia. I can drill in for periods of time and grind out the focused listening energy. But it takes an effort that is incredibly difficult to sustain, and moreover, doesn't really feel necessary to fight.

Again, there are so many ways of delivering learning content,  and I feel like there's a missed opportunity in my own educational experience right now.
Kahoot - Uma ferramenta de interatividade
Published: 2021-07-01 14:17:18

![Kahoot!](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/47j4yk0ymr78r2kiol8e.png)
Fala Dev! Tudo beleza? Então, hoje venho apresentar para vocês um site que oferece um serviço incrível! A interatividade com pessoas! E estas pessoas podem ser sua família, seu time do trabalho, seus amigos, colegas de sala, até os parceiros de bar, clube da Luluzinha etc! É muito legal!

São vários exemplos que podemos usar e vou tentar retratar alguns aqui:

Imagine que trabalha em uma squad de uma empresa e você queira fazer uma dinâmica com todos do time para engajar as pessoas, testar conhecimento ou até mesmo implemetar alguma tática Agilista com perguntas do tipo "Essa sprint foi boa", "Essa sprint foi ruim", "Qual foi o problema dessa sprint". O **Kahoot!** faz iso de uma forma incrível, através do site totalmente dinâmico.

Neste exemplo, o Agilista cadastra todas as perguntas no painel e seleciona o tipo da pergunta (pode ser quiz, true/false, quiz, quadro aberto etc).
![Tela com pin](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nc6iwcjzn1tzeraen6mo.png)
Log em seguida, ao dar start no jogo, cada participante também entra no mesmo site e entra jogo informando o código PIN (que é gerado ao dar start no jogo)
![Tela user](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qsip5p57zhyic1ghn2h4.png)
Quando um usuário entra, seu nome aparece na tela para todos.
![Tela nome](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ebbdykrj0j9k6o45lwa.png)

### Que comece o jogo!
Ao dar start, as perguntas são lançadas na tela principal, onde o participante deverá pressionar no botão correspondente à resposta correta.
![Pergunta](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eulb1n7wbh8apag2aa49.png)
Se ele responde corretamente, ele ganha ponto!
![Ganhou!](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mp51p2pxbbdpfyrnkyzo.png)
E aí a dinâmica acontece! É um jogo envolvente, que instiga a competividade colaborativa de uma forma muito divertida! O som ambiente é muito legal também!

Dei o exemplo em uma squad em time de desenvolvimento, mas imagine agora usar como "Jogo da Verdade", amplamente jogado pelos adolescentes dos anos 90/2000? Neste momento de pandemia com isolamento social, esta ferramenta pode ser bastante útil para conectar pessoas! Pense por exemplo um jogo do "copo cheio" entre os amigos de bar, ou reunião de final de ano com família e parentes com pergunta do tipo "Quem come mais na família?" ou "Quem é o mais velho, Fulano ou Ciclano?".

Agora, caso não queira criar para usar em seu ambiente, o **Kahoot!** também permite que você entre em jogos que já estão em andamento. Muito bom quando você está sozinho e quer se divertir um pouco. Na Sessão Discovery é possível fazer buscas por categorias e simplesmente entrar e começar a jogar. Há várias categorias, como o famoso jogo Trívia, Social, Disney, ciênia e tecnologia, filmes, músicas entre outros diversos temas.

Acesse aqui [o site Kahoot!](http://kahoot.it).
Hand Wave Animation Using HTML & CSS
Tags: html, css, webdev, javascript
Published: 2021-07-01 14:13:51

Hello Guys,

Today I created an Amazing Hand Wave Animation. In this animation, I am using only HTML CSS to create animation.

In this html I am using `a` tag & `span` tag and in the simple css to wave the hand emoji I'm use `transform: rotate` so please checkout this post. I hope you find this useful like and save this post also comments about your thoughts and new ideas for a topic. For more content follow me on Instagram [@developer_nikhil27](https://www.instagram.com/developer_nikhil27/).

Thank you!

{% codepen https://codepen.io/NikhilBobade/pen/qBmdayV %}

{% instagram CQTooauBwo2 %}
git clone and long paths on windows
Published: 2021-07-01 14:11:16

If you ever run in to the issue that you can't clone a git repo because it contains paths longer than 260 characters on windows run
```powershell
git config --global core.longpaths true
```

There is a registry entry for long paths as well but that doesn't help here.
```powershell
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem]
"LongPathsEnabled"=dword:00000001
```
How did I build a free status page for my website?
Tags: tutorial, webdev
Published: 2021-07-01 13:33:58

In the days of the Covid-19 lockdown in Ho Chi Minh, Vietnam. I have been working from home for the past 2 months. In my free time, I share how to create a status statistics page, although it seems quite new or there are paid packages with great features, but for personal needs I choose free services.

You can see my site demo at http://status.eplus.dev

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4a9mj6uqhm92a32pckce.png)

[You can register here](https://updown.io/r/5Rnx7 "You can register here")
 
Sign up for an account
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pl2shos1h4qwrdsd9mb1.png)

Enter the website address you need to track
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vwfrc59jja59vomkicyw.png)

See the stats page we just created will have the format https://updown.io/xxxx . Example: https://updown.io/2yy9
![Screenshot 2021-07-01 202037](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q234fmpugo6hbmzji4m1.png)

Don't forget to make your page public
![Screenshot 2021-07-01 203150](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/thm9lh5su4hd9yx766cs.png)

#### Custom domain status page
In order to have your status page available under your own subdomain,
you need to create a CNAME record from your subdomain to xxxx.status.updown.io
(xxxx being your check token, visible in your status page URL).

For example, in order to direct https://status.example.com to https://updown.io/2yy9,
you need to create a CNAME entry status.example.com pointing to 2yy9.status.updown.io.
Example: https://status.eplus.dev

An SSL certificate will automatically be generated for your custom domains.
Also, your status page must be PUBLIC, otherwise you'll get a 404.

![Screenshot 2021-07-01 203028](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lyidow7vyhz7gafp0of4.png)

Good luck
How To Measure The Success Of Your Mobile App?

Tags: apps, software
Published: 2021-07-01 13:31:04

Nearly 25% of apps downloaded are never used more than once. Creating an engaging user experience is becoming more important as brands develop their mobile offerings and hope to meet user expectations. You invest all your money and time to build a successful mobile app, but only that is not sufficient for the app to become successful in real life. But how can you measure the success of mobile app? You have to analyze its performance with some metrics. Let us see which are those metrics. You can work around your app data and make it positive towards your app performance.

#Mobile App Metrics To Measure The Success Of Mobile App- 
**1. App Downloads-**
The number of app downloads shows the number of users that installed your app on their mobile devices. But only this cannot decide the count. Some users might have uninstalled app and reinstalled again. So, you should consider the time interval they have re-installed the app and consider it as a count. If there are not many downloads of your app, you need to work on your app in terms of marketing promotions.

Know the tips to increase app downloads at- What you should do to get more downloads to your app(app store optimization tips)?

**2. Active App Users-**
Active users are different from users who download your app. Users may download app but not use it regularly. In this case, this active app user metric helps you analyse how many users are frequently visiting your pages and simplify details by calculating session activity and 30 minutes of inactivity also. With this, you can get the details of users of your app and take necessary actions to improve the number of users and retain existing users. 

**3. Session Length-**
Session length is measured as the timespan between app open and close, or when the app times out after 15 seconds. This indicates the that how much time your users are spending in app per individual session. Tracking of user session length is critical to unlock revenue potential in your app flows, or the different in-app scenarios that users encounter. If you’ve got mCommerce app, how long does your checkout flow take? If average session length is five minutes and your checkout flow takes six, you need to either encounter users to stay in the app longer time.

**4. App Session Intervals-**
It measures how frequently a user returns to your mobile app. This parameter defines how engaged your users are. If the interval between two consecutive visits is short, the level of engagement will be higher. Best trick to improve app session interval metric is to make your mobile app a part of user’s daily routine. Ensure that your mobile app is made well for disruption that would happen in between and so when user logs back, they do not need to start from the scratch. 

Know more at- [https://solaceinfotech.com/blog/how-to-measure-the-success-of-your-mobile-app/]
Time complexity is actually easy!!
Tags: algorithms, computerscience, datastructure, complexity
Published: 2021-07-01 13:23:18

Time complexity in simple words can be described as the number of steps executed in order to reach the final output.It depends on the ram , other simultaneously running threads and so on.

The first type is **O(1)**
So it means for any number of input the output is constant single step. For example
```
n=int(input())
if(n>0)
   print("Hello World")
```
Second one is **O(n)**
This means that the number of steps to get to the final result is equal to the input of the program.
```
n=4
for(int i=0;i<n;i++){
   System.out.println("Hello world");
}
```
Next is **O(n^2)**
This can be calculated simply multiplying the length of the nested arrays

**O(log(n))**
Example take a binary tree for a possible of all binary representation of digits like 1 or 0... or take binary search as an example 
We are dividing each time time based on the condition till we get the element we searched for So the time complexity of both these cases are logn

_Thank you or reading_
Time complexity is actually easy!!
Tags: algorithms, computerscience, datastructure, complexity
Published: 2021-07-01 13:21:16

Time complexity in simple words can be described as the number of steps executed in order to reach the final output.It depends on the ram , other simultaneously running threads and so on.

The first type is **O(1)**
So it means for any number of input the output is constant single step. For example
```
n=int(input())
if(n>0)
   print("Hello World")
```
Second one is **O(n)**
This means that the number of steps to get to the final result is equal to the input of the program.
```
n=4
for(int i=0;i<n;i++){
   System.out.println("Hello world");
}
```
Next is **O(n^2)**
This can be calculated simply multiplying the length of the nested arrays

**O(log(n)) **
Example take a binary tree for a possible of all binary representation of digits like 1 or 0 ... or take binary search as an example 
We are dividing each time time based on the condition till we gwt the element we searched for So the time complexity of both these cases are logn

_Thank you or reading_
How to add Discord OAuth to your SvelteKit web application
Tags: sveltekit, svelte, discord, oauth2
Published: 2021-07-01 13:15:41

In this guide I will show you how to bundle your SvelteKit app with Discord OAuth that’s handled on the server side of your web application.

**You can access the guide on Medium: 
https://msyyn.medium.com/how-to-add-discord-oauth-to-your-sveltekit-web-application-7c2e69d7656e**

You should be familiar with the basic concepts of SvelteKit and Discord to get most out of this guide. If you are looking for a quick start template, you can use my [sveltekit-discord-oauth-starter](https://github.com/msyyn/sveltekit-discord-oauth-starter) template that has same project structure than this guide offers.

Looking for an Sapper alternative? Check out my [Sapper version of this guide here](https://msyyn.medium.com/how-to-add-discord-oauth-to-your-sapper-web-application-bd67b3e80a93).
Red Berries Web Design Company in Dubai
Tags: webdev, webdesigncompanyinduba, websitedesigncompanydubai
Published: 2021-07-01 13:03:59

Red Berries is a Website Design company in Dubai that nourishes brands through crisp and fresh web technology. Launched in the market with a fresh approach of offering intelligent representations on web marketing platforms, Red Berries help the clients engage better with customers. Red Berries’ lively and creative solutions mixed with the right tools and ingredients can make any brand leverage that desired target reach.


<a href="https://redberries.ae/services/web-design-company-dubai-uae/">Web Design Company in Dubai</a>
GMB Reinstatement Service
Tags: gmbreinstatementservice
Published: 2021-07-01 12:54:08

<p>Get <strong><em><a href="https://wearedaisy.com/gmb-reinstatement/">GMB Reinstatement Service</a></em></strong> from Digital Daisy in India. We are here to revive your suspended GMB listing so that you receive uninterrupted business inquiries and store visits. We guarantee to reinstate your GMB with almost all the posts and reviews at a success rate of 99%. For more information follow our hashtag #rankpopper on major social media platforms.</p>
<p>Google My Business (GMB) is the lifeline for local marketers to get organic traffic and leads. With our 98% success rate, we are providing <em>GMB reinstatement service</em> with assurance of retrieving all the photos and reviews. We are one of the top experts on Google My Business reinstatement. Click on &lsquo;Reinstate My GMB&rsquo; to restore your reviews and rankings.&nbsp;</p>
<p>It feels helpless when GMB is suspended, no phone calls, not appearing in SERPs hence business seems to be at pause. In these tough times, Digital Daisy is a ray of hope for you. Avail Our <strong><em>GMB Reinstatement service</em></strong> today and be relaxed.&nbsp;</p>
<p>A Google My Business suspension is the point at which your GMB is no longer visible on Google and Google Maps or you have failed to keep a grip on your posting. You will realize that your posting has been suspended when you see this warning in your GMB dashboard</p>
Animated pacman in HTML/CSS
Tags: css, html, animation, pacman
Published: 2021-07-01 12:42:30

You never know when you need a pacman to appear on your site. And when you do, you need it to be lightweight and performant.

Inspired by https://codepen.io/wifi, https://codepen.io/wifi/pen/olKxE

Lets make our pacman HTML structure, eye is optional I guess.

```html
  <div class="pacman">
    <div class="eye"></div>    
  </div>
```

My pacman is more squareish, since that is what i needed, feel free to change the border radius to 50%, and have a more default looking figure.

```css
.pacman {
  background-color: yellow;
  border-radius: 24px;
  height: 210px;
  width: 210px;
  clip-path: polygon(100% 0, 100% 25%, 50% 50%, 50% 50%, 100% 75%, 100% 100%, 0 100%, 0 0);
}
```

![Screenshot 2021-07-01 at 14-36-41 CSS3 Animated Pacman](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mohz8ludtnvf5p3islo7.png)


Lets animate it! Drop the clip-path, and add the keyframe animation. Set it to infinite and alternate direction. An unnessesary complicated animation curve, and your pacman lives!

```css
.pacman {
  animation: mouth .35s infinite cubic-bezier(0.85, 0, 0.15, 1);
  animation-direction: alternate;
}

@keyframes mouth {
  0% { clip-path: polygon(100% 0, 100% 25%, 50% 50%, 50% 50%, 100% 75%, 100% 100%, 0 100%, 0 0) }
  100% { clip-path: polygon(100% 0, 100% 50%, 50% 50%, 50% 50%, 100% 50%, 100% 100%, 0 100%, 0 0) }
}
```

All together with some food:

{% codepen https://codepen.io/lfberge/pen/xxdGZYr %}
50 Great Websites for Web Developers!
Tags: news, webdev, webpack, javascript
Published: 2021-07-01 12:36:14

    

1. [Hidden Tools] -
https://hiddentools.dev/

2. [Music For Programming] -
https://musicforprogramming.net/

3. [Programming Language Convertor] -
https://ide.onelang.io/

4. [HTTP Cat] -
https://http.cat/

5. [Iconscout] -
https://iconscout.com/

6. [CSS Zen Garden] -
http://www.csszengarden.com/

7. [A List Apart] -
https://alistapart.com/


8. [Code Project] -
https://www.codeproject.com/


9. [Scotch] -
https://scotch.io/


10. [TutsPlus] -
https://tutsplus.com/

11. [Creative Blog] -
https://www.creativebloq.com/

12. [Codrops] -
https://tympanus.net/codrops/

13. [MDN Web Docs] -
https://developer.mozilla.org/zh-CN/

14. [The Odin Project] -
https://www.theodinproject.com/

15. [Code Wars] -
https://www.codewars.com/

16. [WpSessions]-
https://wpsessions.com/

17. [CSS Autor] -
https://cssauthor.com/


18. [Laracasts]-
https://laracasts.com/

19. [Web Design News] -
https://www.webdesignernews.com/

20. [UX Movement] -
https://uxmovement.com/

21. [Gradient Magic] -
https://www.gradientmagic.com/

22. [Trianglify] - 
https://trianglify.io/

23. [CSS Tricks] -
https://css-tricks.com/

24. [Free Frontend] -
https://freefrontend.com/

25. [Code My UI] -
https://codemyui.com/

26. [CSS Reference] -
https://cssreference.io/



27. [HTML Reference] -
https://htmlreference.io/


28. [Frontend Mentor] -
https://www.frontendmentor.io/

29. [Site Point] -
https://www.sitepoint.com/

30. [Free CSS] -
https://www.free-css.com/

31. [Awesome Python] -
https://pythonawesome.com/

32. [Fun JavaScript Projects] -
https://fun-javascript-projects.com/



33. [Daily Dev] -
https://daily.dev/

34. [Dev Docs] -
https://devdocs.io/


35. [ShortCode Dev] -
https://shortcode.dev/



36. [What Runs] -
https://www.whatruns.com/

37. [1LOC] -
https://1loc.dev/

38. [Web Code Tools] -
https://webcode.tools/


39. [Am I Responsive] -
http://ami.responsivedesign.is/

40. [Shape Divider] - 
https://www.shapedivider.app/


41. [Fancy Border Radius] -
https://9elements.github.io/fancy-border-radius/


42. [CSS Gradient] -
https://cssgradient.io/


43. [CSS Clip Path] -
https://bennettfeely.com/clippy/

44. [CSS Layout] -
https://csslayout.io/


45. 30 Seconds Of Code -
https://www.30secondsofcode.org/


46. Undraw -
https://undraw.co/


47. Humaaans -
https://www.humaaans.com/



48. W3 Layouts -
https://w3layouts.com/

49. Templatemo -
https://templatemo.com/

50. Tooplate -
https://www.tooplate.com/