Advanced Smart Objects

  • 18 January 2008
  • 7 replies
  • 11 views

Badge +9

I am posing the question of how to use Smart Objects the 'right' way in an overall architecture design.  I am starting to think of Smart Objects as Classes and using them accordingly but then I quickly start running into issues. 


For example, we are writing a system where a user places an 'Order' to start a workflow process - there are many different kinds of orders but each of them have the same set of base data; a situation where I would typically make a base 'order' class and extend from it for each specific order type.  In the Smart Object world, we don't quite have inheritance yet so would I make a smart object to represent the base order data and one to represent specific order types, and have the order form deal with them both, tying them together by 'OrderId'?  So one order form would have an instance of the 'base order' smart object for the common data and a 'specific order' smart object for the data specific to the type of order being ordered?  Is that a good approach, or should I just make one smart object that has both the base and specific data for each order type, to heck with the redundant base order data in each smart object?


Secondly, we have a number of situations where the user may continually append line items to an order, like a parent-child relationship.  Specifically, they place an order for a service and within the order they may specify one to many items to perform the service on.  It is easy to represent and capture this data in InfoPath via repeating tables, but how to shove it into a Smart Object?  Would I createa  smart object to represent one of these items, and create them on the fly for each item the user specifies in their order?  Or would the order smart object just stick these child selections into a multi-value or comma-delimited property?  Are hierarchical smart objects possible in any way?


I hope the experts out there can point me in the right direction here, I need to nail down the architecture for our project soon and I just have so many questions!


7 replies

Badge +4

For the first example, let's assume 3 order "objects".  OrderBase (contains common order info), OrderChild1 & OrderChild2 (both based on OrderBase but with additional extra data).

You can create composite smart objects that will merge the data between OrderBase/OrderChild1 and also OrderBase/OrderChild2.  When using smartobjects in your process/code, use the composite smart objects as your true "classes" that end users & your process would interact with.

Now depending where you're storing the data (SmartBox vs. external DB) will determine how to build your smart objects. 

If storing in SmartBox, you will need to create 5 smart objects:  OrderBase, Order1Base, Order2Base, Order1Composite, Order2Composite.  The *Base objects will contain the distinct data for each type.  The *Composite objects will combine the OrderBase with the "child" order types to create a new "view" of the composite data.

If storing in an external DB, you will only need 2 smart objects.  First you would create ServiceObjects to perform the CRUD operations on your OrderBase & OrderChild* tables.  The 2 smart objects can then be built on top of these service objects, creating the composite object.  SmartObjects created would be Order1Composite and Order2Composite.  Each of these would have multiple actions in the Create, Update, Delete, Load methods.  ex: Create would Create the OrderBase entry and the OrderChild* entry. 

To the end user, these composite objects are nothing more than an object.  The will not know that it's saving off to multiple tables.

 

For #2, I've seen it done in demos/examples we have internally.  I will let one of our infopath experts give their opinion on the best approach to that scenario.
 


 

Badge +3
You can create associations between SmartObjects.  I won't claim to be an expert here, but I'm doing something somewhat similar to what you're talking about.  I have a base form and then multiple multiple notes "fields" on this form.  The thing about these notes fields is that a user is not allowed to modify it once the note has been saved (plus I need to keep track of who entered the note and when it was created), but the user should be allowed to add new notes to the field.  The way I am approaching it right now is to save all the base data into one SmartObject and then all the notes into a separate SmartObject.  I can then link that associated SmartObject back to my form.  Your scenario is a little bit different as I assume you want to enable people to update those order lines.  One of the points of associating SmartObjects, from what I can tell, is for reporting purposes.  I hope this helps some.
Badge +8

Tim,


 


I will be honest, you have hit a very broad answer that myself and some others are brainstorming as we speak.  I think the addition of SmartObjects in the Enterprise Architecture is brilliant but I would not let it take over. 


 


Right now, I believe SmartObjects are the facade to perform CRUD operations across line of business data sources.  Stop there; here is why.  I would not let SmartObjects take over data modeling.  I would start with creating your normalized database as you would for any “enterprise application”.  I would then build your business layer with a full domain model for all your business objects.  There is never a one-to-one mapping a class definition and a table definition unless you are going down an object relational map (and that still is not a guarantee).  Then I would use SmartObjects to start getting data from all the different places and push them into your domain layer.  One thing I immediately see if that you no longer tightly couple your domain layer object to a specific datasource.  It is filled from a SmartObject which handles all of the transactionality.  I think the SmartBox is great for simple solutions but I would invest in writing a truly normalized database with dependencies, triggers, views, stored procedures, etc.


 


I will get off my high horse.


 


I really like mattm’s second suggestion of creating composite SmartObject to handle pushing the data down into a custom database.


 


Now from what I understand you are using SmartObjects to do, you are trying to hook them into InfoPath forms.  Up to now I have typically been hooking them into one or two SmartObjects and they have a simple association to each other (which is further enforce at the database level with a simple primary/foreign key relationship).  Easy enough with the out of the box integration provided with SmartObject and InfoPath.


 


Now if I had an InfoPath form where the user had to work with large collections of data (repeating nodes) I am not sure if I would go down the path of using direct SmartObject to InfoPath integration.  I will be honest, I wrote about three large paragraphs and I discovered I was ranting J  So I deleted them and I will ask this question – how do you intend the transactions to be managed?  When a user does something with a smartobject in a collection, is the data change committed immediately to the database or does the commit occur when they press the submit button?


 


Jason

Badge +9

Jason,


My scenario is very simple, I don't even need to consider much in the way of transaction management - the data is all saved when the user submits the form.  Done.  We were looking for a quick win on a simple project, and full smart object (with smart box) integration seemed to be the quickest way to capture the data for reporting purposes.  Of course, give me a hammer and I try to nail everything with it, which is why I stopped to pose the question of the appropriate use of smart objects.


I'd be interested to hear your ranting on SmartObjects and InfoPath, since I'm close to comitting the project down that path and I'd like to know what I'm getting myself into.  I really like what SmartObjects seem to do on the surface, but I don't want to get burned when its too late to turn back.

Badge +8

Tim,


I am jammed up at the moment but I really love the SmartObject integration with InfoPath.  If this is a simple POC type of implementation and the data in your IP form is can be mapped a couple logical SmartObjects just go ahead.  The great thing about SmartObjects is that you can re-implement the services later for the SmartObject to not use the SmartBox.  One thing I would do is just try to design your SmartObject such if it were to change, you will not be hosed.


Also, I would not make the SmartObjects your main datasource for the InfoPath form.  That will decouple you a little bit.  I would have a schema for the form and then move all the data in/out using the web methods.  I know it will take time to map everything up but if the SmartObjects change, you may limit the changes to the InfoPath form itself.


J

Badge +9
I've actually come full-circle on SmartObjects now... at first I wanted to use them for everything, now I am wondering why I would use them at all.  I thought that using them would make reporting on the data entered into InfoPath much easier, and while it might be a little easier than parsing through the InfoPath XML stored in the process XML data, I don't think it is worth the effort.  What other benefits of SmartObjects am I missing now that I'm all in an anti-SmartObjects mood?
Badge +8

Tim,


Well I am not Dr. Phil and do not want to be :-)


Really briefly, right now I am visioing SmartObjects as an enabler for SOA.  Gabe and I need to talk soon as we are both thinking the same thing but SmartObjects in my opinion SmartObject do not replace an object relational mapping tool.  The SmartBox is a light-weight ORM for doing quick and easy stuff.  Although, SmartObjects could replaced a true object relational map.  I would highly consider still using them in any architecture, k2 or not, as they force seperation between data persistance UI/business layers.  I personally like them as the enforce a common web service layer to perform CRUD operations over the long run.  The interface is agnostic of the datasource and the methodology to get data in and out.  If you let developers write thier own web services, you are doomed.  I have gone to clients to do SOA assessments in both .net and java platforms and you get a range of things.  Everyone is saying they are implementing thier Gang of Four pattern but they all violoate it to get things done in the way they want.


I personally was able to get some bang for my buck using them espically with IP because I did not have to write the any ado code or nothing.  I was done.  The dynamic sql service on the blackmarket gave me what I needed.


I have a slide deck I did for the K2 User Group in Nov. on SmartObjects.  If you shot me a message with your email address I can sent it to you...


Jason

Reply