2. Speaker info
Ivan Pashko, Ukraine
Scrum Master in Betsson, Ciklum
• 8+ years in the IT
• Software Automation Developer
/in/ivan-pashko-33208042/
/groups/1180099188730673
15. Factory Pattern
• Hides the logic of
initializing an object
inside the factory.
• Refers to the object
using a common
interface instead of
the concrete class.
16. Test smell. Inheritance /overrides
Blind inheritance and overrides leads to the
creation of «Monster» objects
17. Composite Pattern
• The composite pattern
describes a group of
objects that is treated the
same way as a single
instance of the same type
of object.
21. Builder Pattern
public class User
{
//Required parameters:
public string Email { get; set; }
public string Login { get; set; }
//Additional parameters:
public string Name { get; set; }
public int Age { get; set; }
public string Address { get; set; }
}
• Typical test user object:
• Required fields
• Additional fields
22. Builder Pattern
//Telescoping constructor
new User(email, login);
new User(email, login, "test name", 18, "test address");
//JavaBeans
new User("test@gmail.com", "test_123")
{
Name = "Name",
Age = 18,
Address = "test address"
};
• Copy / paste
• Constructor overrides
• Helpers methods
As a result:
• A lot of code
• Duplicates
• Unclear defaults
23. Builder Pattern
new UserBuilder("test@gmail.com", "user_123")
.Name("Name")
.Age(18)
.Address("test address")
.Build();
public UserBuilder(string email, string login)
{
_user = new User(email, login)
{
//Default values:
Name = "Default Name",
Age = 18,
Address = "Default address"
};
}
• Easy to read
• Simple to extend
• Safe defaults
24. Your test smells if
• contains if’s
• has a ‘twin brother’
• depends on the data
• doesn’t feet in one screen
• bypass your framework