Friday, April 18, 2008

SmartObject Workshop Thoughts

Background


Colin Murphy, Gabriel Malherbe and I held a workshop on SmartObjects at the K2 Insider Conference this April. It was an interesting discussion because the three of us had some conference calls beforehand where tried to gain a better understanding of how to position SmartObjects in the Enterprise Architecture. I wrote a blog that has not been published which all three of us iterated on before the conference. I made some statements in that article (to invoke debate) where I asserted that SmartObjects could be considered SOA. I got beat up a little by colleagues and now admit that SmartObjects are not SOA even though they adhere to many of the tenants of SOA like autonomy, manageability, discoverable, maintainable, exception handling, scalability, reliability, transactionality, security, logging, buildability, interoperability, testability, etc. Maybe it is low on the maturity scale of SOA (level 2 of 5) and I still debate that sometimes that is good enough for many organizations. It can be challenging to get a company to invest to get to a high maturity level of SOA.


So then what are SmartObjects? Here are some excerpts from the slides that we presented.


Before and Now


In the K2 2003 days we would have to go into the client event after the code was generated and start modifying it to get data from external places. Remember that there is no code generation in BlackPearl; it is declarative.


Now all we do is drag and drop smart object references into the canvas to gain access to data; no code.


K2 [blackpearl] Solution


  • Blackpearl introduces SmartObjects to solve many of these issues.
  • SmartObjects:
    • Are reusable business entities which can be deployed centrally and consumed by non-technical workflow authors
    • Are a storage location for process data (SmartBox)
    • Are a means to quickly access external LOB Data
    • Allow developers to aggregate data from multiple backend systems into a single, composite object
    • Can be created without writing any code
    • Can be accessed outside of the workflow (ADO Provider) and can be reported on

K2 SmartObject in Enterprise Architecture


The following diagram is from a presentation I prepared in November of 2007 for the Texas User Group. At the time I was digging around SmartObjects trying to understand it. From what it looks like my diagram is still spot on.


K2 states that SmartObjects are used to "provision" data into your workflows. K2 uses it as the underpinning to the entire BlackPearl platform. The two things you should know right off are there are SmartObject Services and SmartObjects.

SmartObject Services are:

  • The providers that access line of business and expose the data through a common interface.
  • They expose methods that can be executed; typically CRUD operations.
  • They are registered with the K2 Server and instances of them are created through K2 Workspace.

SmartObjects are:

  • Class definitions that have data elements that map into the methods that are provided by the SmartObject Service.
  • SmartObjects can be graphically used within K2 to access data.
  • SmartObjects have a data provider API which you can easily hook into other tiers of the architecture.

In the end SmartObjects is part of your Data Access layer and they allow you to basically write data providers which are access through SmartObjects.

K2 [blackpearl] Solution


The following are out of the box SmartObject Services that are provided by SharePoint.

  • SmartBox (cannot be used for custom SQL Databases)
  • SharePoint
  • Active Directory – I cannot live without this service when building workflows.
  • K2 [blackpearl] – Provides easy access to all data that is within K2.
  • Salesforce.com

Blackmarket SmartObject Services


The Blackmarket is a K2's version of CodePlex. It is an area where developers can share code with one another - http://k2underground.com/k2/ProjectLanding.aspx

This catalog of services is going grow as more people start to contribute.

Conclusions

The following are my conclusions after the discussion.

  • SmartObjects give you a significant edge in delivering timely solutions with K2. They have provided me the ability to immediately access Active Directory, SQL Databases, etc. We have personally seen that we can now deliver working processes in days instead of weeks because we no longer have to build up custom data access layers and go into the code of K2 and manually access the data. I can use the SmartObjects in a drag and drop fashion in line rules, succeeding rules, preceding rules, emails, destination users/rules, any configuration item in any event wizard, etc. It is ridiculously simple to configure my entire K2 process with data and I have zero custom code to get at the data. Plus I can write C# code in custom event handlers to use SmartObject. The API is really clean, simple and similar to using System.Data.
  • Another great thing about SmartObjects is that if you carefully take the time to build them you will start being able to build catalogs of SmartObjects that business users can use when composing their K2 Processes. They will not be exposed to any of the details associated to knowing where the data comes from.
  • Right now one concern is the ability to place business rules against the SmartObjects methods. For instance if you use the Dynamic SQL Service which build the interface of the service based on the schema of the database there is no way put business rules on the SmartObject to ensure that a value must be greater than X or cannot be null. So if a business user were to use SmartObject Event in their process they could possibly just start setting invalid data.
  • The SmartBox is good for doing early iterations of processes but over the long term you may not want to us them. For instance you have limited control over the schema of the database (because it is generated). As well, you may not want to co-mingle data from different processes in the same database.
  • Do not let you SmartObjects replace your Data Warehouse. With SmartObjects it is possible to perform CRUD operations across line of business data sources. It is very tempting to have a SmartObject read from many different places providing a single view of the data despite where the data is being read from. A simple example would have a SmartObject read from Active Directory and SQL Server. You must take performance into consideration when doing something similar to this. Performance issues associated to reading data will be vetted out in the SmartObject Service implementation however if you read in two large data sources and then join them together in the SmartObject layer you will not have the opportunity to index those joins. It would be better to have the SmartObject access data in the Data Warehouse itself.
  • This comment will be a little at odds with the first but LINQ, Entity and .Net Data Services make it challenging to position SmartObjects. SmartObjects Services may use them to access data and surface it up through a SmartObject for K2. However many developers will be tempted just use LINQ directly inside your custom server events, middle and UI layers. I have not personally messed with LINQ and Entity as much as I should but from the hype it is pretty rich and provide a full Object Query Language and Object Relational Mapping (ORM). The one nice thing about SmartObjects is that they provide you a way to centralize and publish services.

2 comments:

David said...

Can you make use of SmartObjects in am ASP.NET UI, is this even appropriate?

For example: if a user can submit a request on behalf of another user, they may want some variety of people picker to ensure they select the correct user account. Previously I've implemented this using a web service that queries AD. Could this be replaced with the Active Directory SmartObject? Would you want to even if it could?

Jason Apergis said...

David,

Check out the K2 book - there are tons of code in there to show you how to do this. In the book we discuss considerations. For the example you explained, I would go ahead and do that. However let's say you wanted to get thousands of records and put them into a custom grid in ASP.net, well I would probably just use ADO.net.

Does that help?

Jason