7 kyu

Lombok Builder.

Description:

Having this class:

public class People{
   public int age;
   public String name;
   public String lastName;
   String GREET="hello";
   
   public String greet(){
     return GREET+" my name is "+name;
   }
 }
 

We want to:

  • Encapsulate properly the class by providing read accessors (setters are not required for this Kata).
  • Implement the Builder design Pattern.
  • Additionally we have allegedly a JIT compiler and we want to do some micro-optimization by marking constants in the code.

Constants

In Java, constants are creating by adding the final keyword, but only primitives are true constants if we have objects that are not primitives marked as constants they actually have their memory location constant, not the values. It's pretty useful to optimize memory in JIT compilers since they can actually reserve memory before we use the variables and having the confidence in that their memory locations will not be changed through the scope.

Builder Design Pattern

This design pattern help us create instances of the object by specifying all of the data in (Dementor) chain of calls style in any order. The object creation is optimized by creating the instance only when the build method is called. If we call a method twice in the builder the value of the field will be the second setted.

Note: If you don't use Lombok for this Kata ensure proper naming conventions are followed.

Object-oriented Programming
Design Patterns
Refactoring

Stats:

CreatedNov 9, 2017
PublishedNov 14, 2017
Warriors Trained1247
Total Skips16
Total Code Submissions2953
Total Times Completed424
Java Completions424
Total Stars21
% of votes with a positive feedback rating66% of 76
Total "Very Satisfied" Votes40
Total "Somewhat Satisfied" Votes21
Total "Not Satisfied" Votes15
Total Rank Assessments3
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • Javatlacati Avatar
  • Voile Avatar
Ad