2014 jeeconf - cargo culting and memes

65
Cargo Culting and Memes Nicolas Fränkel JEE Conf, Kiev, May 2014

Upload: nicolas-frankel

Post on 02-Jul-2015

619 views

Category:

Software


1 download

TRANSCRIPT

Page 1: 2014 JEEConf - Cargo Culting and Memes

Cargo Cultingand Memes

Nicolas Fränkel

JEE Conf, Kiev, May 2014

Page 2: 2014 JEEConf - Cargo Culting and Memes

Me, myself and I

Developer & Architect as consultant

Wide range of businesses & customers

Teacher & Trainer

Blogger

blog.frankel.ch

morevaadin.com

@nicolas_frankel 2

Page 3: 2014 JEEConf - Cargo Culting and Memes

Also an author

3

Page 4: 2014 JEEConf - Cargo Culting and Memes

E-commerce company

Rocks

Sends employees to Oktoberfest

4@nicolas_frankel

Page 5: 2014 JEEConf - Cargo Culting and Memes

Cargo culting vs memes

@nicolas_frankel 5

Page 6: 2014 JEEConf - Cargo Culting and Memes

Cargo culting

Reproducing outer form in order to

get some benefits regardless of

contexts

@nicolas_frankel 6

Page 7: 2014 JEEConf - Cargo Culting and Memes

Memes

Widespread ideas

With no (or shallow) scientific proof behind

@nicolas_frankel 7

Page 8: 2014 JEEConf - Cargo Culting and Memes

Disclaimer

“All characters appearing in this

work are fictitious. Any

resemblance to real persons, living

or dead, is purely coincidental.”

@nicolas_frankel 8

Page 9: 2014 JEEConf - Cargo Culting and Memes

Do not believe me!

You are not getting sleepy!

I do not want to spread more cargo

culting & memes

Try…

@nicolas_frankel 9

Page 10: 2014 JEEConf - Cargo Culting and Memes

Cargo culting

@nicolas_frankel 10

Page 11: 2014 JEEConf - Cargo Culting and Memes

Imagine living on a paradise island

Free from daily world contingencies

@nicolas_frankel 11

Page 12: 2014 JEEConf - Cargo Culting and Memes

Then come some white people in

birds of steel

They build some stuff, and bigger

birds of steel come, with bunches

of people inside

@nicolas_frankel 12

Page 13: 2014 JEEConf - Cargo Culting and Memes

And the birds of steel have plenty

of good food inside

With no need to go fishing…

@nicolas_frankel 13

Page 14: 2014 JEEConf - Cargo Culting and Memes

When they all go away, what’s the

smart thing to do:

Go fishing again?

Or build the same stuff and hope to attract

more birds of steel?

Very crude summary of Cargo

Culting during WWII (in the Pacific)

@nicolas_frankel 14

Page 15: 2014 JEEConf - Cargo Culting and Memes

The devil is in the detail

Once upon a time, there was a

young developer

He started using Java 1.3

And was taught that local variable

declaration was heavy on

performance

@nicolas_frankel 15

Page 16: 2014 JEEConf - Cargo Culting and Memes

Some years later, he became an

« expert »

And wrote some good practices

guidelines

Including declaring local variables

outside loops

int nb = 0;

for (int i = 0;

i<n; i++) {

...

}

Page 17: 2014 JEEConf - Cargo Culting and Memes

He was very happy

And all developers happily followed

his rules

@nicolas_frankel 17

Page 18: 2014 JEEConf - Cargo Culting and Memes

Until… a new developer came in

town

And threw the gauntlet by claiming:

« You shall declare your variables in the

narrowest scope possible »

This meant inside the loop

@nicolas_frankel 18

Page 19: 2014 JEEConf - Cargo Culting and Memes

The « expert » accepted the

challenge

And coded a small snippet to assert

his claims

It failed miserably…

JDK 1.4 was smart enough to

produce the exact same bytecode

regardless where the variable was

declared

@nicolas_frankel 19

Page 20: 2014 JEEConf - Cargo Culting and Memes

The « expert » was sorely

disappointed

But realized a very important fact

« There’s no universal truth, it all

depends on the context »

@nicolas_frankel 20

Page 21: 2014 JEEConf - Cargo Culting and Memes

Also applies to:

Food

Religion

Sports

You name it

@nicolas_frankel 21

Page 22: 2014 JEEConf - Cargo Culting and Memes

Facts

At this time, I don’t know if that was

ever true

I suppose it was

I found nothing supporting this (or

the opposite) on the Internet

Downloading and installing Java 1.3 sucks

@nicolas_frankel 22

Page 23: 2014 JEEConf - Cargo Culting and Memes

Data Transfer Object

Once upon a time, there was

platform called J2EE

Which provided a bunch of API

@nicolas_frankel 23

Page 24: 2014 JEEConf - Cargo Culting and Memes

EJB Entity - a real heavyweight

object, was bound to the container

So Sun crafted a magical artifact,

the DTO

To allow for data to go outside the

container

@nicolas_frankel 24

Page 25: 2014 JEEConf - Cargo Culting and Memes

The birth of EJB 3 brought a new

Golden Age

And freed people of the tyranny of

the EJB Container

Sadly, many developers still flock to

the banner of the DTO

@nicolas_frankel 25

Page 26: 2014 JEEConf - Cargo Culting and Memes

Alternatives

1. When no association required

Use the entity directly

2. Use eager associations

3. Use the OpenSessionInView

filter

4. Call getters to force load

5. Use JOIN FETCH

@nicolas_frankel 26

Page 27: 2014 JEEConf - Cargo Culting and Memes

Data Access Object

Among other J2EE weapons of

power was the DAO

It was mighty indeed

As it could decouple your

application from persistence stores

of that time

JDBC

JDO

EJB Entity

@nicolas_frankel 27

Page 28: 2014 JEEConf - Cargo Culting and Memes

Agility was at your fingertips!

Change from JDBC to JDO

And back again (?)

@nicolas_frankel 28

Page 29: 2014 JEEConf - Cargo Culting and Memes

Back then, DAO had its uses

Try JDO

Then rollback if when something went wrong

@nicolas_frankel 29

Page 30: 2014 JEEConf - Cargo Culting and Memes

The fall of the DAO

Nowadays, heroes use JPA!

Already an abstraction

Or a concrete implementation

For good reasons

But some fallen knights lies to

themselves in thinking they will

change their data store

Or it will require such a major rework DAO

cannot insulate them from

SQL to NoSQL

@nicolas_frankel 30

Page 31: 2014 JEEConf - Cargo Culting and Memes

Alternatives

JPA makes the EntityManager the

DAO

Spring Data has a different

abstraction

Repository

Only when using implementations

one might need DAO

To migrate from one document-based

NoSQL store to another document-based

@nicolas_frankel 31

Page 32: 2014 JEEConf - Cargo Culting and Memes

XML is BAD

10 years ago, it was all XML

Can be validated against a schema

XML became evil with the coming of

annotations in Java 5

@nicolas_frankel 32

Page 33: 2014 JEEConf - Cargo Culting and Memes

Critics against XML

Verbose

Are not compiled

Errors (beyond grammar) are discovered at

runtime

@nicolas_frankel 33

Page 34: 2014 JEEConf - Cargo Culting and Memes

Self-annotated classes

@Service

@Scope("prototype")

public class MyBean {

@Autowired

private MyRepository myRepo;

...

}

@nicolas_frankel 34

Page 35: 2014 JEEConf - Cargo Culting and Memes

Pros Cons

Everything in the same place Couples code to Spring

Compiled Prevents reusability

Allows bad design

@nicolas_frankel 35

Page 36: 2014 JEEConf - Cargo Culting and Memes

Alternatives

XML

JavaConfig

Compiled

With no con of self-annotated classes

@nicolas_frankel 36

Page 37: 2014 JEEConf - Cargo Culting and Memes

Javaconfig Example

@Configuration

public class JavaConfig {

@Bean

@Scope(SCOPE_PROTOTYPE)

public class myBean() {

return new MyBean(myRepo());

}

@Bean

public class myRepo() {

return new MyRepository();

}

}

@nicolas_frankel 37

Page 38: 2014 JEEConf - Cargo Culting and Memes

Related to Cargo Culting

Copy-Paste Driven Programming

Reverse Cargo Culting:

Forget the form because the context is

different

@nicolas_frankel 38

Page 39: 2014 JEEConf - Cargo Culting and Memes

Spotting Cargo Culting

“We’ve always done like that”

“It’s always been working”

@nicolas_frankel 39

Page 40: 2014 JEEConf - Cargo Culting and Memes

How not to Cargo Cult

Question reasons behind decisions

You cannot always be up-to-date

Listen to others and their arguments

Admit you’re wrong (when you are)

Yes, it’s hard and time-consuming!

@nicolas_frankel 40

Page 41: 2014 JEEConf - Cargo Culting and Memes

Memes

@nicolas_frankel 41

Page 42: 2014 JEEConf - Cargo Culting and Memes

Memes

Cargo Culting can be remedied if

the cultist is rational and willing to

listen

Memes are way more pervasive

Based on faith

And you never can convince a

faithful to renounce his faith

Only if he’s not a true faithful

@nicolas_frankel 42

Page 43: 2014 JEEConf - Cargo Culting and Memes

My Illumination

The Leprechauns of Software

Engineering

@nicolas_frankel 43

Page 44: 2014 JEEConf - Cargo Culting and Memes

The 10X productivity rule

“A good programmer can be as 10X

times more productive than a

mediocre one”

@nicolas_frankel 44

Page 45: 2014 JEEConf - Cargo Culting and Memes

Sackman & al. 1968

“exploratory experiments (...) to

compare debugging performances

of programmers working under

conditions of online and offline

access to a computer”

Ratio of 28:1

Subject 7 required 170 hours to program the

algebra program in a batch environment in

machine language

Subject 3 required 6 hours to program the

same problem in ALGOL in a time-shared

environment

@nicolas_frankel 45

Page 46: 2014 JEEConf - Cargo Culting and Memes

Ref. Direct? Task

type

Sample

size

Pop. Measure Variation

Curtis 1981 N Debug 27 Pros Time-to-

compile

22:1

8:1

Mills 1983 Y ? ? ? ? 10:1

DeMarco &

Lister 1985

Y Program

to spec

166 Pros Time-to-

complete

5,6:1

Curtis & al.

1986

N N/A N/A N/A N/A Various

Card 1987 N Project ? Pros LOC per staff

hour

Not

claimed

Boehm &

Pappacio

1988

N N/A N/A N/A N/A Various

Valet &

McGarry

1989

N Project 150 Pros LOC per staff

hour

Not

claimed

Boehm 2000 Y Project 161

projects

Pros Manager’s

evaluation

Not

claimed@nicolas_frankel 46

Page 47: 2014 JEEConf - Cargo Culting and Memes

Productivity in software

Which metrics?

LOC?

Any is trivial to game...

Which task?

Must be the same in order to compare

Which population?

Pros have other things to do

@nicolas_frankel 47

Page 48: 2014 JEEConf - Cargo Culting and Memes

My experience

There’s a difference in productivity

But I never could quantify

I can only say if one developer is

more productive than another in a

specific area

Software is a team effort!

@nicolas_frankel 48

Page 49: 2014 JEEConf - Cargo Culting and Memes

But rejoice!

Other domains are not free of

memes either

Project Management

Graphical Design

@nicolas_frankel 49

Page 50: 2014 JEEConf - Cargo Culting and Memes

@nicolas_frankel 50

Page 51: 2014 JEEConf - Cargo Culting and Memes

The source of “truth”

Software Engineering Economics –

Boehm, 1981

Made famous in Rapid Development

– McConnell, 1996

@nicolas_frankel 51

Page 52: 2014 JEEConf - Cargo Culting and Memes

It makes sense that uncertainty

decreases with time passing...

Does it make sense that:

It is symmetric?

It follows f(x) = -a/x?

@nicolas_frankel 52

Page 53: 2014 JEEConf - Cargo Culting and Memes

My experience

@nicolas_frankel 53

Page 54: 2014 JEEConf - Cargo Culting and Memes

Images are read LTR

When I was younger (a long time

ago), I was told that images should

be designed to be read left-to-right

And right-to-left for native Arab / Hebrew

speakers

@nicolas_frankel 54

Page 55: 2014 JEEConf - Cargo Culting and Memes

Then came a device to follow eyes

movements

And they made an experience on

the TV

@nicolas_frankel 55

Page 56: 2014 JEEConf - Cargo Culting and Memes

@nicolas_frankel 56

Page 57: 2014 JEEConf - Cargo Culting and Memes

RELATED TO MEMES

“No True Scotsman” Logical fallacy

Ideology

@nicolas_frankel 57

Page 58: 2014 JEEConf - Cargo Culting and Memes

No true Scotsman

“Scotsmen do not put sugar on

their porridge

- I’m a Scotsman and I put sugar on

my porridge

- No true Scotsman sugars his

porridge”

@nicolas_frankel 58

Page 59: 2014 JEEConf - Cargo Culting and Memes

Code is self-documenting

“Yet I cannot make this code clear

without comments.

- Then it’s bad code!”

@nicolas_frankel 59

Page 60: 2014 JEEConf - Cargo Culting and Memes

Agile delivers

“Yet my last Agile project went

wrong.

- Then it must not have been truly

Agile”

@nicolas_frankel 60

Page 61: 2014 JEEConf - Cargo Culting and Memes

Ideology

Memes and ideologies are based on

faith

Memes are largely shared

Ideologies are more restricted

Counter-ideologies

@nicolas_frankel 61

Page 62: 2014 JEEConf - Cargo Culting and Memes

This is crap

It’s not proper:

Object-Oriented Programming

Functional Programming

You name yours

@nicolas_frankel 62

Page 63: 2014 JEEConf - Cargo Culting and Memes

Those are ways!

My goal is to achieve those

properties:

Readability

Testability

Maintainability

So long as I get them, I don’t care

Better to have a unique paradigm in an

application

@nicolas_frankel 63

Page 64: 2014 JEEConf - Cargo Culting and Memes

Spotting Memes

@nicolas_frankel 64

Page 65: 2014 JEEConf - Cargo Culting and Memes

Thank you for your interest

@nicolas_frankel

@learnvaadin

@itfromtrenches

http://blog.frankel.ch/

http://morevaadin.com/