Roadmap
This presentation is the property of its rightful owner.
Sponsored Links
1 / 9

Roadmap PowerPoint PPT Presentation


  • 76 Views
  • Uploaded on
  • Presentation posted in: General

Roadmap. Generics Abstract Factory Annotations Model-Driven Engineering. Design Patterns, a preview…. “Each pattern describes a problem which occurs over and over again in our environment; and it describes the core of the solution to that problem, in such a way that

Download Presentation

Roadmap

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Roadmap

P2 — Clients and Servers

Roadmap

  • Generics

  • Abstract Factory

  • Annotations

  • Model-Driven Engineering


Design patterns a preview

P2 — Clients and Servers

Design Patterns, a preview…

“Each pattern describes a problem which occurs over

and over again in our environment; and it describes the

core of the solution to that problem, in such a way that

you can use this solution a million times over…”

— Christopher Alexander


Creational patterns

P2 — Clients and Servers

Creational Patterns

… deal with the best way to create objects


Abstract factory pattern

P2 — Clients and Servers

Abstract Factory Pattern

  • A Factory is the location in the code at which objects are created.

  • Provides an interface for creating families of related dependent objects.

  • Let clients create products in any family of products in an abstract way, without having to specify their concrete class.

  • Separates the details of implementation of a set of objects from its general usage.


Structure of the abstract factory pattern

ConcreteFactory1

createProduct()

ConcreteFactory2

createProduct()

P2 — Clients and Servers

Structure of the Abstract Factory Pattern

AbstractFactory

createProduct()

Client

AbstractProduct

concreteProduct


Abstract factory with generics ludo example

P2 — Clients and Servers

Abstract Factory with Generics: Ludo Example

package ludo;

// NOTE interface for "Abstract Factory" pattern.

public interface Factory<T> {

public T createInstance();

}


The concrete factory

P2 — Clients and Servers

The Concrete Factory

package ludo;

public class LudoFactory implements Factory<Ludo> {

public Ludo createInstance() {

initializeHome();

initializeBranchings();

initializeMainRing(quarterLength);

initializeHomeRuns(quarterLength);

initializeNests();

return new Ludo(nest);

}

We specify the

type to be Ludo


The ludo example

«interface»

AbstractFactory

createInstance() : T

«interface»

Board

addPlayer(Player )

LudoFactory

createInstance() : Ludo

Ludo

P2 — Clients and Servers

The Ludo Example


The client drives the ludo game

P2 — Clients and Servers

The Client drives the Ludo Game

The Driver can drive any Board game

public class Driver implements Runnable {

private Board board;

public Driver(Factory<? extends Board> factory) {

this.board = factory.createInstance();

board.addPlayer(new Player());

board.addPlayer(new Player());

board.addPlayer(new Player());

}

We specify the Game Factory we want

public class Main {

public static void main(String[] args) {

Runnable gameDriver = new Driver(new LudoFactory());

gameDriver.run();

}


  • Login