• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

in28minutes/java-best-practices: Best practices in Coding, Designing and Archite ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

in28minutes/java-best-practices

开源软件地址:

https://github.com/in28minutes/java-best-practices

开源编程语言:


开源软件介绍:

Java Best Practices

I've been Programming, Designing and Architecting Java applications for 15 years. I would like this page to serve as a good starting point for programmers to understand what it takes to build good applications. I would talk about Best practices and Frequently asked questions in Coding, Designing and Architecting Java Applications.

Learn from the Top 5 Best Selling Courses

Image

Image

Image

Image Image

Image

Image

Reskill with the Amazing in28Minutes Learning Paths

Java Best Practices

Journey of a Programmer

How to become a good programmer?

How to become a good programmer?

What do you think about while you code

  • Am I going to understand this in 3 months time?
  • Am I trying to be too clever: is there a simpler way to get the job done?
  • Can I write this in such a way as to make some parts re-usable?
  • Have I written anything before that I could re-use here?
  • What's for dinner?
  • Am I going to be able to easily test this?
  • Is the first programmer who will read the code going to send a snippet to The Daily WTF?

Important Things to Learn

  • Spring
  • Unit Testing
  • TDD
  • Microservices Architecture

Ask Why?

  • Question Everything!

Books

  • Code Complete by Steve McConnell.
  • Clean Code- A Handbook of Agile Software Craftsmanship
  • The Pragmatic Programmer: From Journeyman to Master by Andrew Hunt
  • Effective Java (2nd Edition) by Joshua Bloch
  • Refactoring: Improving the Design of Existing Code by Martin Fowler
  • Test Driven Development: By Example by Kent Beck

Katas

Programming FAQ

Should I be an expert at all Design Patterns?

What are NFRs?

  • Performance
  • Scalability
  • Maintainability
  • Portability
  • Availability
  • Security
  • Testability etc..

Coding

Java Tips

Why should you have minimum scope for variables?

Why should you understand performance of String Concatenation?

What are the best practices with Exception Handling?

  • Do not ignore exceptions
  • When coding, think what will the guy debugging a problem here would need?
  • Microservices - Centralized logging & correlation id

When is it recommended to prefer Unchecked Exceptions?

  • Spring Framework

When do you use a Marker Interface?

Why are ENUMS important for Readable Code?

Avoid String when other types are appropriate

Why should you minimize mutability?

What is functional programming?

Why should you prefer Builder Pattern to build complex objects?

Why should you avoid floats for Calculations?

Why should you build the riskiest high priority features first?

Code Quality

Code Quality Overview

Code Quality Overview

  • An overview : https://github.com/in28minutes/java-best-practices/blob/master/pdf/CodeQuality.pdf
  • More than everything else, code quality is an attitude. Either, the team has it or not. The attitude to refactor when something is wrong. The attitude to be a boy scout. As an architect, it is important to create an environment where such an attitude is appreciated. (There are always bad sheep, who take the code quality to such depth that it is not fun anymore, but I like them more than developers who keep churning out bad code).
  • Have a good static analysis tool(and is part of Continuous Integration). Sonar is the best bet today. Understand the limits of Static Analysis. Static Analysis is not a magic wand. For me, results from Static Analysis are a signal: It helps me decide where I should look during peer or architect reviews?
  • Have good peer review practices in place. Every user story has to be peer reviewed. Put more focus on peer reviews when there is a new developer or there is a new technical change being done. Make best use of Pair Programming. The debate is ongoing : Is pair programming more productive or not? I would rather stay out of it. You make your choice. However, these two scenarios are bare minimum:
  • Onboarding a new programmer. Makes him comfortable with all the new things he has to encounter.
  • Implementing a complex functionality.
  • Next question is how to approach a Code Review. Difficult to cover everything. I would make a start. When doing a code review, I start with static analysis results (for example, sonar). I spend 10 minutes getting an overview of components and/or layers (focusing on size and dependencies). Next I would pick up a unit test for a complex functionality. I feel unit tests are the best place to discover the dependencies and naming practices (I believe good names = 50% of maintainable code). If a programmer can write a simple and understandable unit test, he can definitely write good code. Next, I look for 4 principles of Simple Design. After this, there are 100 other things we can look for - You decide.

Why should you not take code quality tools at face value?

  • If a project has a great Sonar report, does it mean it is perfect?
  • Nope, code quality tools are just a guidance!
  • Your focus should be to write code that adheres to "4 Principles of Simple Design"
  • Peer Reviews are necessary!

Why should you have coding standards?

What are the most important coding standards?

  • Complexity of a method
  • Naming variables, methods and classes
  • Size of methods and classes
  • Number of parameters

What is Pair Programming?

Why is readable code important?

Static Code Analysis

Static Code Analysis

SONAR

Code Reviews

Modern Development Practices

Modern Development Practices

  • Unit Testing and Mocking : We are in the age of continuous integration and delivery, and the basic thing that enables those is having a good set of unit test in place. (Don’t confuse unit testing with screen testing done manually to check if the screen flow is right. What I mean by unit testing is JUnit test’s checking the business logic/screen flow in a java method (or) set of methods). Understand JUnit. Here is a good start : https://courses.in28minutes.com/p/junit-tutorial-for-beginners. Also understand the concept of Mocking. When should we mock? And when we should not? Complicated question indeed. Understand one mocking framework : Mockito is the most popular one. Easymock is a good mocking framework as well.
  • Automated Integration Tests. Automated Integration Tests is the second important bullet in enabling continuous delivery. Understand Fitnesse, Cucumber and Protractor.
  • TDD (actually I wanted to put it first). Understand what TDD is. If you have never used TDD, then be ready for a rude shock. Its not easy to change a routine you developed during decades (or years) of programming. Once you are used to TDD you never go back. I promise. This list of videos is a good start to understanding TDD. https://www.youtube.com/watch?v=xubiP8WoT4E&list=PLBD6D61C0A9F671F6. Have fun.
  • BDD. In my experience, I found BDD a great tool to enable communication between the ready team (Business Analysts, Product Owner) and the done team (Developers, Testers, Operations). When User Stories are nothing but a set of scenarios specified is GWT (Given When Then) format, it is easy for the done team to chew at the user story scenario by scenario. With tools like Cucumber & Fitnesse, tooling is not far behind too. Do check BDD out.
  • Refactoring. Is there an Architect who does not encounter bad code? Understand refactoring. Understand the role of automation tests in refactoring.
  • Continuous Integration. Every project today has continuous integration. But, the real question is “What is under Continuous Integration?”. Compilation, unit tests and code quality gate(s) is the bare minimum. If you have integration and chain tests, wonderful. But make sure the build does not take long. Immediate feedback is important. If needed, create a separate build scheduled less frequently for slower tests (integration and chain tests). Jenkins is the most popular Continuous Integration tool today. [[ModernDevelopmentPractices.png]]

Unit Testing

Unit Testing Best Practices

Unit Testing Best Practices

Why is unit testing important?

Why is performance of Unit Tests important?

Do not be fooled by Code Coverage!

Why should a good programmer understand Mocking?

What is TDD?

Why should you write unit tests with/before code?

What is BDD?

What is ATDD?

When should you have multiple CI builds?

Continuous Integration

Continuous Integration - Important Questions

  • How often is code commited?
  • How early are problems/defects found/fixed?
  • Code Quality, Code Review, ST Defects
  • Broken Builds?
  • How often is code deployed to production?
  • How often is code deployed to test environment?
  • How different is deploying code to local or test environment from deploying code to production?
  • What steps are in continuous integration? More steps in continuous integration means more stability.
  • Compilation
  • Unit Tests
  • Code Quality Gates
  • Integration Tests
  • Deployment
  • Chain Tests
  • How long does a Continuous Integration build run for? Is there a need for multiple builds?

DevOps

  • Typically Enterprise Teams are made up of number of teams - Dev, QA, DBA,Administrators, Operations, Project and Release Management.
  • Each team works in silos. Some teams have contradicting goals. Dev team wants to push their features live as soon as possible where as Operations want stability. Operations are measured on availability.
  • Reliance on documentation and hand-offs.
  • Devops aims at making these teams work together focused on single goal - Delivering value to end customers safely.
  • Single Leadership.
  • Continuous Delivery.

Design

热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap