﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Passing Business Objects as variables</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 01:52:48 GMT</lastBuildDate><ttl>20</ttl><item><title>Passing Business Objects as variables</title><link>http://forum.strataframe.net/FindPost10584.aspx</link><description>Hi All&lt;/P&gt;&lt;P&gt;I want to pass a business object from one method to another. At first this seemed pretty simple but I'm not having much success except to do it as a generic object.&amp;nbsp; Am I missing something really dumb, is there another way or is this just it?&lt;/P&gt;&lt;P&gt;Public Sub DoIt(b as strataframeobject) &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' in this example, i want to be able to pass different objects and load the results into cache&lt;/P&gt;&lt;P&gt;end function&lt;/P&gt;&lt;P&gt;Thansk!</description><pubDate>Mon, 30 Jul 2007 08:43:01 GMT</pubDate><dc:creator>choyt</dc:creator></item><item><title>RE: Passing Business Objects as variables</title><link>http://forum.strataframe.net/FindPost10620.aspx</link><description>Yeah, whenever you have a component designer attached to something, you have to make its base class non-abstract.&amp;nbsp; Because the designer actually creates an instance of the base class and uses that as the root of the designer... rather than the class&amp;nbsp;itself (I have no idea why, but I'm sure they've got a good reason for doing so).&amp;nbsp; So, when we have a base class for our business objects, we generally create a property/method that needs to be overriden and throw a NotImplementedException() from within the base class (rather than making it abstract/MustInherit, because you can't), so that way, when you forget to override it in one of your classes, you'll get a nice red error window telling you what method you forgot to override.&amp;nbsp; (just don't forget to NOT call the MyBase.Method() or it will still throw the exception ;)).</description><pubDate>Mon, 30 Jul 2007 08:43:01 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Passing Business Objects as variables</title><link>http://forum.strataframe.net/FindPost10619.aspx</link><description>Good to hear. Any time I can help, I'll be glad to. :D</description><pubDate>Mon, 30 Jul 2007 07:51:39 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Passing Business Objects as variables</title><link>http://forum.strataframe.net/FindPost10611.aspx</link><description>Thanks Greg&lt;/P&gt;&lt;P&gt;This did the trick. I truly appreciate the help.</description><pubDate>Sat, 28 Jul 2007 10:41:32 GMT</pubDate><dc:creator>choyt</dc:creator></item><item><title>RE: Passing Business Objects as variables</title><link>http://forum.strataframe.net/FindPost10608.aspx</link><description>I didn't know that about the abstract class.  Well, you could just make the CachedBO a normal class and then make the FillForCache an actual method:&lt;br&gt;
[codesnippet]Public Class CachedBO&lt;br&gt;
  Inherits BusinessLayer&lt;br&gt;
  ' make it overridable, and it does nothing...subclasses must implement this.&lt;br&gt;
  Public Overridable Sub FillForCache()&lt;br&gt;
  End Sub&lt;br&gt;
End Class[/codesnippet]&lt;br&gt;
Now when you inherit, you just override the FillForCache() method.  This should work with the designers, its just normal inheritance.  In this case you are trading a cleaner coding style (abstract class...explicitly defining the intent of the abstract class) for a more convenient coding style (use of designers, less typing/typos).</description><pubDate>Fri, 27 Jul 2007 21:16:11 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Passing Business Objects as variables</title><link>http://forum.strataframe.net/FindPost10604.aspx</link><description>Hi Folks&lt;/P&gt;&lt;P&gt;The inheritance idea works great except for one problem. When your BO inherits from&amp;nbsp;an abstract&amp;nbsp;class (instead of &lt;FONT size=2&gt;MicroFour.StrataFrame.Business.BusinessLayer directly) the designer no longer works. &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;The only drawback to this that I can see is having to manually edit properties such as CRUD, required fields, etc.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;Can anyone else think of a reason not to do this?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;Thanks!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;Clay&lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Fri, 27 Jul 2007 17:02:31 GMT</pubDate><dc:creator>choyt</dc:creator></item><item><title>RE: Passing Business Objects as variables</title><link>http://forum.strataframe.net/FindPost10600.aspx</link><description>Thanks all! Greg...I am going to take your advice.</description><pubDate>Fri, 27 Jul 2007 12:29:36 GMT</pubDate><dc:creator>choyt</dc:creator></item><item><title>RE: Passing Business Objects as variables</title><link>http://forum.strataframe.net/FindPost10599.aspx</link><description>[quote][b]choyt (07/27/2007)[/b][hr]That helps. The problem I'm having now is that my FILL methods are custom created and are not being recognized in the sub. I will probably have to resort to late binding and if that is the case, I doubt I will follow this path.[/quote]&lt;br&gt;
&lt;br&gt;
Clay,&lt;br&gt;
&lt;br&gt;
A few options to possibly avoid late binding.  &lt;br&gt;
&lt;br&gt;
- Fill the BOs before they are passed. This may or may not be feasible, but it is at least more possible that you'd know what the Fill methods are on the calling side.&lt;br&gt;
&lt;br&gt;
- It might be possible to create an abstract class that inherits from BusinessLayer and has a MustOverride method that is used to fill the BO.  See the code below:&lt;br&gt;
[codesnippet]Public MustInherit Class CachedBO&lt;br&gt;
  Inherits BusinessLayer&lt;br&gt;
  ' This method must be overridden in classes that inherit from CachedBO&lt;br&gt;
  Public MustOverride FillForCache() &lt;br&gt;
End Class[/codesnippet]&lt;br&gt;
Note that this is the entire class needed.  You'd then change any BO that is to be cached to inherit from CachedBO instead of BusinessLayer and implement the FillForCache() method in each of them and have DoIt use CachedBO:&lt;br&gt;
[codesnippet]Public Sub DoIt(a As CachedBO)&lt;br&gt;
  a.FillForCache()&lt;br&gt;
End Sub[/codesnippet]&lt;br&gt;
This could work very nicely if the parameters needed to fill the BO are common between the Fill methods, or you can figure out some other way to get the Fill methods the data they need, like using properties on the BO.  If data needed by the Fill methods is different then this likely won't work out.&lt;br&gt;
&lt;br&gt;
- An interface might work, but only if you don't need any of the method/properties of the BusinessLayer and the Fill methods can be generalized (have the same signature).&lt;br&gt;
&lt;br&gt;
Anyway, some food for thought.</description><pubDate>Fri, 27 Jul 2007 11:13:25 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Passing Business Objects as variables</title><link>http://forum.strataframe.net/FindPost10592.aspx</link><description>Greg is correct.&amp;nbsp; You just need to type your parm as a BusinessLayer or BusinessLayerBase and it will then accept any BO.&amp;nbsp; You can then DirectCast or CType it if you know what to expect on the other side.&amp;nbsp; Otherwise you can just leave it typed as the BusinessLayer and interact with the "known" methods and properties.</description><pubDate>Fri, 27 Jul 2007 08:45:43 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Passing Business Objects as variables</title><link>http://forum.strataframe.net/FindPost10590.aspx</link><description>Thanks Greg&lt;/P&gt;&lt;P&gt;That helps. The problem I'm having now is that my FILL methods are custom created and are not being recognized in the sub. I will probably have to resort to late binding and if that is the case, I doubt I will follow this path.&lt;/P&gt;&lt;P&gt;Clay</description><pubDate>Fri, 27 Jul 2007 08:35:59 GMT</pubDate><dc:creator>choyt</dc:creator></item><item><title>RE: Passing Business Objects as variables</title><link>http://forum.strataframe.net/FindPost10586.aspx</link><description>Well, it is actually that simple. However, if you want your method/function/sub to handle different types of business objects then you'd need to use BusinessLayer (Microfour.StrataFrame.Business.BusinessLayer).&lt;br&gt;
&lt;br&gt;
I.e.&lt;br&gt;
&lt;br&gt;
[codesnippet]Sub DoIt(a As MyBO)[/codesnippet]&lt;br&gt;
&lt;br&gt;
will work with MyBO objects only, were as &lt;br&gt;
&lt;br&gt;
[codesnippet]Sub DoIt(a As BusinessLayer)[/codesnippet]&lt;br&gt;
&lt;br&gt;
will work with ANY business object.  &lt;br&gt;
&lt;br&gt;
Obviously what you do with the BO will determine which is better. Hope that helps! :D&lt;br&gt;</description><pubDate>Thu, 26 Jul 2007 17:53:05 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item></channel></rss>