JSR-303 (“Bean Validation”) ActionScript3 framework for form validation
validation framework is a specific adaptation of the JSR-303 (Bean Validation) specification to Flex: like its Java counterpart, it relies on validation annotations placed on bean properties and provides an engine API that lets you validate your forms without writing by hand a specific validator for each of your input fields
code generation tools provided by GraniteDS so that when you write your Java entity bean with validation annotations, they are automatically replicated in your ActionScript3 beans
problem with LCDS is mainly that it promotes a strict “client / server” architecture, with – roughly speaking – a heavy Flex client application connected to a server almost reduced to a database frontend
big majority of these organizations use BlazeDS, a free and open-source subset of LCDS
need more advanced mechanisms than just Remoting start looking for open-source libraries to enable deeper integrations with the Java business layer, and GraniteDS is for sure the most popular project
“Flex Data Services” (now renamed to “Live Cycle Data Services”)
stop asking themselves how this solution could be improved upon
It's a very impressive magic trick, and I wish I knew how to do it myself. But then, I'm just not like that. I'm always trying to poke holes in things - whether they were Invented Here or Not.
but that might be too high-level for your taste. Their are other, less-abstract options.
exception handling, this is one area where Spring does a good job: "The Spring Framework's handling of SQLException is one of its most useful features in terms of enabling easier JDBC development and maintenance. The Spring Framework provides JDBC support that abstracts SQLException and provides a DAO-friendly, unchecked exception hierarchy."
Utter nonsense and dishonest false advertising
Automatic connection closing (and other boiler-plate code) is obviously a hard requirement to be handled by the fwk.
Pffffff. It's a trivial requirement which I can solve in my framework with two lines of code in a @Disposes method. Did you see any connection handling in the code above?
I mean, seriously guys. The Spring stuff is trivial and not even very elegant. I guess it's easier for me to see that, since I spent half my career thinking about data access and designing data access APIs. But even so...
I don't understand. You hate the ability to write typesafw SQL that much?
Gavin King
Methods with long argument lists are a code smell.
It's something Spring copied from Hibernate 1.x, back in the days before varargs
It's something we removed in Hibernate2 and JPA.
there are a bunch of people
who don't want to use JPA.
They don't understand, or see the value of, using managed objects to represent their persistent data.
Um. Why? Why would that be a bad thing? I imagine that any app with 1000 queries has tens of thousands of classes already. What's the problem? Why is defining a class worse than writing a method?
Are you working from some totally bizarre metric where you measure code quality by number of classes?
well, dependency injection, but moreover, the soa approach to service design tends to force otherwise intelligent software engineers into doing procedural design
the services just end up being bags of method calls that implement any type of behavior, with the domain objects or entity beans being reduced to mere data structures with little responsibility or behavior beyond persistence. (which, in this anti-pattern, is typically mostly provided by the repository or dao class! ie. domain object crud)
think of it as internal design documentation
when you revisit this code 8 months from now:
- based on nothing but your well-chosen ;) package/class/method/variable names, will you recall all of your current design intentions and rationale? likely not
- when you hand-off this code to another software engineer, how easy will it be to mostly rtfm? will you have to waste time preparing design/implementation notes specifically for the hand-off? if this is the case because the code is unreadable and not self-guiding and there's not already at least high level design notes in a wiki, you're doing it wrong!
If a method is overridden in a subclass, Javadoc should only be present
if it says something distinct to the original definition of the method
this at least makes the paragraph breaks wysiwygísh and somewhat easier to read
Use a single <li> tag for items in a list
place a single <li> tag at the start of the line and no closing tag
Define a punchy first sentence
it has the responsibility of summing up the method or class to readers scanning
the class or package
the first sentence should be
clear and punchy, and generally short
use the third person form at the start
Avoid the second person form, such as "Get the foo"
Use "this" to refer to an instance of the class
When referring to an instance of the class being documented, use "this" to reference it.
Aim for short single line sentences
Wherever possible, make Javadoc sentences fit on a single line
favouring between 80 and 120 characters
Use @link and @code wisely
@link feature creates a visible hyperlink in generated Javadoc to the target
@code feature provides a section of fixed-width font, ideal for references to
methods and class names
Only use @link on the first reference to a specific class or method
Use @code for subsequent references.
This avoids excessive hyperlinks cluttering up the Javadoc
Never use @link in the first sentence
Always use @code in the first sentence if necessary
Adding a hyperlink in that first sentence makes the higher level documentation more confusing
Do not use @code for null, true or false
Adding @code for every occurrence is a burden to both the reader and writer of the
Javadoc and adds no real value.
Use @param, @return and @throws
@param entries should be specified in the same order as the parameters
@return should be after the @param entries
followed by @throws.
Use @param for generics
correct approach is an @param tag with the parameter name of <T> where T
is the type parameter name.
Use one blank line before @param
This aids readability in source code.
Treat @param and @return as a phrase
They should start with a lower case letter, typically using the word "the".
They should not end with a dot.
This aids readability in source code and when generated.
treated as phrases rather than complete sentences
Treat @throws as an if clause
phrase describing the condition
Define null-handling for all parameters and return types
ideally, if the method in question has any specified/required pre and/or post conditions, they should be noted in the javadoc, not *just* null handling
also, there are cleaner ways to design around this type of old school null handling hackage
methods should define their null-tolerance in the @param or @return
likewise with javadoc on things like default constructors
/**
* Creates an instance of SomeClass
*/
public SomeClass() {}
is equally useless and unnecessarily clutters up the source code
Fully polymorphic behavior is available, but there is no annotation support for any mappings.
Hibernate supports fully polymorphic behavior. It provides extra support for any association mappings to an inheritance hierarchy mapped with implicit polymorphism.
but don’t know how those dependencies are instantiated
And you shouldn’t really care, all that is important is that UserService depends on dao and webservice object.
BDD template given-when-then) tests are easy to read
@Entity
public class User
calling new User(“someName”,”somePassowrd”, “someOtherName”, “someOtherPassword”) becomes hardly readable and maintainable
code duplication
Maintaining this code would turn into a nightmare in no time
running the code above will throw an exception by the JPA provider,
since not-nullable password field was never set.
Joshua Blooch gives fine example of builder pattern.
Instead of making the desired object directly, the client calls a constructor (or static factory) with all of the required parameters and gets a builder object. Then the client calls setter-like methods on the builder object to set each optional parameter of interest. Finally, the client calls a parameterless build method to generate the object, which is immutable. The builder is a static member class of the class it builds.
Coffee
public static class Builder
Builder(CoffeeType type, int cupSize)
Builder withMilk()
Coffee build()
Coffee(this)
private Coffee(Builder builder)
Coffee coffee = new Coffee.Builder(CoffeeType.Expresso, 3).withMilk().build();2}
especially if most of those parameters are optional.
For all entity attributes I create private fields
those that are obligatory become parameters for the public constructor
parameter-less constructor, I create one, but I give him
purpose is to make it easier to build Spring-powered Rich Internet Applications using Adobe Flex as the front-end client
providing first-class support for using the open source Adobe BlazeDS project and its powerful remoting and messaging facilities in combination with the familiar Spring programming model
GraniteDS introduces an ActionsScript3 implementation of the Bean Validation specification and provides code generation
tools integration so that your Java constraint annotations are reproduced in your AS3 beans
All entities marked as [Managed] are considered as corresponding to Hibernate/JPA managed entities on the server
It is highly recommended to use JPA optimistic locking in a multi-tier environment (@Version annotation
In conclusion, the recommended approach to avoid any kind of subtle problems is to have a real uid property which will be persisted
in the database
but is not a primary key for efficiency concerns
Here all loaded collections of the Person object will be uninitialized so uperson contains only the minimum of data
to correctly merge your changes in the server persistence context
Tide uses the client data tracking (the same used for dirty checking, see below) to determine which parts of the graph
need to be sent.
Dirty Checking and Conflict Handling
Data Validation
Tide integrates with Hibernate Validator 3.x and the Bean Validation API (JSR 303) implementations, and propagate the server validation errors to the client
UI components