Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Web Service Architecture

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

Web Service Architecture

Avatar for Robin Darby

Robin Darby

March 06, 2012
Tweet

More Decks by Robin Darby

Other Decks in Programming

Transcript

  1. a service is a model! • Traditional MVC frameworks assume

    that the model is a set of classes that talk to a database. • However, a service is also a kind of model. • Views don’t change • Controllers now call services, rather than directly accessing your data source. Tuesday, 6 March 2012
  2. databases are dangerous! • SQL is complex, powerful. • Hard

    to manage SQL routines, stored procedures hide complexity. • No revision control. • Bad developers _will_ attempt to optimize their apps by bastardizing the model. • Most companies don’t have a DBA to manage database performance/access. Tuesday, 6 March 2012
  3. • It’s all too easy to just add SQL call

    to a view. Front-end developers are used to this lexicon, because it’s more or less the same as making an AJAX call. • We all end up spend time refactoring code that belongs in a controller. Tuesday, 6 March 2012
  4. ....the good. • Anything that involves talking to a database.

    • Search. • KinoSearch Tuesday, 6 March 2012
  5. ...the bad. • I18N • However it’s still beneficial to

    define an interface and stub classes. Tuesday, 6 March 2012
  6. defining an API • I like to go old school:

    use-case, data-flow, UML. • You could use REST, JSON etc, but I’d suggest trying SOAP! • Define a WSDL file - even tho you don’t have to. • Version control for your interface • Language agnostic ( can use the same WSDL file to create Java, C#, php, etc stubs ). Tuesday, 6 March 2012
  7. • Once you’ve defined your API and created your WSDL

    file, choosing whether or not to create a stub class is up to you. • If you do, you are likely to rework the generated class to your own preferences and patterns ( i.e. use Moose ). • If you don’t, you are going to incur the cost of opening & processing the WSDL file for each service call. Tuesday, 6 March 2012
  8. building stubs WSDL stubmaker.pl Operation Operation Attribute Attribute GetCamel Operation

    Operation Attribute Attribute Camel::Client Operation Operation Attribute Attribute Camel::Client Tuesday, 6 March 2012