JavaRush /Java Blog /Random EN /Coffee break #39. 6 reasons to know at least one programm...

Coffee break #39. 6 reasons to know at least one programming language. 12 Useful Refactoring Rules

Published in the Random EN group

6 reasons to know at least one programming language

Source: Hackernoon You may have never been exposed to computer science. But there are at least 6 reasons to learn at least one programming language.Coffee break #39.  6 reasons to know at least one programming language.  12 useful refactoring rules - 1

1. To understand where you spend 28,300 hours of your life

According to statistics, most of us spend a significant portion of our lives (28,300 hours) on the Internet, mobile and desktop applications. All these virtual things are created using code. To understand how they work, it is important to have basic programming knowledge.

2. To make your life easier

Programs and technical devices are created to make our lives easier. And while almost all of us interact with them as a user, you too can create applications through programming. For example, setting up a text response using a bot when you are offline. At first glance, this seems like a difficult task, but it is not. You don't even have to write every line of code. You just need to understand what this or that line of code is responsible for, and how it all works. Other programs are created using a similar principle.

3. To be able to create new things

Every device you use, from your cell phone to your electric guitar, uses code to operate. Thus, programming is present in our lives. So no matter what you're passionate about, you can create new things through programming. It doesn’t matter who you are: a musician or a lawyer - now everyone can show their creativity if they know a programming language.

4. To improve your resume

There's nothing wrong with adding something new to your resume, right? So why not add programming as an additional skill? Knowing a programming language can make your resume stand out from others. This will indicate that you are a person who is not afraid to learn something outside the box and is not afraid to take on a challenge. It also shows that you are up to date with modern technology.

5. To strengthen problem solving skills

Programming gives you more than just a body of knowledge. It improves your problem solving skills and also helps improve your patience levels. You may not feel it right away, but it will have a positive impact on many areas of your life in the future.

6. To expand career opportunities

2020 brought us a lot of surprises. The job market has completely changed due to COVID-19. Many professions have lost relevance, and people are trying to find new opportunities for survival. So there is no guarantee that your profession will exist in 30 years. Having a backup option is a wise decision.

When code needs refactoring: 12 useful rules

Source: Medium Refactoring, at its core, is redesigning the code base, changing the internal structure of the program. The refactoring process is often combined with fixing bugs, adding new features, and tuning performance. But don’t forget: refactoring is not code review or error correction.Coffee break #39.  6 reasons to know at least one programming language.  12 useful refactoring rules - 2

Why it's worth taking the time to learn refactoring

If you're a new developer, learning how to refactor code and, more importantly, know when to refactor, will be an important skill for you. Many developers skip refactoring. As a result, their code looks mediocre, confusing, and hard to read. How do you know when your code needs refactoring? There are 12 rules that will help determine this:
  1. Has your class parameter list become too large? Is it difficult to test and debug? Then this is a prime candidate for refactoring.
  2. Are there methods in your code within classes that only use one of the class dependencies? You are better off putting this method in a separate class - even if this class consists of only one method.
  3. Does your method do two different things depending on the value of a boolean parameter? In this case, it is better to create two different methods with clear responsibilities.
  4. Does your method have value branching? For example, you check the type of an object and perform various operations depending on its type. This is a great case to turn your if-elseor switchinto a dictionary.
  5. Do you often use if-elseor switches? Try using polymorphism instead and applying battle-tested design patterns like Strategy or Mediator.
  6. Does your class's constructor or method accept a magic number or string? Replace magic with ordinary enumerations.
  7. Do you have clearly programmed values ​​(numbers or strings)? Instead, take the values ​​as parameters and make them configurable. You'll find it easier to reuse or deploy your application to new environments or change settings.
  8. Do not use variable names like i, j, k, m, n, x. Just stop doing it.
  9. Do you find yourself frequently using the same logic in multiple places? Move the logic into its own class or method.
  10. Are there classes in your code Serviceor Manager? They are like a Swiss Army knife - lots of options that are rarely used. Take a moment to think about what tasks could be used in them, and then move each individual task into its own class.
  11. Do you find it difficult to test a single method because the class it's in takes many constructor arguments? Then take the method out of the class.
  12. Do you need to add a new one else-ifor switchto implement a new requirement or feature? Try using interfaces and reflection for automatic type discovery.

How does refactoring improve the quality of internal software?

When you refactor, you improve one or more characteristics of the code:
  • Maintainability – Make sure you can easily make changes to your software. Maintainability includes adding new features, tuning performance, and making it easy to fix bugs.
  • Flexibility is the range to which you can modify your software to serve other purposes.
  • Portability - How easily you can make the software work in another environment.
  • Reusability - How easily you can use parts of your software on other systems.
  • Readability - How easily you can read and understand the source code, not only at the interface level, but also in the smallest implementation details.
  • Testability - ease of creating unit tests, integration tests.
  • Understanding - How to easily understand your software on a general level. Make sure your codebase has structured content.
Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION