Presentation is loading. Please wait.

Presentation is loading. Please wait.

Bc. Matej Kováč Vedúci projektu: prof. Ing. Pavol Návrat, PhD.

Similar presentations


Presentation on theme: "Bc. Matej Kováč Vedúci projektu: prof. Ing. Pavol Návrat, PhD."— Presentation transcript:

1 Bc. Matej Kováč Vedúci projektu: prof. Ing. Pavol Návrat, PhD.
Refaktorizácia softvérových systémov s podporou kontextového odporúčania Bc. Matej Kováč Vedúci projektu: prof. Ing. Pavol Návrat, PhD.

2 Refaktorizácia a návrhové vzory
GoF, Design Patterns: Elements of Reusable Object-Oriented Software M. Fowler, Refactoring: Improving the design of existing code J. Kerievsky, Refactoring to Patterns

3 Ciele práce Vytvorenie prístupu pre identifikáciu nedostatkov v návrhu existujúcich systémov, ktoré je možné odstrániť zavedením návrhových vzorov Zakomponovanie prístupu do existujúceho vývojového prostredia

4 JDeodorant: Refaktorizácia so vnášaním polymorfizmu
N. Tsantalis and A. Chatzigeorgiou, Identification of refactoring opportunities introducing polymorphism, Elsevier, 2009.

5 public class Square extends Shape {
private double side; public double calculateArea() { return side * side; }

6 public class CarStore {
public Car createCar(EquipmentClass equipmentClass) { // deklarácie premenných a pod. switch (equipmentClass) { case COMFORT: engine = new DieselEngine(); seat = new FabricSeat(); transmission = new ManualTransmission(); break; case SPORT: engine = new PetrolEngine(); seat = new SportSeat(); transmission = new DualClutchTransmission(); case LUXURY: engine = new HybridEngine(); seat = new LeatherSeat(); transmission = new AutomaticTransmission(); } return new Car(engine, seat, transmission); aaa}

7 public class CarStore {
public Car createCar(EquipmentClass equipmentClass) { // deklarácie premenných a pod. switch (equipmentClass) { case COMFORT: engine = new DieselEngine(); seat = new FabricSeat(); transmission = new ManualTransmission(); break; case SPORT: engine = new PetrolEngine(); seat = new SportSeat(); transmission = new DualClutchTransmission(); case LUXURY: engine = new HybridEngine(); seat = new LeatherSeat(); transmission = new AutomaticTransmission(); } return new Car(engine, seat, transmission); aaa}

8 Abstract Factory

9 Abstract Factory Factory Method Engine Seat Transmission COMFORT 1
switch (equipmentClass) { case COMFORT: engine = new DieselEngine(); seat = new FabricSeat(); transmission = new ManualTransmission(); break; case SPORT: engine = new PetrolEngine(); transmission = new DualTransmission(); case LUXURY: engine = new HybridEngine(); seat = new LeatherSeat(); transmission = new AutomaticTransmission(); } switch (equipmentClass) { case COMFORT: engine = new DieselEngine(); seat = new FabricSeat(); break; case SPORT: engine = new PetrolEngine(); case LUXURY: engine = new HybridEngine(); something = new SomethingElse(); } Engine Seat Transmission COMFORT 1 SPORT LUXURY Engine Seat COMFORT 1 SPORT LUXURY Abstract Factory Factory Method

10 Builder public class Car { private String model; // povinný atribút
private String brand; // povinný atribút private Color color; // nepovinný atribút private EquipmentClass equipment; // nepovinný atribút public Car(String model, String brand) { this(model, brand, null); } public Car(String model, String brand, Color color) { this(model, brand, color, null); public Car(String model, String brand, Color color, EquipmentClass equipment) { this.model = model; this.brand = brand; this.color = color; this.equipment = equipment;

11 Builder public class CarSeller { private Car car;
public void prepareCar() { Car car = new Car(); car.setColor(new Color(255,255,255)); car.setBrand("Audi"); car.setModel("A3"); car.setId(1L); car.setWheels(4); } Joshua Bloch. Effective Java. Java Series. Pearson Education, 2008.

12 Mediator

13

14 Plán Podpora pre nasadenie inštancií odporúčaných vzorov
Overenie riešenia

15 Zhrnutie Odporúčané vzory: Odporúčania na úrovni: Abstract Factory
Builder Factory Method Mediator Odporúčania na úrovni: Kompilačných jednotiek (.java súbor) Balíkov Projektov

16


Download ppt "Bc. Matej Kováč Vedúci projektu: prof. Ing. Pavol Návrat, PhD."

Similar presentations


Ads by Google