SlideShare a Scribd company logo
1 of 21
Download to read offline
Simple
Pure
Java


                    Anton Keks
             anton@codeborne.com
          
The Enterprise...
           
Enterprise Architecture
    20 years ago a new field was born, addressing

    System complexity = more and more
        money for building IT systems

Poor business alignment = more difficult
  to keep those increasingly expensive
   systems aligned with business need

       A problem of more cost, less value
     Today: even more cost, even less value
                           
Complexity


            
!
         O
      BO
 
    ☠   
Your average Java (web) app
    ●   Framework (JSF?)
    ●   Model
    ●   Portal?
    ●   Services!
    ●   Remote services, SOA, EJB
    ●   JNDI
    ●   Stubs, generated code
    ●   How many layers?
                            
...
    ●   Patterns!
    ●   Factory, Singleton, Facade
    ●   Enterprise patterns!
    ●   DTO, DAO, etc
    ●   Getters/setters
         (what's the deal - generate 'em)
    ●   JPA, JAXB
    ●   JMS!

                            
Bad words

     Layer          Tier    Bus
           Context     Manager
     Locator     Assembler    Bean
             Broker      Facade
       Transfer Object    DAO
                 …
    It's always nice to see guys like
       SessionServiceContextManager
    or AbstractStrategyFactoryProxyFacadeBuilder
                             
EAR, WAR, WAR, WAR
      Configuration, descriptors!
                  JNDI!
                 ESB? ;-)

    Must be a wizard to make it all run!
      Improves job security index :-)
                     
For a small thing we create
    ●   ManagedBean
    ●   MegaServiceWrapper
    ●   CoreServiceLocal, Stub (JNDI lookup?)
    ●   CoreService (&& CoreServiceImpl)
    ●   AggregatedService
    ●   ConcreteService
    ●   ConcreteDAO
    ●   JPAAdapter
 
    ●   ...                  
The result?                             ☠
    ●   It kills productivity
    ●   Thousands lines of code, very few
         functionality
    ●   Well hidden ”business logic”
    ●   N minute deploy time (+ N minutes app
         server startup)
    ●   Oops, sometimes redeploy doesn't work,
         need to restart
    ●   Slow UI responsivness
                                 
What to do?
    ●   Concentrate on domain terminology
          ●   This was the intention of OOP


    ●   Avoid overly defensive code
          ●   You are not writing a framework!
          ●   Fellow developers are friends


    ●   Follow Clean Code by Robert C. Martin

                                
Java platform and language
    ●   Java (EE) is a victim of JCP
           ●   Many unreal/unusable JSRs
    ●   Stick to proven open-source stuff
           ●   Less standards – the better
    ●   Java language is ok
           ●   The biggest miss are closures
           ●   DSLs are possible: Mockito, LambdaJ
           ●   Don't bloat (generate) your code


                                 
Code style
    ●   Is your code style limiting readability?
           ●   Avoid too many line breaks and braces
           ●   Emphasize what is important

        public int   size() {              public int size() {
          if (root   == null) {              if (root == null) return 0;
            return   0;                      return root.numSiblings();
          }                                }
          else {
            return   root.numSiblings();
          }
                                           public int size() {
        }
                                             return root != null ?
                                               root.numSiblings() : 0;
                                           }

                                       
Code style
    ●   Avoid over-indenation (or code ladder)
        public void startCharging() {
          if (customer.hasFunds()) {
            if (!station.isCharging()) {
              if (!station.currentlyBooked()) {
                reallyStartCharging();
                return;
              }
            }
          }
          throw new UnableToStartException();
        }
                          public void startCharging() {
                            if (!customer.hasFunds()) throw new UnableToSta
                            if (station.isCharging()) throw new UnableToSta
                            if (station.currentlyBooked()) throw new Unable

                             reallyStartCharging();
                         }
                                       
Code style
    ●   Prefer shorter code (use static imports)
        List<Integer> list = Arrays.asList(1, 2, 3));
        list = Collections.unmodifieableList(list);
        return list;

        import static java.util.Arrays.*;
        import static java.util.Collections.*;
        ...

        return unmodifiableList(asList(1, 2, 3))

        Looks a bit like functional programming, isn't it?

                                  
Code style
    ●   Prefer good naming to comments
    ●   Avoid getters/setters, equals, hashCode,
         toString unless necessary
    ●   Break free from 'conventions'
    ●   Work towards a DSL

        when(session.currentUser()).thenReturn(fakeUser);

        assertThat(person.age, is(25));

        sort(people, on(Person.class).getAge());

                                 
Proper Java app
    ●   Jetty Launcher (esp in development)
    ●   Know the APIs well: servlets, filters, etc
    ●   Avoid vendor-specific stuff
    ●   Keep environment-specific configuration
         in version control
    ●   Dependency Injection
    ●   Avoid scattering cross-cutting concerns
    ●   DB migrations (w/ liquibase/dbdeploy)

 
    ●   Start thin and simple, prefer higher SNR
                             
Web UI
    ●   Your framework tells you don't need to
         know JavaScript? (GWT, JSF, etc)
    ●   B.S.!
    ●   Keep it under control: learn basics of
         JQuery instead
    ●   Knockout.js, Backbone.js can help
    ●   You are not limited with Java syntax on
         the client side :-)

                             
Worth reminding...

    ● Don't Repeat Yourself
    ● Keep It Simple Stupid


    ● You Ain't Gonna Need It


    ● Test Driven Development




                     
Let's continue on
github:
github.com/angryziber/simple-java




job@codeborne.com
                     

More Related Content

What's hot

Ola Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The JvmOla Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The Jvm
deimos
 
Java compilation
Java compilationJava compilation
Java compilation
Mike Kucera
 
J2EE vs JavaEE
J2EE vs JavaEEJ2EE vs JavaEE
J2EE vs JavaEE
eanimou
 
The Top 30 LotusScript Development Tips
The Top 30 LotusScript Development TipsThe Top 30 LotusScript Development Tips
The Top 30 LotusScript Development Tips
dominion
 

What's hot (20)

Непрерывное тестирование для улучшения качества кода
Непрерывное тестирование для улучшения качества кодаНепрерывное тестирование для улучшения качества кода
Непрерывное тестирование для улучшения качества кода
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
 
Javascript training sample
Javascript training sampleJavascript training sample
Javascript training sample
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
 
An Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and RuntimeAn Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and Runtime
 
Java introduction
Java introductionJava introduction
Java introduction
 
Ola Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The JvmOla Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The Jvm
 
Java compilation
Java compilationJava compilation
Java compilation
 
Java 9, JShell, and Modularity
Java 9, JShell, and ModularityJava 9, JShell, and Modularity
Java 9, JShell, and Modularity
 
Throwing complexity over the wall: Rapid development for enterprise Java (Jav...
Throwing complexity over the wall: Rapid development for enterprise Java (Jav...Throwing complexity over the wall: Rapid development for enterprise Java (Jav...
Throwing complexity over the wall: Rapid development for enterprise Java (Jav...
 
J2EE vs JavaEE
J2EE vs JavaEEJ2EE vs JavaEE
J2EE vs JavaEE
 
Scala: An experience report
Scala: An experience reportScala: An experience report
Scala: An experience report
 
XPDays Ukraine: Legacy
XPDays Ukraine: LegacyXPDays Ukraine: Legacy
XPDays Ukraine: Legacy
 
TDD anche su iOS
TDD anche su iOSTDD anche su iOS
TDD anche su iOS
 
How we tested our code "Google way"
How we tested our code "Google way"How we tested our code "Google way"
How we tested our code "Google way"
 
The Top 30 LotusScript Development Tips
The Top 30 LotusScript Development TipsThe Top 30 LotusScript Development Tips
The Top 30 LotusScript Development Tips
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Java notes | All Basics |
Java notes | All Basics |Java notes | All Basics |
Java notes | All Basics |
 
Acceptance Test Driven Development and Robot Framework
Acceptance Test Driven Development and Robot FrameworkAcceptance Test Driven Development and Robot Framework
Acceptance Test Driven Development and Robot Framework
 
cf.Objective() 2017 - Design patterns - Brad Wood
cf.Objective() 2017 - Design patterns - Brad Woodcf.Objective() 2017 - Design patterns - Brad Wood
cf.Objective() 2017 - Design patterns - Brad Wood
 

Viewers also liked

最新開発支援ツールを使ったデバッグ対応
最新開発支援ツールを使ったデバッグ対応最新開発支援ツールを使ったデバッグ対応
最新開発支援ツールを使ったデバッグ対応
Osamu Monoe
 
マークアップエンジニア だからうれしい Fireworksの使い方あれこれ
マークアップエンジニア だからうれしい Fireworksの使い方あれこれマークアップエンジニア だからうれしい Fireworksの使い方あれこれ
マークアップエンジニア だからうれしい Fireworksの使い方あれこれ
Naoki Matsuda
 
リサーチャーとマーケター原稿2012326
リサーチャーとマーケター原稿2012326リサーチャーとマーケター原稿2012326
リサーチャーとマーケター原稿2012326
Shigeru Kishikawa
 
これから求められるWebコミュニケーションスキル 〜今日から始めるプロトタイプデザイン
これから求められるWebコミュニケーションスキル 〜今日から始めるプロトタイプデザインこれから求められるWebコミュニケーションスキル 〜今日から始めるプロトタイプデザイン
これから求められるWebコミュニケーションスキル 〜今日から始めるプロトタイプデザイン
Yasuhisa Hasegawa
 

Viewers also liked (20)

画像Hacks
画像Hacks画像Hacks
画像Hacks
 
解析データの分析と活用
解析データの分析と活用解析データの分析と活用
解析データの分析と活用
 
3D printing for Development Hack Day in Bucharest, session 1
3D printing for Development Hack Day in Bucharest, session 13D printing for Development Hack Day in Bucharest, session 1
3D printing for Development Hack Day in Bucharest, session 1
 
The Craft of UX
The Craft of UXThe Craft of UX
The Craft of UX
 
最新開発支援ツールを使ったデバッグ対応
最新開発支援ツールを使ったデバッグ対応最新開発支援ツールを使ったデバッグ対応
最新開発支援ツールを使ったデバッグ対応
 
デザイナーがエンジニアさんと楽しくデザイン実装の話をするために
デザイナーがエンジニアさんと楽しくデザイン実装の話をするためにデザイナーがエンジニアさんと楽しくデザイン実装の話をするために
デザイナーがエンジニアさんと楽しくデザイン実装の話をするために
 
WordPressコミュニティの魅力 | OSC Nagoya 2012 WordBench Nagoya
WordPressコミュニティの魅力 | OSC Nagoya 2012 WordBench NagoyaWordPressコミュニティの魅力 | OSC Nagoya 2012 WordBench Nagoya
WordPressコミュニティの魅力 | OSC Nagoya 2012 WordBench Nagoya
 
マークアップエンジニア だからうれしい Fireworksの使い方あれこれ
マークアップエンジニア だからうれしい Fireworksの使い方あれこれマークアップエンジニア だからうれしい Fireworksの使い方あれこれ
マークアップエンジニア だからうれしい Fireworksの使い方あれこれ
 
Transformative Web Design ~変化にしなやかに対応するデザイン力~
Transformative Web Design ~変化にしなやかに対応するデザイン力~Transformative Web Design ~変化にしなやかに対応するデザイン力~
Transformative Web Design ~変化にしなやかに対応するデザイン力~
 
Debugging mobile websites and web apps
Debugging mobile websites and web appsDebugging mobile websites and web apps
Debugging mobile websites and web apps
 
リサーチャーとマーケター原稿2012326
リサーチャーとマーケター原稿2012326リサーチャーとマーケター原稿2012326
リサーチャーとマーケター原稿2012326
 
WebフレームワークXSS対策の自動化
WebフレームワークXSS対策の自動化WebフレームワークXSS対策の自動化
WebフレームワークXSS対策の自動化
 
『デザイニング・インターフェース』読書会資料
『デザイニング・インターフェース』読書会資料『デザイニング・インターフェース』読書会資料
『デザイニング・インターフェース』読書会資料
 
Developing with Phonegap - Adobe Refresh 2012
Developing with Phonegap - Adobe Refresh 2012Developing with Phonegap - Adobe Refresh 2012
Developing with Phonegap - Adobe Refresh 2012
 
言語の世界
言語の世界言語の世界
言語の世界
 
これから求められるWebコミュニケーションスキル 〜今日から始めるプロトタイプデザイン
これから求められるWebコミュニケーションスキル 〜今日から始めるプロトタイプデザインこれから求められるWebコミュニケーションスキル 〜今日から始めるプロトタイプデザイン
これから求められるWebコミュニケーションスキル 〜今日から始めるプロトタイプデザイン
 
6 Key Elements to a Good Website
6 Key Elements to a Good Website6 Key Elements to a Good Website
6 Key Elements to a Good Website
 
JavaFX
JavaFXJavaFX
JavaFX
 
デジタルインテリジェンスの「構想力」
デジタルインテリジェンスの「構想力」デジタルインテリジェンスの「構想力」
デジタルインテリジェンスの「構想力」
 
【16-D-4】3分ではじめるスマホアプリのビジュアル開発
【16-D-4】3分ではじめるスマホアプリのビジュアル開発【16-D-4】3分ではじめるスマホアプリのビジュアル開発
【16-D-4】3分ではじめるスマホアプリのビジュアル開発
 

Similar to Simple Pure Java

[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
Sang Don Kim
 
Productivity Enhencement with Visual Studio
Productivity Enhencement with Visual StudioProductivity Enhencement with Visual Studio
Productivity Enhencement with Visual Studio
Ahasan Habib
 
Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011
Agora Group
 

Similar to Simple Pure Java (20)

Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScript
 
"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James Nelson"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James Nelson
 
Developing cross platform desktop application with Ruby
Developing cross platform desktop application with RubyDeveloping cross platform desktop application with Ruby
Developing cross platform desktop application with Ruby
 
Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
 
AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8
 
Old code doesn't stink
Old code doesn't stinkOld code doesn't stink
Old code doesn't stink
 
Productivity Enhencement with Visual Studio
Productivity Enhencement with Visual StudioProductivity Enhencement with Visual Studio
Productivity Enhencement with Visual Studio
 
Java - A broad introduction
Java - A broad introductionJava - A broad introduction
Java - A broad introduction
 
Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011
 
Road to sbt 1.0 paved with server
Road to sbt 1.0   paved with serverRoad to sbt 1.0   paved with server
Road to sbt 1.0 paved with server
 
Java one 2015 [con3339]
Java one 2015 [con3339]Java one 2015 [con3339]
Java one 2015 [con3339]
 
Skiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in DSkiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in D
 
Nodejs
NodejsNodejs
Nodejs
 
Real-world polyglot programming on the JVM - Ben Summers (ONEIS)
Real-world polyglot programming on the JVM  - Ben Summers (ONEIS)Real-world polyglot programming on the JVM  - Ben Summers (ONEIS)
Real-world polyglot programming on the JVM - Ben Summers (ONEIS)
 
An overview of node.js
An overview of node.jsAn overview of node.js
An overview of node.js
 
Java one 2010
Java one 2010Java one 2010
Java one 2010
 
Scala on-android
Scala on-androidScala on-android
Scala on-android
 
Design Summit - UI Roadmap - Dan Clarizio, Martin Povolny
Design Summit - UI Roadmap - Dan Clarizio, Martin PovolnyDesign Summit - UI Roadmap - Dan Clarizio, Martin Povolny
Design Summit - UI Roadmap - Dan Clarizio, Martin Povolny
 
Pysec
PysecPysec
Pysec
 

More from Anton Keks

More from Anton Keks (18)

Being a professional software tester
Being a professional software testerBeing a professional software tester
Being a professional software tester
 
Java Course 14: Beans, Applets, GUI
Java Course 14: Beans, Applets, GUIJava Course 14: Beans, Applets, GUI
Java Course 14: Beans, Applets, GUI
 
Java Course 13: JDBC & Logging
Java Course 13: JDBC & LoggingJava Course 13: JDBC & Logging
Java Course 13: JDBC & Logging
 
Java Course 12: XML & XSL, Web & Servlets
Java Course 12: XML & XSL, Web & ServletsJava Course 12: XML & XSL, Web & Servlets
Java Course 12: XML & XSL, Web & Servlets
 
Java Course 11: Design Patterns
Java Course 11: Design PatternsJava Course 11: Design Patterns
Java Course 11: Design Patterns
 
Java Course 10: Threads and Concurrency
Java Course 10: Threads and ConcurrencyJava Course 10: Threads and Concurrency
Java Course 10: Threads and Concurrency
 
Java Course 9: Networking and Reflection
Java Course 9: Networking and ReflectionJava Course 9: Networking and Reflection
Java Course 9: Networking and Reflection
 
Java Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and StreamsJava Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and Streams
 
Java Course 7: Text processing, Charsets & Encodings
Java Course 7: Text processing, Charsets & EncodingsJava Course 7: Text processing, Charsets & Encodings
Java Course 7: Text processing, Charsets & Encodings
 
Java Course 6: Introduction to Agile
Java Course 6: Introduction to AgileJava Course 6: Introduction to Agile
Java Course 6: Introduction to Agile
 
Java Course 5: Enums, Generics, Assertions
Java Course 5: Enums, Generics, AssertionsJava Course 5: Enums, Generics, Assertions
Java Course 5: Enums, Generics, Assertions
 
Java Course 4: Exceptions & Collections
Java Course 4: Exceptions & CollectionsJava Course 4: Exceptions & Collections
Java Course 4: Exceptions & Collections
 
Java Course 3: OOP
Java Course 3: OOPJava Course 3: OOP
Java Course 3: OOP
 
Java Course 2: Basics
Java Course 2: BasicsJava Course 2: Basics
Java Course 2: Basics
 
Java Course 1: Introduction
Java Course 1: IntroductionJava Course 1: Introduction
Java Course 1: Introduction
 
Java Course 15: Ant, Scripting, Spring, Hibernate
Java Course 15: Ant, Scripting, Spring, HibernateJava Course 15: Ant, Scripting, Spring, Hibernate
Java Course 15: Ant, Scripting, Spring, Hibernate
 
Scrum is not enough - being a successful agile engineer
Scrum is not enough - being a successful agile engineerScrum is not enough - being a successful agile engineer
Scrum is not enough - being a successful agile engineer
 
Being a Professional Software Developer
Being a Professional Software DeveloperBeing a Professional Software Developer
Being a Professional Software Developer
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

Simple Pure Java

  • 1. Simple Pure Java Anton Keks anton@codeborne.com    
  • 3. Enterprise Architecture 20 years ago a new field was born, addressing System complexity = more and more money for building IT systems Poor business alignment = more difficult to keep those increasingly expensive systems aligned with business need A problem of more cost, less value Today: even more cost, even less value    
  • 5. ! O BO   ☠  
  • 6. Your average Java (web) app ● Framework (JSF?) ● Model ● Portal? ● Services! ● Remote services, SOA, EJB ● JNDI ● Stubs, generated code ● How many layers?    
  • 7. ... ● Patterns! ● Factory, Singleton, Facade ● Enterprise patterns! ● DTO, DAO, etc ● Getters/setters (what's the deal - generate 'em) ● JPA, JAXB ● JMS!    
  • 8. Bad words Layer Tier Bus Context Manager Locator Assembler Bean Broker Facade Transfer Object DAO … It's always nice to see guys like SessionServiceContextManager or AbstractStrategyFactoryProxyFacadeBuilder    
  • 9. EAR, WAR, WAR, WAR Configuration, descriptors! JNDI! ESB? ;-) Must be a wizard to make it all run! Improves job security index :-)    
  • 10. For a small thing we create ● ManagedBean ● MegaServiceWrapper ● CoreServiceLocal, Stub (JNDI lookup?) ● CoreService (&& CoreServiceImpl) ● AggregatedService ● ConcreteService ● ConcreteDAO ● JPAAdapter   ● ...  
  • 11. The result? ☠ ● It kills productivity ● Thousands lines of code, very few functionality ● Well hidden ”business logic” ● N minute deploy time (+ N minutes app server startup) ● Oops, sometimes redeploy doesn't work, need to restart ● Slow UI responsivness    
  • 12. What to do? ● Concentrate on domain terminology ● This was the intention of OOP ● Avoid overly defensive code ● You are not writing a framework! ● Fellow developers are friends ● Follow Clean Code by Robert C. Martin    
  • 13. Java platform and language ● Java (EE) is a victim of JCP ● Many unreal/unusable JSRs ● Stick to proven open-source stuff ● Less standards – the better ● Java language is ok ● The biggest miss are closures ● DSLs are possible: Mockito, LambdaJ ● Don't bloat (generate) your code    
  • 14. Code style ● Is your code style limiting readability? ● Avoid too many line breaks and braces ● Emphasize what is important public int size() { public int size() { if (root == null) { if (root == null) return 0; return 0; return root.numSiblings(); } } else { return root.numSiblings(); } public int size() { } return root != null ? root.numSiblings() : 0; }    
  • 15. Code style ● Avoid over-indenation (or code ladder) public void startCharging() { if (customer.hasFunds()) { if (!station.isCharging()) { if (!station.currentlyBooked()) { reallyStartCharging(); return; } } } throw new UnableToStartException(); } public void startCharging() { if (!customer.hasFunds()) throw new UnableToSta if (station.isCharging()) throw new UnableToSta if (station.currentlyBooked()) throw new Unable reallyStartCharging(); }    
  • 16. Code style ● Prefer shorter code (use static imports) List<Integer> list = Arrays.asList(1, 2, 3)); list = Collections.unmodifieableList(list); return list; import static java.util.Arrays.*; import static java.util.Collections.*; ... return unmodifiableList(asList(1, 2, 3)) Looks a bit like functional programming, isn't it?    
  • 17. Code style ● Prefer good naming to comments ● Avoid getters/setters, equals, hashCode, toString unless necessary ● Break free from 'conventions' ● Work towards a DSL when(session.currentUser()).thenReturn(fakeUser); assertThat(person.age, is(25)); sort(people, on(Person.class).getAge());    
  • 18. Proper Java app ● Jetty Launcher (esp in development) ● Know the APIs well: servlets, filters, etc ● Avoid vendor-specific stuff ● Keep environment-specific configuration in version control ● Dependency Injection ● Avoid scattering cross-cutting concerns ● DB migrations (w/ liquibase/dbdeploy)   ● Start thin and simple, prefer higher SNR  
  • 19. Web UI ● Your framework tells you don't need to know JavaScript? (GWT, JSF, etc) ● B.S.! ● Keep it under control: learn basics of JQuery instead ● Knockout.js, Backbone.js can help ● You are not limited with Java syntax on the client side :-)    
  • 20. Worth reminding... ● Don't Repeat Yourself ● Keep It Simple Stupid ● You Ain't Gonna Need It ● Test Driven Development