80
Systematyczny architekt na Systematyczny architekt na drodze ku planowanemu drodze ku planowanemu postarzaniu postarzaniu

Systematyczny architekt na drodze ku planowanemu postarzaniu

Embed Size (px)

Citation preview

Systematyczny architekt na drodze ku planowanemu postarzaniu

O mnie : Jarosaw Paka

Who am I?

Journeyman through space, timeandtechnology

devoted follower in church of JVM

Archaeologist of legacy code

chief architect @ Lumesse

owner/founder @ symentis.pl

blogger @ geekyprimitives.wordpress.com

philosopher @ twitter:j_palka

code mangler @ bitbucket:kcrimson & github:jpalka

evil emperor @ 4developers architecture track

Created weakness for the numbers on the boardAbsurd amount of things, obsolete creationThe lust for always more, indulgence in hungerA greed for power, the demon needs to feedDesigned for failureGojira Planned Obsolescence

strategia producenta, majca na celu takie projektowanie towarw, aby miay one ograniczony czas uytecznego ycia, po tym za okresie staway si niesprawne, a czsto nieopacalne w naprawie. Towary te zwykle psuj si zaraz po upywie gwarancji.Wikipedia

Techniki planowanego postarzania

najlepiej na wczoraj

si poprawi jutro (jutro nie nadejdzie nigdy)

to tylko prototyp (artowalimy)

nie mamy czasu (to po co si zabieracie za ten projekt?)

Jakby tego byo mao

trendy

We are fashion industryUncle Bob

Rewrite

Offload

Modernization

Next Generation Something

Kilka lat pniej

Rewrite

Offload

Modernization

Next Generation Something

I znowy trzeba przepisa

Dobry inynier,Id szukaj business value,szukaj

Podejcie Big-Bang

Uczymy si na ywym organizmie

Ludzie z businessu trzymaj si na dystans

Brak zrozumienia domeny problemu

It is up to us to live up to the legacy that was left for us, and to leave a legacy that is worthy of our children and of future generations.Christine Gregoire

Nie naprawimy przeszoci,Ale moemy uczyni przyszo lepsz

Mzg, cobdziemy dzi robi?

Dodamy kolejny framework!

Przygotujmy si na lepsz przyszo

Przygotujmy si na zmiany

Abstrakcje

Posugujemy si nimi na co dzie

S zapisane w naszej podwiadomoci

Dlatego tak trudno o nich rozmawia

Znaczenie ukryte za fasad sw

Czy mgby otworzy zamek?

Brak jednoznacznoci abstrakcji

Znaczenie = abstrakcja(kontekst)

Polimorfizm

public interface TalkingAboutAbstractions{

public void createEmployee(String candidate);

}

public vois hireCandidate(){

String candidate = "Jan Kowalski";employeeBean.createEmployee(candidate);

candidate = "123456";employeeBean.createEmployee(candidate);

candidate = "{ candidate : {id : \"123456\"} }";employeeBean.createEmployee(candidate);

}

public interface TalkingAboutAbstractions{

public Employee hireCandidate(Suppliercandidate);

}

public interface GuessWhatIHaveInMind{

String serverStatus() throws Exception;

}

OK

Mam si dobrze

Cholera gdzie jest dysk?

Daj mi spokj

!@#$%^&*()

public interface GuessWhatIHaveInMind{

public enum ServerStatus { OK, BUSY, INTERNAL_ERROR }

ServerStatus serverStatus() throws Exception;

}

A teraz czas na co z klasyki

Prawdziwy, Autentyczny,jedyny

Brainfuck

public class BrainFuck extends GenericHibernateDAO{

List processList(String target, Long id);

}

public class BrainFuck extends GenericHibernateDAO{

ResultSet processList(String target, Long id);

}

Use types, Luke!

Mie i by, to nie to samo

Diabe tkwi w szczegach

Generalizacja, uoglnienieis-a

Kompozycja, delegacjahas-a

Uoglniaj na poziomie kontraktuInterfejsu ze wiatem zewntrznym

Kompozycja i delegacjagdy przychodzi czasna Szczegy implementacji

Stosuj obie techniki wiadomie,Naucz si stosowa je wymiennie

Polimorfizm przychodzi W wielu smakach(dziedziczenie to tylko jeden z nich)

Ad hocParametricCoercionInclusion (subtyping)

Buisness logic system constructioncode infrastructure

public class SoftwareConstruction implements BeanFactoryAware, DisposableBean {

@Override@SuppressWarnings("unchecked")public void setBeanFactory(final BeanFactory beanFactory) throws BeansException {consumerConfigurations = (Map)(Object) ((ListableBeanFactory) beanFactory).getBeansOfType(ConsumerConfiguration.class);}

}

Nie mieszajmy odpowiedzialnoci

Odpowiedzialno to nie tylko business features

Obiekt nie moe by odpowiedzialny za skonstruowanie samego siebie

public AlbumPage(PageParameters parameters) {super(parameters);

boolean showDescription = false;

List albums;String searchQuery = parameters.get("search").toString(null);

if (searchQuery == null) {searchQuery = parameters.get(0).toString(null);if (searchQuery != null) {showDescription = true;}}

albums = productCatalog.searchAlbums(searchQuery);

ListView albumsListView = new AlbumsListView(ID_ALBUMS_VIEW, albums, showDescription);

add(albumsListView);}

public interface ShowMeMore{

@GETpublic Response getRoot(@Context HttpServletRequest request);

}

public class ShowMeMoreImpl implements ShowMeMore{

@Contextprivate HttpServletRequest request;

@GETpublic Response getRoot();

}

Struktura systemu

Gsto informacji

Hierarchies are brilliant systems inventions, not only because they give a systemstability and resilience, but also because they reduce the amount of information thatany part of the system has to keep track of.

Hierarchies are brilliant systems inventions, not only because they give a systemstability and resilience, but also because they reduce the amount of information thatany part of the system has to keep track of.

In hierarchical systems relationships within each subsystem are denser and strongerthan relationships between subsystems. Everything is still connected to everythingelse, but not equally strongly.

In hierarchical systems relationships within each subsystem are denser and strongerthan relationships between subsystems. Everything is still connected to everythingelse, but not equally strongly.

Hierarchical systems are partially decomposable. Their subsystems with theirespecially dense information links can function at least partially as systems in theirown right. When hierarchies break down, they usually split along their subsystemboundariesDonella Meadows

Hierarchical systems are partially decomposable. Their subsystems with theirespecially dense information links can function at least partially as systems in theirown right. When hierarchies break down, they usually split along their subsystemboundaries

Value is Your Subsystem Boundary

Kandydat

AplikantKandydat

AplikantKandydatBezrobotny

AplikantKandydatBezrobotny

Value is usually Your subsystem boundary

Encapsulation is the packing of data and functions into a single component.

Hierarchies are brilliant systems inventions, not only because they give a systemstability and resilience, but also because they reduce the amount of information thatany part of the system has to keep track of.

public class WrongEncapsulation{public String name;}

public class IsItEncapsulation{private String name;}

public class JavaStyleEncapsulation{private String name;

public String getName(){ ... };

public void setName(String name){ };

}

Software design porn

public class AnotherStylishClass{

private List strings = new ArrayList();

public List getStrings(){return strings;}

AnotherStylishCase obj = new AnotherStylishCase();

obj.getStrings().add("Hello leaky abstraction!");

}

Testabilitythe ultimate UI

If it's hard to test it will be hard to maintain and even harder to rewritesomebody on the internet

Jakie s granice szalestwa ...

Kiedy znowu zobaczysz Java Bean,usu go,powanie,natychmiast,git rm AnotherStupidJavaBean.java

Jedyne rzeczy ktre warto zapamita

AbstrakcjePolimorfizmContext is King

Gsto informacjiEnkapsulacjaHierarchical Systems

Software construction vs business logic