Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

What are SOPLETS?

Soplets is a new way of embedding the model of an application inside the code by just using (Java/.Net) enumerations and annotations. The result: Really transparent, maintainable and manageable code!
by

Christof May

on 1 November 2014

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of What are SOPLETS?

In Information Systems design and theory, Single Source Of Truth (SSOT) refers to the practice of structuring information models and associated schemata, such that every data element is stored exactly once. Any possible linkages to this data element are by reference only. Thus, when any such data element is updated, this update propagates to the enterprise at large, without the possibility of a duplicate value somewhere in the distant enterprise not being updated (because there would be no duplicate values that needed updating).
.......code.........................................
......................................................
......................................................
............................code....................
......................................................
......................................................
.................code...............................
......................................................
..................................code..............
SSoT
Single Source of Truth
This is plain regular Java Code - right?
Model
Code
Model
{
txtMarketingCode.setSize(3)
<hibernate>
...
<property name="marketingCode" size=3 />
...
in the GUI...
configuration files...
marketing_code_3_chars = Der Marketing-Code muss
resource files...
documentation...
<html>
<b>Marketing code:</b><br>
bla bla ... is at least 3 characters long... bla bla
</hmtl>
and this bit of information is just one dot in your overall software...
Shouldn't it be possible to 'embed' the model *inside* the code, so we safely and consistently can reference it from there?
But how can we represent the model inside the code?
Customer
firstName (String 50)
lastName (String 50)
city (City)
...
...
...
City
...
...
...
With a combination of Java enumerations and annotations the semantics of a model can be represented inside the code!
SOPLETS - the model inside the code!
Runtime interpretation
mindestens 3 Zeichen lang sein
Model
Model
Code
Model
Code
Model
Code
Model
A
Anatomy of a Soplet
An enumeration groups and lists logicaly related Soplets
}
Every Soplet is an encapsulated logical unit containing ALL attributes of a given concept (as far as feasable)
An enum constant is at the root of every Soplet.

This makes it referenceable throughout your application
With a customizable annotation all the properties of a given concept are defined in form of key-value pairs.
SOPLETS
In summary...
Soplets are logical building blocks which represent the business logic inside your code
Soplets are plain Java annotations and enumerations
Soplets are referenceable/readable from anywhere in your code
Why the name 'Soplets'?
SOP = Semantic Oriented Programmierung
logging
data dictionary
enumerations
business rules
Have a look at this code:
3 times the same value in just a couple of lines.
Do you still think this is "regular"?
and the same value appears not only in that code fragment, but also...
duplications
logical fragmentation
the result:
and subsequently:
inconsistencies...
...and bugs
and the the reason for all that mess???
FACE IT:
you do not have a consistent strategy for organizing the logics of your application in place!
NO STRATEGY!
A proven pattern for avoiding
duplications is SSoT - Single Source of Truth.
In database design this is what we call "Normalization".
So, what exactly is SSoT, and how can we possibly apply it
to our code?
Model
What about MDA? Isn't it all about SSoT?
Code
In MDA, the model is the central place where the knowleadge about a system is developed and subsequently stored. It serves as SSoT, from where your code and documentation is generated.
Documentation
So far the theory...
Model
In reality, MDA often has failed on delivering on it's self-proclaimed promises. Complexity, scarce cost-benefit ratio, steep learning curve, lack of flexibility and missing support for agile methods are just symptoms for a great concept gone wrong.
How comes?...
MDA produces typically 20-30% of your actual code. So what about the other 70-80% of your code, which you write by hand?
Referenceability?
The SSoT principle states, that all usage should occur via references - remember?
generated
code
'your'
code
But how can your code reference the model, if it does have no access to it? It can't.

So, what is a model good for if I can't use the knowleadge contained in it consistently over the system? You have to re-define information, such as the length of a field, again and again. So, instead of reducing duplications, you create even more of them!
Model Driven Architecture
So what can we do about it?
How goes the model into the code?
Model
Code
Model
Option A:

You generate
the Soplets from your MDA modeling tool, just as you would generated also any other code artifacts.
hmm...
this seems more like a one-way route...
Option B:

We allow 2-way syncronization between the modeling environment and the code.
B
Model
Code
Model
Option C:

Just forget any tools or stuff, just model inside your code!
Code
Model
C
How to use Soplets?
There are basically 4 ways of using Soplets:
Your SOPLETS
1.) Runtime interpretation
2.) Byte-code generation
3.) Deployment adaptation
The simplest way of using Soplets is by just referencing them, and reading out the properties you need.
No tools, plugins are whatever are needed - this can be done be simple standard Java methods
Tip:
You can generate any kind of always up-to-date documentation that way, by reading out the contents of the Soplets, and displaying a tool-tip-text for instance, or by generating pdf/excels on-the-fly with appropiate Java libraries (itext, apache hssf etc.)
read out the contents of a Soplet by Java reflection
Byte-code generation
Generated code is EVIL! You may beg to differ - but why should you have bloated, arkward and cumbersome code in the first place, if you are not supposed to touch it anyway?
Instead, use byte-code generation in order to fulfil the required functionalities, and that way you keep your codebase nice and tidy!
one strategy
Visit www.soplets.org!
Try it out!
Discuss with others!
Join the team!
We, the community at soplets.org are developing an Eclipse plugin based on Lombok (www.projectlombok.org) which creates the code for the ubiquos 'business objects' - based on the attributes defined in the corresponding Soplets
The Soplet defining the structure of the business object
The actual business object (or 'entity')
See how all the fields, getters and setters are generated at compile time
All fields, getters and setters are generated automatically!
Changing the Soplet changes automatically also the business object in real-time
Deployment adaptation
Even if your Soplets are compiled and deployed you still can change, adapt and extend them!
With simple property files you can override the values contained in your sopletized code
Soplets ain't limited to plain modelling - see here some examples on how you can use them in your project
...
Logging
Data
Dictionary
Listings
Business rules
etc.
etc.
embrace
duplications
duplications

SSoT
MDA-
really?

how it
works...

summing
it up...

?
this tutorial will introduce you to SOPLETS, the Semantic Oriented way of Programming with Java:
what are Soplets?
how do they work?
what can I do with them?
why should I care anyway?
Or do you...?
source: Wikipedia
Define the errors, warnings and other log entries as Soplets, and associate additional information with them.
You might export the problem and solution messages as HTML of PDF file, so the server admin can consult them, and get instructions on what to do.
reference the Soplets from anywhere in your code, and read out the property values
- many use cases
note also the references to other Soplets!...
Of course you can use enumerations for what they have been originally conceived, that is:
Listing related things in an ordered and iterable fashion.
With Soplets you can enhance them by simply adding an annotation element.
(your use case goes here...)
Soplets aren't limited to simple key-value pair descriptions. Applying the "method template" pattern you can even attach simple functions to your Soplet, and thus create business rules which you can re-use from whereever in your project
A data dictionary is a "centralized repository of information about data such as meaning, relationships to other data, origin, usage, and format."
Source: IBM Dictionary of Computing
4.) Web-based collaboration
Web-based collaboration
Developer
Translator
Business analyst
Quality manager
Repository
Soplet Studio
Eclipse
Plugin
Collaborate with other project stakeholders on any aspects of the business logic which is related to your application
They can work on a convenient web GUI with customizable views and workflows - and no need to be a technical whizz
fine-grained
2-way synchronization
PDF
Excel
Word
UML
Documenation
How comes?
Example 1
Overwrite existing Soplet properties
Adapt your application even if it has been deployed. You may fix it for good the next time you deploy it.
Add new entries as you go...
Example 3
Adapt to the local deployment environment
Example 4
Add new entries to existing Soplets...
Use it for local testing, for integration testing, or for servers with different environment settings
2-way syncronization between code and web environment
1
2
3
4
You may keep your translations inside the Soplets, in property files, or in a combination of both - just as you prefer!
Mark new entries with a #NEW tag, so they will be added at runtime as regular enum entries
Framework
Code
419 Lines of code
26%
48%
26%
Soplet Code
227 Lines of code
230 Lines of code
"Normal"
Code
100% clean!
100% transparent!
minimal bug rate!
100% reusable across projects
Reduced bug rate thru SSoT
The result
(numbers from the PetStore demo)
so what are you waiting for?
reference to Soplet
Example 2
Full transcript