Podcast
Questions and Answers
What is the primary goal of refactoring?
What is the primary goal of refactoring?
- To fix all bugs in the code
- To add new features to the code
- To optimize the code for performance
- To improve the design of existing code without changing its external behavior (correct)
Which of the following is an example of the "feature envy" code smell?
Which of the following is an example of the "feature envy" code smell?
- A method that has a long parameter list
- A method that performs a specific task
- A method that relies heavily on methods and fields of another class (correct)
- A method with constants and values without labels
List 2 reasons why developers are reluctant to refactor their code?
List 2 reasons why developers are reluctant to refactor their code?
If your code contained a Large class, how would you handle that code smell?
If your code contained a Large class, how would you handle that code smell?
What is the Single Responsibility Principle (SRP)?
What is the Single Responsibility Principle (SRP)?
Code Challenge:
Write a Java class named "Rectangle" with instance variables for length and width. Implement methods to calculate the area and perimeter of the rectangle. Provide a parameterized constructor to initialize the dimensions.
Code Challenge:
Write a Java class named "Rectangle" with instance variables for length and width. Implement methods to calculate the area and perimeter of the rectangle. Provide a parameterized constructor to initialize the dimensions.
Create an interface named "Shape" with an abstract method "calculateArea()". Implement the interface in two classes: "Circle" and "Square". Each class should provide its own implementation of calculateArea().
Create an interface named "Shape" with an abstract method "calculateArea()". Implement the interface in two classes: "Circle" and "Square". Each class should provide its own implementation of calculateArea().