SlideShare a Scribd company logo
The programming philosophy of jRQL

Frank Leja, May 2012
My goals
You wanna …
• be flexible and agile for changing customer demands?
• develop faster in the long run without reducing quality?
• don‘t invent the wheel again and again?

• write reliable code?
• write errorless code?
• write highly reusable code?


… check out this guide, if you want to improve your style!



                                                             take the chance
… follow these small steps to improve yourself …
You write services!
Think of every class and method
as a service you provide
for users not having your knowledge of the domain.                                   unmistakable

Means
• your classes and methods forms an API

• tell your users with your code what they can do (public)
• how you do it (implementation) is private (encapsulation), could be changed!

• public method and parameter names focus on what not how
• take 10s to think on good names!
                                                                                          reliable
• all possible usage scenarios should work! (formBean setter problem)
• or force user for only one usage possibility (method calling order)

• caches has to be maintained transparently (for the user) (e.g. in instance variables)

• full javadoc with all parameters and possible return values described
• handle every problem, even it „could not happen“ (prevent NullPointerExceptions)
think on options: see this
ProjectDetailsFormBean    public void saveProjectDetails(ProjectDetailsFormBean formBean) {
.setBpm(String)
.setDescription(String)       // write the data into CRX
                              this.setProperty(ProjectConstants.DESCRIPTION, formBean.getDescription());
.setEndDate(Calendar)         this.setProperty(ProjectConstants.OWNER, formBean.getBpm());
.setItm(String)               this.setProperty(ProjectConstants.OWNER2, formBean.getItm());
.setName(String)              this.setProperty(ProjectConstants.START_DATE, formBean.getStartDate());
.setStartDate(Calendar)       this.setProperty(ProjectConstants.END_DATE, formBean.getEndDate());
.setStatus(String)            this.setProperty(ProjectConstants.STATUS, formBean.getStatus());


If not all set* methods used, the save method will go wrong.

How can this problem be solved?


  1. with FormBean?                  my option:
  2. without FormBean?               • no form bean at all, bc only used once for all attributes
                                     • direct usage of parameter values in method
  What do you prefer and why?
Think on all options and decide wisely and
  consious
there are always options how to solve a problem or implement a task

1. think on all possible options you could imagine

2. for every option think on the pros and cons

3. choose the option which best matches the goals given in this guide
Dry
Never break this rule!
                                                                                Easy to
Don‘t repeat yourself! or Once and Only Once (see wikipedia)                    change

public method1() {
if (getOwnerProfile() != null) {
                                            public boolean hasOwnerProfile() {
…
                                                     return getOwnerProfile() != null;
public method2() {
                                            }
if (getOwnerProfile() != null) {
…                                                                               Safe to
                                                                                change
StringBuilder sb = …                        StringBuilder sb = …
If (sb.toString().length() >5) {            String currentName = sb.toString();
  node.getNode(sb.toString());              If (currentName.length() >) {
                                              node.getNode(currentName);
                                                                                     reusable
• every check should go into a new check method (is*, has*, exists*)
• every repetition within a method should use a local variable or new method
• find the right class for the new method to re-use it from everywhere you need it
One method = one task!
Every method should solve only ONE task!
                                                                             flexible
One method = one task

This will result typically into many short methods with only some lines of code (<10 w/o
catches), often <5 lines

• check methods return boolean (is*, has*, exists*)
• very short attribute methods (get*, set*)                                reusable
• every conversion as gettter too (date formatting)
• new types of method parameters supported with new method
• action methods with other verbs

                                                                           easy to
Benefits?                                                                understand
• better possibility for reusing a task
• easy to assemble into new tasks with more power (more abstract)

• even the main program code could be only 1 page long!
naming convention for getter
private Entity getEntity() {
…
}
                                                                   keep
public String getEntityName() {                                   control
  return getEntity().getName();
}

public String getEntityDescription() {
  return getEntity ().getDescription();
}

public String getEntityEmail() {
  return getEntity ().getEmail();
}

prevent exposing an entity, because you break encapsulation
if you do it, think carefully on the consequences!
no conversion possible (show blank, if entity could not found)
no lazy initialisation possible
How I implement a method
1. visibility of method
    (public, private)
2. name of method
    (think on WHAT not how; the kind of implementation is never stated in the name!)
3. how many input parameters?
4. type of input parameters?
    (prefer an object over primitive types like String to keep signature stable)
5. return value
    (reduce void, return what makes sense, even you don‘t need it yet)
6. now write the method‘s signature
7. write the methods javadoc explanation
    (sometimes a better method name comes into my mind, than adjust)
8. implement functionality
9. sit back and check the method‘s implementation
    (all possible return values of used methods handled?)
10. sit back and think on the big picture
    (can this method be used at any time and all circumstances?)
Monitor cheat sheet                                                   hang on your
                                                                          monitor


Issues                                    Recommended action

method name tell about how implemented?   rename to tell what it does, not how
long method?                              refactor | extract methods to shorten it

exposing entity?                          implement getter for all needed attributes
first thought implemented?                think on other options and decide wisely

method called twice for return value      refactor | extract local variable

all (instance var) caches maintained?     update when set, or set to null

checkstyle complaints?                    fix them all!

unused or unwanted methods still there?   remove first thought not needed anymore
You are free!
there is no limitation for the number

• of methods of a class
• of method parameters

A class represents an item from your domain, regardless how many methods it
needs.

A class should not be splitted only because of the number of methods!


By the way, prevent static helper methods, because you will never get them in the
code completion feature of your IDE.

Instead implement methods on your API classes you can re-use!
forget about complains
The most often complain I heard for this programming style is:

too many methods on a class are not maintainable

This comes, because you try to understand all code of a class at the same time.

I think on a method as a service I offer to the users of my class.

For implementing a new service (method) I only have to understand how to achieve this.

I can concentrate of implementing this one service (method) right,
without a need to understand all the other methods available.

Of course, I can call other methods to provide the new service (method).


(This might be a Java specific problem, because Java handle a whole classes source into 1 file.
In Smalltalk a file for class doesn‘t exists, only a list of methods you have to check one-by-one.)
Conclusion
If you want to

• be agile and flexible
• write safe and reliable code and
• develop fast at still high quality,

you have to re-use your code as much as you can!

In the long term you would be faster as a programmer doing the same stuff again and again.


Only because of the consequent usage of these principles jRQL

• can offer functions from such a wide range
• is reliable and stable
• and still easy to enhance!

More Related Content

What's hot

Generics in java
Generics in javaGenerics in java
Generics in java
suraj pandey
 
Clean code and Code Smells
Clean code and Code SmellsClean code and Code Smells
Clean code and Code Smells
Mario Sangiorgio
 
Std 12 computer chapter 8 classes and object in java (part 2)
Std 12 computer chapter 8 classes and object in java (part 2)Std 12 computer chapter 8 classes and object in java (part 2)
Std 12 computer chapter 8 classes and object in java (part 2)
Nuzhat Memon
 
Java for beginners
Java for beginnersJava for beginners
Java for beginners
Saeid Zebardast
 
Prototype
PrototypePrototype
Prototype
Aditya Gaur
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
Fu Cheng
 
Code smells and remedies
Code smells and remediesCode smells and remedies
Code smells and remedies
Md.Mojibul Hoque
 
The Ring programming language version 1.5.1 book - Part 70 of 180
The Ring programming language version 1.5.1 book - Part 70 of 180The Ring programming language version 1.5.1 book - Part 70 of 180
The Ring programming language version 1.5.1 book - Part 70 of 180
Mahmoud Samir Fayed
 
Only oop
Only oopOnly oop
Only oop
anitarooge
 
JavsScript OOP
JavsScript OOPJavsScript OOP
JavsScript OOP
LearningTech
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
Jussi Pohjolainen
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
Subramanyan Murali
 
Ruby object model - Understanding of object play role for ruby
Ruby object model - Understanding of object play role for rubyRuby object model - Understanding of object play role for ruby
Ruby object model - Understanding of object play role for ruby
Tushar Pal
 
Core Java Programming | Data Type | operator | java Control Flow| Class 2
Core Java Programming | Data Type | operator | java Control Flow| Class 2Core Java Programming | Data Type | operator | java Control Flow| Class 2
Core Java Programming | Data Type | operator | java Control Flow| Class 2
Sagar Verma
 
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
Sagar Verma
 
Javascript Prototype Visualized
Javascript Prototype VisualizedJavascript Prototype Visualized
Javascript Prototype Visualized
军 沈
 
Android webinar class_java_review
Android webinar class_java_reviewAndroid webinar class_java_review
Android webinar class_java_review
Edureka!
 
Object oriented programming with python
Object oriented programming with pythonObject oriented programming with python
Object oriented programming with python
Arslan Arshad
 
25 java tough interview questions
25 java tough interview questions25 java tough interview questions
25 java tough interview questions
Arun Banotra
 
The Ring programming language version 1.3 book - Part 55 of 88
The Ring programming language version 1.3 book - Part 55 of 88The Ring programming language version 1.3 book - Part 55 of 88
The Ring programming language version 1.3 book - Part 55 of 88
Mahmoud Samir Fayed
 

What's hot (20)

Generics in java
Generics in javaGenerics in java
Generics in java
 
Clean code and Code Smells
Clean code and Code SmellsClean code and Code Smells
Clean code and Code Smells
 
Std 12 computer chapter 8 classes and object in java (part 2)
Std 12 computer chapter 8 classes and object in java (part 2)Std 12 computer chapter 8 classes and object in java (part 2)
Std 12 computer chapter 8 classes and object in java (part 2)
 
Java for beginners
Java for beginnersJava for beginners
Java for beginners
 
Prototype
PrototypePrototype
Prototype
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
Code smells and remedies
Code smells and remediesCode smells and remedies
Code smells and remedies
 
The Ring programming language version 1.5.1 book - Part 70 of 180
The Ring programming language version 1.5.1 book - Part 70 of 180The Ring programming language version 1.5.1 book - Part 70 of 180
The Ring programming language version 1.5.1 book - Part 70 of 180
 
Only oop
Only oopOnly oop
Only oop
 
JavsScript OOP
JavsScript OOPJavsScript OOP
JavsScript OOP
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
Ruby object model - Understanding of object play role for ruby
Ruby object model - Understanding of object play role for rubyRuby object model - Understanding of object play role for ruby
Ruby object model - Understanding of object play role for ruby
 
Core Java Programming | Data Type | operator | java Control Flow| Class 2
Core Java Programming | Data Type | operator | java Control Flow| Class 2Core Java Programming | Data Type | operator | java Control Flow| Class 2
Core Java Programming | Data Type | operator | java Control Flow| Class 2
 
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
 
Javascript Prototype Visualized
Javascript Prototype VisualizedJavascript Prototype Visualized
Javascript Prototype Visualized
 
Android webinar class_java_review
Android webinar class_java_reviewAndroid webinar class_java_review
Android webinar class_java_review
 
Object oriented programming with python
Object oriented programming with pythonObject oriented programming with python
Object oriented programming with python
 
25 java tough interview questions
25 java tough interview questions25 java tough interview questions
25 java tough interview questions
 
The Ring programming language version 1.3 book - Part 55 of 88
The Ring programming language version 1.3 book - Part 55 of 88The Ring programming language version 1.3 book - Part 55 of 88
The Ring programming language version 1.3 book - Part 55 of 88
 

Viewers also liked

Security Systems of The Future
Security Systems of The FutureSecurity Systems of The Future
Security Systems of The Future
DAVID ISSA
 
Phantom Runner Project
Phantom Runner ProjectPhantom Runner Project
Phantom Runner Project
DAVID ISSA
 
Practical information and agenda berlin
Practical information and agenda berlinPractical information and agenda berlin
Practical information and agenda berlin
Chon Keon
 
Final presentation
Final presentationFinal presentation
Final presentationraylian
 
Future of the remote
Future of the remoteFuture of the remote
Future of the remoteDAVID ISSA
 
A Circular Story
A Circular StoryA Circular Story
A Circular Story
DAVID ISSA
 
Mulookk
MulookkMulookk
Nouveau présentation microsoft power point (1)
Nouveau présentation microsoft power point (1)Nouveau présentation microsoft power point (1)
Nouveau présentation microsoft power point (1)
eftis
 
Billaud camille m1_eftis_spider_silk_2nd_passage
Billaud camille m1_eftis_spider_silk_2nd_passageBillaud camille m1_eftis_spider_silk_2nd_passage
Billaud camille m1_eftis_spider_silk_2nd_passage
eftis
 
Starbucks: A Story of Growth - case study presentation for EBS/DBS
Starbucks: A Story of Growth - case study presentation for EBS/DBSStarbucks: A Story of Growth - case study presentation for EBS/DBS
Starbucks: A Story of Growth - case study presentation for EBS/DBS
Brandon J. Murray, PMP
 
NAVIDAD PARA TOIDOS
NAVIDAD PARA TOIDOSNAVIDAD PARA TOIDOS
NAVIDAD PARA TOIDOS
MARVINCACHORRO
 

Viewers also liked (12)

Security Systems of The Future
Security Systems of The FutureSecurity Systems of The Future
Security Systems of The Future
 
Phantom Runner Project
Phantom Runner ProjectPhantom Runner Project
Phantom Runner Project
 
Practical information and agenda berlin
Practical information and agenda berlinPractical information and agenda berlin
Practical information and agenda berlin
 
Final presentation
Final presentationFinal presentation
Final presentation
 
Future of the remote
Future of the remoteFuture of the remote
Future of the remote
 
A Circular Story
A Circular StoryA Circular Story
A Circular Story
 
Mulookk
MulookkMulookk
Mulookk
 
Nouveau présentation microsoft power point (1)
Nouveau présentation microsoft power point (1)Nouveau présentation microsoft power point (1)
Nouveau présentation microsoft power point (1)
 
Parameciul
ParameciulParameciul
Parameciul
 
Billaud camille m1_eftis_spider_silk_2nd_passage
Billaud camille m1_eftis_spider_silk_2nd_passageBillaud camille m1_eftis_spider_silk_2nd_passage
Billaud camille m1_eftis_spider_silk_2nd_passage
 
Starbucks: A Story of Growth - case study presentation for EBS/DBS
Starbucks: A Story of Growth - case study presentation for EBS/DBSStarbucks: A Story of Growth - case study presentation for EBS/DBS
Starbucks: A Story of Growth - case study presentation for EBS/DBS
 
NAVIDAD PARA TOIDOS
NAVIDAD PARA TOIDOSNAVIDAD PARA TOIDOS
NAVIDAD PARA TOIDOS
 

Similar to The programming philosophy of jrql

Design Patterns
Design PatternsDesign Patterns
Design Patterns
Srikrishnan Suresh
 
The Ring programming language version 1.5.4 book - Part 74 of 185
The Ring programming language version 1.5.4 book - Part 74 of 185The Ring programming language version 1.5.4 book - Part 74 of 185
The Ring programming language version 1.5.4 book - Part 74 of 185
Mahmoud Samir Fayed
 
Refactoring In Tdd The Missing Part
Refactoring In Tdd The Missing PartRefactoring In Tdd The Missing Part
Refactoring In Tdd The Missing Part
Gabriele Lana
 
Javascript Common Design Patterns
Javascript Common Design PatternsJavascript Common Design Patterns
Javascript Common Design Patterns
Pham Huy Tung
 
The Ring programming language version 1.8 book - Part 81 of 202
The Ring programming language version 1.8 book - Part 81 of 202The Ring programming language version 1.8 book - Part 81 of 202
The Ring programming language version 1.8 book - Part 81 of 202
Mahmoud Samir Fayed
 
Design p atterns
Design p atternsDesign p atterns
Design p atterns
Amr Abd El Latief
 
The Ring programming language version 1.7 book - Part 78 of 196
The Ring programming language version 1.7 book - Part 78 of 196The Ring programming language version 1.7 book - Part 78 of 196
The Ring programming language version 1.7 book - Part 78 of 196
Mahmoud Samir Fayed
 
Refactoring Tips by Martin Fowler
Refactoring Tips by Martin FowlerRefactoring Tips by Martin Fowler
Refactoring Tips by Martin Fowler
Igor Crvenov
 
The Ring programming language version 1.10 book - Part 86 of 212
The Ring programming language version 1.10 book - Part 86 of 212The Ring programming language version 1.10 book - Part 86 of 212
The Ring programming language version 1.10 book - Part 86 of 212
Mahmoud Samir Fayed
 
33rd degree talk: open and automatic coding conventions with walkmod
33rd degree talk: open and automatic coding conventions with walkmod33rd degree talk: open and automatic coding conventions with walkmod
33rd degree talk: open and automatic coding conventions with walkmod
walkmod
 
The Ring programming language version 1.2 book - Part 53 of 84
The Ring programming language version 1.2 book - Part 53 of 84The Ring programming language version 1.2 book - Part 53 of 84
The Ring programming language version 1.2 book - Part 53 of 84
Mahmoud Samir Fayed
 
Software Engineering Best Practices @ Nylas
Software Engineering Best Practices @ NylasSoftware Engineering Best Practices @ Nylas
Software Engineering Best Practices @ Nylas
Ben Gotow
 
Esoft Metro Campus - Certificate in java basics
Esoft Metro Campus - Certificate in java basicsEsoft Metro Campus - Certificate in java basics
Esoft Metro Campus - Certificate in java basics
Rasan Samarasinghe
 
Pi j2.3 objects
Pi j2.3 objectsPi j2.3 objects
Pi j2.3 objects
mcollison
 
Metaprogramming in Ruby
Metaprogramming in RubyMetaprogramming in Ruby
Metaprogramming in Ruby
Volodymyr Byno
 
core_java.ppt
core_java.pptcore_java.ppt
core_java.ppt
YashikaDave
 
2CPP18 - Modifiers
2CPP18 - Modifiers2CPP18 - Modifiers
2CPP18 - Modifiers
Michael Heron
 
Metaprogramming Rails
Metaprogramming RailsMetaprogramming Rails
Metaprogramming Rails
Justus Eapen
 
L03 Software Design
L03 Software DesignL03 Software Design
L03 Software Design
Ólafur Andri Ragnarsson
 
Test in action – week 1
Test in action – week 1Test in action – week 1
Test in action – week 1
Yi-Huan Chan
 

Similar to The programming philosophy of jrql (20)

Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
The Ring programming language version 1.5.4 book - Part 74 of 185
The Ring programming language version 1.5.4 book - Part 74 of 185The Ring programming language version 1.5.4 book - Part 74 of 185
The Ring programming language version 1.5.4 book - Part 74 of 185
 
Refactoring In Tdd The Missing Part
Refactoring In Tdd The Missing PartRefactoring In Tdd The Missing Part
Refactoring In Tdd The Missing Part
 
Javascript Common Design Patterns
Javascript Common Design PatternsJavascript Common Design Patterns
Javascript Common Design Patterns
 
The Ring programming language version 1.8 book - Part 81 of 202
The Ring programming language version 1.8 book - Part 81 of 202The Ring programming language version 1.8 book - Part 81 of 202
The Ring programming language version 1.8 book - Part 81 of 202
 
Design p atterns
Design p atternsDesign p atterns
Design p atterns
 
The Ring programming language version 1.7 book - Part 78 of 196
The Ring programming language version 1.7 book - Part 78 of 196The Ring programming language version 1.7 book - Part 78 of 196
The Ring programming language version 1.7 book - Part 78 of 196
 
Refactoring Tips by Martin Fowler
Refactoring Tips by Martin FowlerRefactoring Tips by Martin Fowler
Refactoring Tips by Martin Fowler
 
The Ring programming language version 1.10 book - Part 86 of 212
The Ring programming language version 1.10 book - Part 86 of 212The Ring programming language version 1.10 book - Part 86 of 212
The Ring programming language version 1.10 book - Part 86 of 212
 
33rd degree talk: open and automatic coding conventions with walkmod
33rd degree talk: open and automatic coding conventions with walkmod33rd degree talk: open and automatic coding conventions with walkmod
33rd degree talk: open and automatic coding conventions with walkmod
 
The Ring programming language version 1.2 book - Part 53 of 84
The Ring programming language version 1.2 book - Part 53 of 84The Ring programming language version 1.2 book - Part 53 of 84
The Ring programming language version 1.2 book - Part 53 of 84
 
Software Engineering Best Practices @ Nylas
Software Engineering Best Practices @ NylasSoftware Engineering Best Practices @ Nylas
Software Engineering Best Practices @ Nylas
 
Esoft Metro Campus - Certificate in java basics
Esoft Metro Campus - Certificate in java basicsEsoft Metro Campus - Certificate in java basics
Esoft Metro Campus - Certificate in java basics
 
Pi j2.3 objects
Pi j2.3 objectsPi j2.3 objects
Pi j2.3 objects
 
Metaprogramming in Ruby
Metaprogramming in RubyMetaprogramming in Ruby
Metaprogramming in Ruby
 
core_java.ppt
core_java.pptcore_java.ppt
core_java.ppt
 
2CPP18 - Modifiers
2CPP18 - Modifiers2CPP18 - Modifiers
2CPP18 - Modifiers
 
Metaprogramming Rails
Metaprogramming RailsMetaprogramming Rails
Metaprogramming Rails
 
L03 Software Design
L03 Software DesignL03 Software Design
L03 Software Design
 
Test in action – week 1
Test in action – week 1Test in action – week 1
Test in action – week 1
 

Recently uploaded

Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
David Brossard
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
jpupo2018
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 

Recently uploaded (20)

Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 

The programming philosophy of jrql

  • 1. The programming philosophy of jRQL Frank Leja, May 2012
  • 2. My goals You wanna … • be flexible and agile for changing customer demands? • develop faster in the long run without reducing quality? • don‘t invent the wheel again and again? • write reliable code? • write errorless code? • write highly reusable code? … check out this guide, if you want to improve your style! take the chance … follow these small steps to improve yourself …
  • 3. You write services! Think of every class and method as a service you provide for users not having your knowledge of the domain. unmistakable Means • your classes and methods forms an API • tell your users with your code what they can do (public) • how you do it (implementation) is private (encapsulation), could be changed! • public method and parameter names focus on what not how • take 10s to think on good names! reliable • all possible usage scenarios should work! (formBean setter problem) • or force user for only one usage possibility (method calling order) • caches has to be maintained transparently (for the user) (e.g. in instance variables) • full javadoc with all parameters and possible return values described • handle every problem, even it „could not happen“ (prevent NullPointerExceptions)
  • 4. think on options: see this ProjectDetailsFormBean public void saveProjectDetails(ProjectDetailsFormBean formBean) { .setBpm(String) .setDescription(String) // write the data into CRX this.setProperty(ProjectConstants.DESCRIPTION, formBean.getDescription()); .setEndDate(Calendar) this.setProperty(ProjectConstants.OWNER, formBean.getBpm()); .setItm(String) this.setProperty(ProjectConstants.OWNER2, formBean.getItm()); .setName(String) this.setProperty(ProjectConstants.START_DATE, formBean.getStartDate()); .setStartDate(Calendar) this.setProperty(ProjectConstants.END_DATE, formBean.getEndDate()); .setStatus(String) this.setProperty(ProjectConstants.STATUS, formBean.getStatus()); If not all set* methods used, the save method will go wrong. How can this problem be solved? 1. with FormBean? my option: 2. without FormBean? • no form bean at all, bc only used once for all attributes • direct usage of parameter values in method What do you prefer and why?
  • 5. Think on all options and decide wisely and consious there are always options how to solve a problem or implement a task 1. think on all possible options you could imagine 2. for every option think on the pros and cons 3. choose the option which best matches the goals given in this guide
  • 6. Dry Never break this rule! Easy to Don‘t repeat yourself! or Once and Only Once (see wikipedia) change public method1() { if (getOwnerProfile() != null) { public boolean hasOwnerProfile() { … return getOwnerProfile() != null; public method2() { } if (getOwnerProfile() != null) { … Safe to change StringBuilder sb = … StringBuilder sb = … If (sb.toString().length() >5) { String currentName = sb.toString(); node.getNode(sb.toString()); If (currentName.length() >) { node.getNode(currentName); reusable • every check should go into a new check method (is*, has*, exists*) • every repetition within a method should use a local variable or new method • find the right class for the new method to re-use it from everywhere you need it
  • 7. One method = one task! Every method should solve only ONE task! flexible One method = one task This will result typically into many short methods with only some lines of code (<10 w/o catches), often <5 lines • check methods return boolean (is*, has*, exists*) • very short attribute methods (get*, set*) reusable • every conversion as gettter too (date formatting) • new types of method parameters supported with new method • action methods with other verbs easy to Benefits? understand • better possibility for reusing a task • easy to assemble into new tasks with more power (more abstract) • even the main program code could be only 1 page long!
  • 8. naming convention for getter private Entity getEntity() { … } keep public String getEntityName() { control return getEntity().getName(); } public String getEntityDescription() { return getEntity ().getDescription(); } public String getEntityEmail() { return getEntity ().getEmail(); } prevent exposing an entity, because you break encapsulation if you do it, think carefully on the consequences! no conversion possible (show blank, if entity could not found) no lazy initialisation possible
  • 9. How I implement a method 1. visibility of method (public, private) 2. name of method (think on WHAT not how; the kind of implementation is never stated in the name!) 3. how many input parameters? 4. type of input parameters? (prefer an object over primitive types like String to keep signature stable) 5. return value (reduce void, return what makes sense, even you don‘t need it yet) 6. now write the method‘s signature 7. write the methods javadoc explanation (sometimes a better method name comes into my mind, than adjust) 8. implement functionality 9. sit back and check the method‘s implementation (all possible return values of used methods handled?) 10. sit back and think on the big picture (can this method be used at any time and all circumstances?)
  • 10. Monitor cheat sheet hang on your monitor Issues Recommended action method name tell about how implemented? rename to tell what it does, not how long method? refactor | extract methods to shorten it exposing entity? implement getter for all needed attributes first thought implemented? think on other options and decide wisely method called twice for return value refactor | extract local variable all (instance var) caches maintained? update when set, or set to null checkstyle complaints? fix them all! unused or unwanted methods still there? remove first thought not needed anymore
  • 11. You are free! there is no limitation for the number • of methods of a class • of method parameters A class represents an item from your domain, regardless how many methods it needs. A class should not be splitted only because of the number of methods! By the way, prevent static helper methods, because you will never get them in the code completion feature of your IDE. Instead implement methods on your API classes you can re-use!
  • 12. forget about complains The most often complain I heard for this programming style is: too many methods on a class are not maintainable This comes, because you try to understand all code of a class at the same time. I think on a method as a service I offer to the users of my class. For implementing a new service (method) I only have to understand how to achieve this. I can concentrate of implementing this one service (method) right, without a need to understand all the other methods available. Of course, I can call other methods to provide the new service (method). (This might be a Java specific problem, because Java handle a whole classes source into 1 file. In Smalltalk a file for class doesn‘t exists, only a list of methods you have to check one-by-one.)
  • 13. Conclusion If you want to • be agile and flexible • write safe and reliable code and • develop fast at still high quality, you have to re-use your code as much as you can! In the long term you would be faster as a programmer doing the same stuff again and again. Only because of the consequent usage of these principles jRQL • can offer functions from such a wide range • is reliable and stable • and still easy to enhance!