Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
4 votes
1 answer
127 views

Lift simulator in Java

I implement a working version of the Lift Kata Can you provide me some tips to improve my code? I am not very proud of the handleLiftWithOpenDoors method that have ...
fluminis's user avatar
  • 196
3 votes
2 answers
255 views

Immutable employee class

I have created an employee object to be immutable. ...
Rahul Shivsharan's user avatar
8 votes
3 answers
2k views

Stack as a Persistent Data Structure Implementation

After reading some articles about immutability, I found out that there are persistent data structures. In the following, I implemented a stack as a persistent data structure. What I like about the ...
Roman's user avatar
  • 2,903
1 vote
2 answers
2k views

Creating a Student class for a project

To recover from yesterday's disaster, I re-read the SOLID principles and refactored my code. Hopefully I did a better job than yesterday. I wanted to keep my Student...
user avatar
1 vote
2 answers
264 views

Creating Immutable Student Object

For a project I'm working on I have the following requirements: We have two student types: Domestic and International ...
user avatar
0 votes
1 answer
70 views

Class that holds calculation results and has to be immutable

I'm roughly trying to follow the guidelines in "Effective Java", "Item 15: Minimize mutability", hence the class is not "final" on purpose. Information is gathered from a number of temperature ...
user77115's user avatar
  • 103
23 votes
4 answers
28k views

Simple builder pattern implementation for building immutable objects

This is a builder pattern implementation to build immutable Person objects: Person class ...
Levent Divilioglu's user avatar
3 votes
5 answers
295 views

An immutable person

I am trying to model person in OOPS using immutability. I have created an object bond with age as 25. To change the age I have created a new object and returned it. ...
mc20's user avatar
  • 801
6 votes
4 answers
279 views

Creating SOLID immutable and mutable Location types

I have a Location type: ...
Dioxin's user avatar
  • 414
9 votes
4 answers
5k views

Creating unique registration numbers using object factories

I'm learning about immutability and uniqueness in Java, particularly the use of defensive programming and object factories. I have been asked to create a class containing an object factory that when ...
javapalava's user avatar
1 vote
1 answer
105 views

Removing getters for a custom enum [closed]

Recently, I perform re-factor on one of my frequent used custom enum, by removing its getter. My rational for doing so it. The enum's custom fields are immutable Only use getters when it is ...
Cheok Yan Cheng's user avatar
4 votes
2 answers
3k views

Immutable Queue in Java using an Immutable Stack

I am new to this Immutability concept and I have some coding experience in JAVA. Recently as a part of internship program, they gave me a 5-day task, which was to implement Immutable Queue. After some ...
Naruto's user avatar
  • 51
7 votes
4 answers
10k views

Should I copy list both in constructor and in getter?

I have a simple immutable class: ...
Leonid Semyonov's user avatar
39 votes
8 answers
5k views

Immutable objects in Java

I just finished studying immutable objects and their advantages so I thought I'd create one of my own. Here is my employee class that extends a person class. It is not mutable since I have getters to ...
Ishan Soni's user avatar
6 votes
3 answers
42k views

Insert a character into a string

For practicing reasons I would like to write a method which inserts a character into a string. I would like to know: What is the best practice concerning placement of a comment within methods? For ...
C graphics's user avatar

15 30 50 per page